Charge per macroparticle wrong for multicharged particles?
Summary
The charge per macroparticle seems wrongly calculated in case of OPAL-T.
This was discovered by Finn O'Shea, and posted to the OPAL mailing list.
Steps to reproduce
BEAM1: BEAM, PARTICLE=PROTON, PC=P0, NPART=1000, BCURRENT=2.0e-03, BFREQ=50, CHARGE=1;
BEAM2: BEAM, PARTICLE=ALPHA, PC=P0, NPART=1000, BCURRENT=2.0e-03, BFREQ=50, CHARGE=2, MASS=3.7274;
What is the current bug behavior?
BEAM1:
OPAL> * ************** B U N C H *********************************************************
OPAL> * NP = 1000
OPAL> * Qtot = 39.500 [pC] Qi = 39.500 [fC]
BEAM2:
OPAL> * ************** B U N C H *********************************************************
OPAL> * NP = 1000
OPAL> * Qtot = 79.000 [pC] Qi = 79.000 [fC]
What is the expected correct behavior?
These two beams are expected to have the same charge per bunch and macroparticle (since BCURRENT
and FREQ
are constant).
Relevant logs and/or screenshots
In TrackRun::setDistributionParallelT():
// Return charge per macroparticle.
return beam->getCharge() * beam->getCurrent() / (beam->getFrequency()*1.0e6) / numberOfParticles;
Possible fixes
The factor beam->getCharge()
should not be present in the formula. This is correctly calculated for OPAL-Cycl. Ideally the formula should be refactored to a separate function to reduce code duplication.
Edited by snuverink_j