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] Generated particles do not honor the requested bunching #136

Closed ChristopherMayes closed 7 months ago

ChristopherMayes commented 7 months ago

Describe the bug Above some value for bunching, the particles that Genesis4 produces do not show the requested level. Scanning over several values shows:

image

To Reproduce Using the following input, the bunching from the particles is 0.44 and not 0.5 as requested. The distribution in a typical slice looks like:

image
&setup
rootname = drift_test
lattice = genesis4_drift.lat
beamline = LAT
lambda0 = 1e-07
gamma0 = 1000
seed = 123456
&end

&time
slen = 100e-7
sample = 1
&end

&beam
current = 1000
gamma = 1000
delgam = 1
bunch = 0.5
&end

&track
zstop = 1e-09
&end

&write
beam = end
&end

with genesis4_drift.lat:


D1: DRIFT = { L= 1e-9 };
LAT: LINE= { D1 };

Expected behavior Bunching equal to the request is expected.

ChristopherMayes commented 7 months ago

The code that does this is: https://github.com/svenreiche/Genesis-1.3-Version4/blob/694c1d0c7d9d6a49f93e88ecc5629f9f4d970bce/src/Loading/QuietLoading.cpp#L258

Integrating gives the bunching = $J_1(2b)$,

image
svenreiche commented 7 months ago

Hi Christopher, yes it is an bug since it does not reach the value one specifies.
The basic algorithm mimics the basic process how the FEL forms the bunching but it is limited to the Bessel Function value of J1. To go beyond I have to include higher harmonics. should be straight forward but it will takes some time.

Working on it....

svenreiche commented 7 months ago

The loading algorithm has been fixed and can now reproduce bunching factors up to 1.
To keep some back-compatibilities the correction is only applied for requested bunching values above 0.1 The updated code has been committed to master and dev branch