Commit d9f907ba authored by kraus's avatar kraus
Browse files

output the trajectory of every dipole

parent fe761512
......@@ -803,6 +803,54 @@ void Bend::CalculateRefTrajectory(double &angleX, double &angleY) {
else
angleY = atan2(P(1), P(2));
std::ofstream traj(std::string("data/") + getName() + std::string("_traj.dat"));
traj.precision(8);
double E1 = getEntranceAngle();
double cosE1 = cos(0.5 * E1), sinE1 = sin(0.5 * E1);
double zRotation = Orientation_m(2);
Quaternion toStandard = (Quaternion(cosE1, sinE1 * Vector_t(0, 1, 0)) *
Quaternion(cos(0.5 * zRotation), sin(0.5 * zRotation) * Vector_t(0, 0, -1)));
X = Vector_t(0.0, 0.0, startField_m - elementEdge_m);
P = Vector_t(0.0, 0.0, betaGamma);
deltaS = 0.0;
while(deltaS < bendLength) {
X /= Vector_t(Physics::c * dt);
pusher_m.push(X, P, dt);
X *= Vector_t(Physics::c * dt);
Vector_t eField(0.0, 0.0, 0.0);
Vector_t bField(0.0, 0.0, 0.0);
Vector_t XInBendFrame = RotateToBendFrame(X);
/*
* Add in transverse bend displacements. (ds is already
* accounted for.)
*/
CalculateMapField(XInBendFrame, eField, bField);
bField = fieldAmplitude_m * RotateOutOfBendFrame(bField);
X /= Vector_t(Physics::c * dt);
pusher_m.kick(X, P, eField, bField, dt);
Vector_t R = toStandard.rotate(X * Physics::c * dt);
traj << std::setw(16) << R(0)
<< std::setw(16) << R(2)
<< std::setw(16) << bField(1)
<< std::endl;
pusher_m.push(X, P, dt);
X *= Vector_t(Physics::c * dt);
deltaS += refTrajMapStepSize_m;
}
}
double Bend::EstimateFieldAdjustmentStep(double actualBendAngle,
......
......@@ -374,7 +374,7 @@ void OpalBeamline::prepareSections() {
CompVec tmp;
FieldList::iterator flit;
list<double>::iterator pos_it, next_it, last_it;
const double tolerance = 1.e-4;
const double tolerance = 1.e-10;
if (elements_m.size() == 0) {
prepared_m = true;
......@@ -529,4 +529,4 @@ FieldList OpalBeamline::getElementByType(ElementBase::ElementType type) {
}
}
return elements_of_requested_type;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment