43 fieldAmplitudeError_m(right.fieldAmplitudeError_m),
44 startField_m(right.startField_m),
45 lengthField_m(right.lengthField_m),
46 geometry_m(right.geometry_m),
53 fieldAmplitudeError_m(0.0),
74 Vector_t tmpE(0.0, 0.0, 0.0), tmpB(0.0, 0.0, 0.0);
104 double zBegin = 0.0, zEnd = 0.0;
109 double fieldLength = zEnd - zBegin;
110 double z = 0.0, dz = fieldLength / 1000;
112 while (z < fieldLength && B(1) < 0.5) {
116 double zEntryEdge = z;
119 while (z > 0.0 && B(1) < 0.5) {
143 double integratedBy = 0.0;
146 integratedBy += 0.5 * B(1);
151 integratedBy += B(1);
154 integratedBy -= 0.5 * B(1);
163 for (
unsigned int i = 0; i < 10; ++ i) {
174 double refCharge = bunch->
getQ();
176 if (refCharge < 0.0) {
184 endField = startField;
271 const double stepSize = refBetaGamma / refGamma *
Physics::c * dt;
275 std::ofstream trajectoryOutput;
281 trajectoryOutput.open(fname);
282 trajectoryOutput.precision(12);
283 trajectoryOutput <<
"# " << std::setw(18) <<
"s"
284 << std::setw(20) <<
"x"
285 << std::setw(20) <<
"z"
286 << std::setw(20) <<
"By"
303 pusher.
push(
X, P, dt);
308 trajectoryOutput << std::setw(20) << deltaS + 0.5 * stepSize
309 << std::setw(20) <<
X(0)
310 << std::setw(20) <<
X(2)
311 << std::setw(20) << B(1)
315 pusher.
kick(
X, P, E, B, dt);
318 pusher.
push(
X, P, dt);
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > tan(const Tps< T > &x)
Tangent.
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TBTree< FnCopysign, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > copysign(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Inform & level2(Inform &inf)
Inform & endl(Inform &inf)
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
bool writeBendTrajectories
std::string combineFilePath(std::initializer_list< std::string > ilist)
const PartData * getReference() const
double getQ() const
Access to reference data.
ParticleAttrib< Vector_t > P
std::string getInputBasename()
get input file name without extension
static OpalData * getInstance()
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
virtual void visitRBend3D(const RBend3D &)
Apply the algorithm to a rectangular bend.
double calcGamma() const
Calculate gamma from design energy.
const bool fast_m
Flag to turn on fast field calculation.
double fieldAmplitude_m
Field amplitude.
double calcBetaGamma() const
Calculate beta*gamma from design energy.
Fieldmap * fieldmap_m
Magnet field map.
double calcFieldAmplitude(double radius) const
Calculate field amplitude from design energy and radius.
double angle_m
Bend angle.
PartBunchBase< double, 3 > * RefPartBunch_m
virtual const std::string & getName() const
Get element name.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.
ElementBase * clone() const override
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual void goOnline(const double &kineticEnergy) override
virtual void goOffline() override
BGeometryBase & getGeometry() override
virtual bool isInside(const Vector_t &r) const override
StraightGeometry geometry_m
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
double fieldAmplitudeError_m
virtual void finalise() override
BMultipoleField dummyField_m
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
virtual ElementType getType() const override
Get element type std::string.
double trackRefParticleThrough(double dt, bool print=false)
MeshData getSurfaceMesh() const
EMField & getField() override
virtual void accept(BeamlineVisitor &) const override
Apply visitor to RBend3D.
Abstract base class for accelerator geometry classes.
Abstract base class for electromagnetic fields.
virtual void getInfo(Inform *msg)=0
virtual void getFieldDimensions(double &zBegin, double &zEnd) const =0
static Fieldmap * getFieldmap(std::string Filename, bool fast=false)
virtual bool isInside(const Vector_t &) const
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const =0
std::vector< Vektor< unsigned int, 3 > > triangles_m
std::vector< Vector_t > vertices_m
void kick(const Vector_t &R, Vector_t &P, const Vector_t &Ef, const Vector_t &Bf, const double &dt) const
void push(Vector_t &R, const Vector_t &P, const double &dt) const
Vektor< double, 3 > Vector_t