Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user defined variables in Match function #139

Open
Rays-Accelerator-Design opened this issue Nov 5, 2024 · 1 comment
Open

user defined variables in Match function #139

Rays-Accelerator-Design opened this issue Nov 5, 2024 · 1 comment

Comments

@Rays-Accelerator-Design
Copy link

Is it possible to use user defined variables in the match function. or

Ex:

    mad.match(sequence=SEQ_Name,
    constraints=[
    dict(range="FOCUSINGQUAD",
            myvar=Constraint(min=-0, max=0),
            alfy=bety,
            ),

Trying to define variable in madx file does not work and is not recognized.

@coldfix
Copy link
Member

coldfix commented Dec 13, 2024

Hi,
I just realized I haven't answered on this so far.
As cpymad acts only as a proxy to input commands to MAD-X, it is limited by what type of constraints can be provided in the MAD-X language. In your example, the Madx.match() method would generate commands like this:

match, sequence="seq0";
constraint, myvar>0, myvar<0, alfy=bety;

However, MAD-X commands are defined using a fixed set of possible parameter names. So, no, I would say it is not possible in this form, you can only specify the compiled-in parameters, which you can look up e.g. like this:

>>> mad.command.constraint
constraint, weight=1.0, range=#s/#e, iindex=-1.0, pattern=any, betx=None, alfx=None, mux=None, bety=None, alfy=None, muy=None, x=None, px=None, y=None, py=None, t=None, pt=None, dx=None, dpx=None, dy=None, dpy=None, wx=None, phix=None, dmux=None, wy=None, phiy=None, dmuy=None, ddx=None, ddpx=None, ddy=None, ddpy=None, r11=None, r12=None, r21=None, r22=None, energy=None, mvar1=None, mvar2=None, mvar3=None, mvar4=None, re11=None, re12=None, re13=None, re14=None, re15=None, re16=None, re21=None, re22=None, re23=None, re24=None, re25=None, re26=None, re31=None, re32=None, re33=None, re34=None, re35=None, re36=None, re41=None, re42=None, re43=None, re44=None, re45=None, re46=None, re51=None, re52=None, re53=None, re54=None, re55=None, re56=None, re61=None, re62=None, re63=None, re64=None, re65=None, re66=None, sig11=None, sig12=None, sig13=None, sig14=None, sig15=None, sig16=None, sig21=None, sig22=None, sig23=None, sig24=None, sig25=None, sig26=None, sig31=None, sig32=None, sig33=None, sig34=None, sig35=None, sig36=None, sig41=None, sig42=None, sig43=None, sig44=None, sig45=None, sig46=None, sig51=None, sig52=None, sig53=None, sig54=None, sig55=None, sig56=None, sig61=None, sig62=None, sig63=None, sig64=None, sig65=None, sig66=None, alfa=None, beta11=None, alfa11=None, mu1=None, beta22=None, alfa22=None, mu2=None, beta33=None, alfa33=None, mu3=None, disp1=None, disp2=None, disp3=None, disp4=None;

I personally haven't used MAD-X in a while, so it would be better to ask a MAD-X user who is more update-to-date and knowledgeable if they know a better way to achieve your goal.

Best,
Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants