MAD-X icon indicating copy to clipboard operation
MAD-X copied to clipboard

Bug in aperture definition of aper_vx

Open roman-martin opened this issue 3 years ago • 7 comments

consider the following script:

//---------------------------------------------
//----Element definition-----------------------
//---------------------------------------------
foil: collimator, apertype=circle, aperture={0.000005}, aper_vx:={-a,-a,k,k}, aper_vy:={-a,a,a,-a};
a = 1.0;
k = 0.1;
//---------------------------------------------
//----/Element definition----------------------
//---------------------------------------------
beam;

testseq: sequence, l=4;
    foil, at=2.0;
endsequence;

use, sequence=testseq;
track, onepass,  APERTURE=true;
    start, x=0.005, px=0, y=0, py=0, t=0, pt=0;
    run, turns=10;
endtrack;

it defines an arbitrary aperture with aper_vx/vy using the parameters a and k, then tracks a particle through it. You will see that the particle finishes all 10 turns.

However, if you change the element definition part to

//---------------------------------------------
//----Element definition-----------------------
//---------------------------------------------
a = 1.0;
k = 0.1;
foil: collimator, apertype=circle, aperture={0.000005}, aper_vx:={-a,-a,k,k}, aper_vy:={-a,a,a,-a};
//---------------------------------------------
//----/Element definition----------------------
//---------------------------------------------

i.e. if the parameters a and k are defined before the element, the particle will be lost in the first turn.

A similar issue comes up with

//---------------------------------------------
//----Element definition-----------------------
//---------------------------------------------
foil: collimator, apertype=circle, aperture={0.000005}, aper_vx:={-1.0,-a,k,k}, aper_vy:={-a,a,a,-a};
a = 1.0;
k = 0.1;
//---------------------------------------------
//----/Element definition----------------------
//---------------------------------------------

where one instance of a in aper_vx is replaced with the corresponding floating point number.

roman-martin avatar Feb 11 '22 16:02 roman-martin