Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit cbe4a67f authored by Christof Metzger-Kraus's avatar Christof Metzger-Kraus
Browse files

fixing #162; was introduced when both SBend and RBend were rewritten to be...

fixing #162; was introduced when both SBend and RBend were rewritten to be derived from 'Bend' class
parent 7bd3f165
No related branches found
No related tags found
No related merge requests found
......@@ -1073,6 +1073,7 @@ bool Bend::FindIdealBendParameters(double chordLength) {
bendAngle = 2.0 * Physics::pi - bendAngle;
angle_m = bendAngle;
return false;
} else {
......@@ -1538,6 +1539,9 @@ bool Bend::SetupBendGeometry(Inform &msg, double &startField, double &endField)
}
reinitialize_m = FindIdealBendParameters(chordLength);
if (getType() == RBEND) {
SetEntranceAngle(getEntranceAngle());
}
FindReferenceExitOrigin(xExit_m, zExit_m);
/*
......
......@@ -141,6 +141,10 @@ protected:
double getLength();
double getMapLength();
double bX_m; /// Amplitude of Bx field (T).
double bY_m; /// Amplitude of By field (T).
double designEnergy_m; /// Bend design energy (eV).
private:
// Not implemented.
......@@ -214,11 +218,8 @@ private:
double angle_m; /// Bend angle for reference particle with bend
/// design energy (radians).
double aperture_m; /// Aperture of magnet in non-bend plane.
double designEnergy_m; /// Bend design energy (eV).
double designRadius_m; /// Bend design radius (m).
double fieldAmplitude_m; /// Amplitude of magnet field (T).
double bX_m; /// Amplitude of Bx field (T).
double bY_m; /// Amplitude of By field (T).
bool angleGreaterThanPi_m; /// Set to true if bend angle is greater than
/// 180 degrees.
double entranceAngle_m; /// Angle between incoming reference trajectory
......
......@@ -153,8 +153,21 @@ bool RBend::FindChordLength(Inform &msg,
* Find bend chord length. If this was not set by the user using the
* L (length) attribute, infer it from the field map.
*/
chordLength = 2 * getLength() * sin(0.5 * std::abs(getAngle())) /
(sin(getEntranceAngle()) + sin(std::abs(getAngle()) - getEntranceAngle()));
const double angle = getAngle();
if (std::abs(angle) > 0.0) {
chordLength = 2 * getLength() * sin(0.5 * std::abs(angle)) /
(sin(getEntranceAngle()) + sin(std::abs(angle) - getEntranceAngle()));
} else {
double refMass = RefPartBunch_m->getM();
double refGamma = designEnergy_m / refMass + 1.0;
double refBetaGamma = sqrt(pow(refGamma, 2.0) - 1.0);
double refCharge = RefPartBunch_m->getQ();
double amplitude = (std::abs(bY_m) > 0.0? bY_m: bX_m);
double fieldAmplitude = refCharge * std::abs(amplitude / refCharge);
double designRadius = std::abs(refBetaGamma * refMass / (Physics::c * fieldAmplitude));
chordLength = sin(0.5 * (asin(getLength() / designRadius - sin(getEntranceAngle())) + getEntranceAngle())) * 2 * designRadius;
}
if(chordLength > 0.0) {
chordLengthFromMap = false;
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment