svenreiche / Genesis-1.3-Version4

Time-dependent, 3D Code to simulate the amplification process of a Free-electron Laser.
GNU General Public License v3.0
53 stars 26 forks source link

[BUG] cx is units of radians, not $\gamma \beta_x$ #153

Closed ChristopherMayes closed 7 months ago

ChristopherMayes commented 7 months ago

Describe the bug The manual states that: https://github.com/svenreiche/Genesis-1.3-Version4/blob/9f9f00ff787d8561e9e1b7b14cd6a30038c48f55/manual/LATTICE.md?plain=1#L61

However, this seems to be just an angle in units of radians, not units of $\gamma \beta_x$

To Reproduce Create a simple lattice with a corrector:

D1: DRIFT = { l = 1};
C1: corrector = {l=0.01, cx=1e-3};
LAT: LINE= { D1, C1, D1};

and any beam. The change in transverse momentum is then observed to be approximately cx * p, with p as the total momentum.

balticfish commented 7 months ago

Sven, could you comment on the internal units of px in TrackBeam.cpp?

svenreiche commented 7 months ago

This is a typo in the documents. The intention is that the corrector should give a net deflection independent to the beam energy. This is in strickt analogy to the quadrupoles in the lattice, which are expressed by k1 and also independent on the beam energy. Internally Genesis uses beta_x*gamma as the transverse momentum.

I will correct the manual in the next update.

balticfish commented 7 months ago

Thanks, Sven! I have a follow up question. In TrackBeam.cpp:123, you are adding the values of cx, cy to px. Do you divide by gamma_z somewhere else?

      beam->beam.at(i).at(j).px+=cx;
      beam->beam.at(i).at(j).py+=cy;
svenreiche commented 7 months ago

Hi Alex,

In Genesis, pushing the particles is done in three steps: 1) Tracking the transverse coordinates half the integration step 2) Tracking the longitudinal a full integration step 3) Tracking the transverse coordinates the second half.

This can be found in Beam::track . Note that the routine is track.solver. The last argument is a bool indicating whether it is the first or last half step.

For the second half step, the routine scales the angle with the particle momentum with gammaref (See Trackbeam::track line 38, where the kick is applied). There you see that the corrector kick is multiplied with the beam energy to get the right units for px and py, which is given by beta_xgamma or beta_ygamma.

One could argue that the kick should also scale with gammaz instead of gammaref.

Hope this helps.

svenreiche commented 7 months ago

Manual corrected with the latest commit

balticfish commented 7 months ago

Thank you for clarification!