The TransverseOffset parameter of BunchTrain shifts the space charge in the wrong direction (for em-field calculation)
The following configuration file can be used to reproduce the issue: test.xml
It contains the following BunchTrain
definition:
<BunchTrain>
<Type>SingleBunch</Type>
<TransverseOffset unit="mm">[ 5, 0 ]</TransverseOffset>
</BunchTrain>
Hence, the bunch center and thus the center of the bunch electric field is shifted by 5 mm in positive x-direction. However, the electric field calculation places the center in the opposite direction:
This is due to an sign error in the function that transforms the particle positions from the lab frame to the bunch frame. While this transformation should subtract the transverse offset of the bunch, it erroneously adds it (see here).