MethodicalAcceleratorDesign / MAD-X

MAD-X repository
Other
48 stars 39 forks source link

PTC tracking computation issue when momentum spread is included #1172

Open LucaBiasia opened 1 year ago

LucaBiasia commented 1 year ago

Hi, I am trying to track 1000 non-relativistic muons (28 MeV) passing through a quadrupole using MAD-X PTC library. In the case of monochromatic particles I get the expected results (compared with other programs). When I try to include momentum spread in the sampled particles (I sample only the particles on the border of the phase space ellipse) I would expect only a slightly deviation of the points from the phase space ellipse border, but I get the artifatc you can see in the following image (representing the normalized final phase space): NORM_PS_WITH_MOMENTUM_SPREAD This gets worse if the momentum spread increases and also if the CORRELATION in the initial phase space increases! The following plot shows the same result, but with -0.995 x axis correlation and 0.995 y axis correlation: NORM_PS_WITH_MOMENTUM_SPREAD_CORR

I tried to apply different models for the PTC tracking procedure but i didn't manage to find the reason behind this problem. I will attach an example of the python code below. particle_tracking.zip

This is how the initial phase space looks like: PHASE_SPACE_TEST

Thank you for your help!

ldeniau commented 1 year ago

I never use MADX-PTC from Python so my comments will only focus on the quadrupole definition and its use. The best is also to provide the MADX-PTC script generated by your Python script (I let Riccardo take over this part).

  1. remove the definition of the aperture just to be sure that you don't hit the limits (can be restored once things get back to normal)

  2. define your quad in the simplest way, your definition uses a contradictory setup...

    • QSK : quadrupole, l={L_QSK}, k1={strength};
    • remove knl={} and thick=true (used by makethin only).
  3. simplify the setup of PTC to what is really needed

    • ntpsa is useless and less tested than berz (default)
    • model 2 is useless with your "thin" definition, but needed with the thick definition as above.
    • nst =10 is needed only if your strength is extremely high with a phase advance larger than pi.
    • remove resplit, thin, and xbend.
    • use exact=true.
  4. In 5D, pt=(E-E0)/p0c, your setup with pt_ps tends to set it to delta_p, which is the same as soon as your energy is large enough to get relativistic beta = 1

Then tell us what are the obtained results.

LucaBiasia commented 1 year ago

Thank you for your fast reply.

I was defining knl={} because subsequently i would like to include multipoles (as i know that PTC can treat multipoles as thick elements).

Anyway I followed all of your suggestions and the result is the following: NORM_PS_WITH_MOMENTUM_SPREAD It looks like the non focusing axis (Y) have a different behaviour (I've found a similar result in other previous simulations).

For what concerns 4., Is it correct with time=false in 5D to define pt_ps as deltap instead of pt? (my particles won't get relativistic and relativistic beta is not ~1).

Thanks.

ldeniau commented 1 year ago

I was defining knl={} because subsequently i would like to include multipoles (as i know that PTC can treat multipoles as thick elements).

It is the opposite, thick elements can have multipoles with MADX-PTC and MAD-NG, so better to define your quad as mentioned and add later the knl (and ksl) without the k1l included.

Concerning 4. you are right.

For more investigation, we need a pure MADX standalone working example.