Coder Social home page Coder Social logo

Checking of Madx commands about cpymad HOT 4 CLOSED

coldfix avatar coldfix commented on July 29, 2024
Checking of Madx commands

from cpymad.

Comments (4)

mina-acc avatar mina-acc commented on July 29, 2024

Hello
I want to use the flag "error" in cpymad, but I don't know how! I already use it in Madx and there was no problem. This is the error block in my madx file:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Select, flag=error, clear = true;
select, flag=error, class=quadrupole;
efcomp, order:=0, radius:=0.013,
dknr={tgauss(2)*1e-4,tgauss(2)*1e-3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
select, flag=error, class=quadrupole;
esave,file=efield.tab0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have already checked the installed cpymad on my pc with the twiss example and everything works correctly. I was wondering if you could help me.
Thanks!

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

Hey, welcome to github!

Two beginner tips first:

  • please open new issues to discuss separate topics.
  • you can fence off code blocks as shown here, so your formatting doesn't get lost.

Did you consider to just leave these commands in a .madx file and madx.call() that file from cpymad? This is much easier and recommended if you are only going to change parameters manually. In general, you probably don't need cpymad if you are not trying to write a program which generates commands automatically or adjusts parameters dynamically.

If you really do need python code to input these commands: Most MAD-X commands can be converted to python syntax pretty straight forward, e.g.:

# (assuming your Madx instance is called `madx`:)
madx.command.select(flag="error", clear=True)
# note the trailing underscore in 'class_' is needed because class is a python keyword:
madx.command.select(flag="error", class_="quadrupole")
# Now this command is a bit non-standard and currently cpymad does a bad job getting it right.
# But you can still generate your command string manually and input it to cpymad:
madx.input('efcomp, order:=0, radius:=0.013, dknr={tgauss(2)*1e-4,tgauss(2)*1e-3};')
madx.command.esave(file="efield.tab0")

I agree that many of this should be simplified and made more straight forward, but this is not on the top of my priority list right now;)

from cpymad.

mina-acc avatar mina-acc commented on July 29, 2024

Hi.
Sorry for discussing this issue here. I thought that I found the related topic for my issue.
Yes. I already used the madx.call() command. The main motivation for me for switching to cpymad was that I need to use different seeds for the errors and calculating twiss function for each error data. I used while loop in MADX to change the seed every time, add errors to magnets and calculating twiss function. The madx problem was that it rewrites the twiss file each time in loop, so I only have access to the twiss data of last turn in loop.
I tried to use cpymad, so I could save the error and twiss data for any individual seed in each turn of while loop.
Thanks for your informative response. That works, except the part 'class_="quadrupole"'. Cpymad didn't recognize the quadrupoles. Instead, I use "pattern" and call all of the quadrupoles by their names.

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

Concerning the original issue: implemented in the branch merged in 24717d2.

from cpymad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.