Bend2D does not take particle charge into account
Summary
A RBEND
or SBEND
element does not take the particle charge into account.
This was discovered by Finn O'Shea, and posted to the OPAL mailing list.
Steps to reproduce
Define two beams and a bend:
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;
REAL switch_angle = 0.1;
REAL design_energy = 0.05;
SBEND, ANGLE = switch_angle,
FMAPFN = "1DPROFILE1-DEFAULT",
ELEMEDGE = 2.664,
DESIGNENERGY = design_energy,
L = 2 * switch_radius * sin(switch_angle / 2.0),
E1 = 0, E2 = 0, // make a "true" sector magnet
What is the current bug behavior?
Same bend magnet strength for each beam.
What is the expected correct behavior?
Different bending strength, reduced by a factor 2 for BEAM2.
Relevant logs and/or screenshots
void Bend2D::setBendStrength() {
// Estimate bend field magnitude.
double mass = RefPartBunch_m->getM();
double gamma = designEnergy_m / mass + 1.0;
double betaGamma = sqrt(pow(gamma, 2.0) - 1.0);
double charge = RefPartBunch_m->getQ();
fieldAmplitude_m = ((charge / std::abs(charge)) * betaGamma * mass /
(Physics::c * designRadius_m));
This formula does only take the sign of the charge into account. It is repeated in findIdealBendParameters
Possible fixes
The formulas should be adjusted such that the charge is taken into account properly. The following methods should be fixed:
- setBendStrength
- findIdealBendParameters
Possibly also:
- findBendStrength
- estimateFieldAdjustmentStep
Edited by snuverink_j