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);
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) {
168 if (std::abs(error) < 0.001)
break;
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);
std::vector< Vektor< unsigned int, 3 > > triangles_m
std::vector< Vector_t > vertices_m
Inform & level2(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)
double getQ() const
Access to reference data.
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(const std::string &name)
Constructor with given name.
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
RBend3D(const std::string &name)
Constructor with given name.
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.
static Fieldmap getFieldmap(std::string Filename, bool fast=false)
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