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);
76 fieldmap_m->getFieldstrength(tmpR, tmpE, tmpB);
87 fieldmap_m->getFieldstrength(tmpR, tmpE, tmpB);
94 Inform msg(
"RBend3D ", *gmsg);
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) {
142 double z = 0.0, dz = lengthField_m / 999;
143 double integratedBy = 0.0;
146 integratedBy += 0.5 * B(1);
148 while (z < lengthField_m) {
151 integratedBy += B(1);
154 integratedBy -= 0.5 * B(1);
155 integratedBy *= lengthField_m / 1000;
163 for (
unsigned int i = 0; i < 10; ++ i) {
174 double refCharge = bunch->
getQ();
176 if (refCharge < 0.0) {
184 endField = startField;
238 fieldmap_m->getFieldDimensions(XIni(0), XFinal(0),
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);
static OpalData * getInstance()
constexpr double c
The velocity of light in m/s.
ElementBase * clone() const override
item[EANGLE] Entrance edge angle(radians).\item[ROTATION] Rotation of the magnet about its central axis(radians
Tps< T > tan(const Tps< T > &x)
Tangent.
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)
Abstract base class for electromagnetic fields.
ParticleAttrib< Vector_t > P
double calcGamma() const
Calculate gamma from design energy.
Vektor< double, 3 > Vector_t
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
double calcBetaGamma() const
Calculate beta*gamma from design energy.
Abstract base class for accelerator geometry classes.
virtual void goOnline(const double &kineticEnergy) override
PartBunchBase< double, 3 > * RefPartBunch_m
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
bool writeBendTrajectories
virtual const std::string & getName() const
Get element name.
double getQ() const
Access to reference data.
constexpr double pi
The value of .
Inform & endl(Inform &inf)
std::vector< Vector_t > vertices_m
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
StraightGeometry geometry_m
double trackRefParticleThrough(double dt, bool print=false)
virtual bool isInside(const Vector_t &r) const override
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
virtual void finalise() override
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual void visitRBend3D(const RBend3D &)
Apply the algorithm to a rectangular bend.
double angle_m
Bend angle.
std::vector< Vektor< unsigned int, 3 > > triangles_m
virtual void accept(BeamlineVisitor &) const override
Apply visitor to RBend3D.
virtual double getElementLength() const
Get design length.
BGeometryBase & getGeometry() override
virtual void goOffline() override
double fieldAmplitudeError_m
virtual void getDimensions(double &zBegin, double &zEnd) const override
Tps< T > cos(const Tps< T > &x)
Cosine.
MeshData getSurfaceMesh() const
std::string combineFilePath(std::initializer_list< std::string > ilist)
Fieldmap fieldmap_m
Magnet field map.
const bool fast_m
Flag to turn on fast field calculation.
std::string getInputBasename()
get input file name without extension
virtual void setElementLength(double length)
Set design length.
virtual ElementType getType() const override
Get element type std::string.
Inform & level2(Inform &inf)
const PartData * getReference() const
BMultipoleField dummyField_m
double fieldAmplitude_m
Field amplitude.
EMField & getField() override
Tps< T > sin(const Tps< T > &x)
Sine.
static Fieldmap getFieldmap(std::string Filename, bool fast=false)
double calcFieldAmplitude(double radius) const
Calculate field amplitude from design energy and radius.