32 straightGeometry_m(right.straightGeometry_m),
34 maxOrder_m(right.maxOrder_m),
37 zNegExtent_m(right.zNegExtent_m),
38 zPosExtent_m(right.zPosExtent_m),
39 halfWidth_m(right.halfWidth_m),
40 bbLength_m(right.bbLength_m),
41 endField_m(right.endField_m->clone()),
42 dfCoefficients_m(right.dfCoefficients_m)
98 std::vector<double> fringeDerivatives(
maxOrder_m+2, 0.);
100 for (
size_t i = 0; i < fringeDerivatives.size(); ++i) {
101 fringeDerivatives[i] =
endField_m->function(zRel, i);
106 for (
size_t i = 1; i < x_n.size(); ++i) {
107 x_n[i] = x_n[i-1] *
R[0];
113 std::vector<double> dz_f_n(
maxOrder_m + 1, 0.);
116 for (
size_t i = 0; i < coefficients.size(); ++i) {
117 f_n[
n] += coefficients[i] * fringeDerivatives[i];
118 dz_f_n[
n] += coefficients[i] * fringeDerivatives[i+1];
125 for (
size_t n = 0;
n < x_n.size(); ++
n) {
126 B[0] += bref * f_n[
n+1] * (
n+1) /
k_m * x_n[
n];
127 B[1] += bref * f_n[
n] * x_n[
n];
128 B[2] += bref * dz_f_n[
n] /
k_m * x_n[
n];
144 std::vector<double> coefficients(oldCoefficients.size() + 2, 0);
146 for (
size_t j = 0; j < oldCoefficients.size(); ++j) {
147 coefficients[j] += -1./(
n)/(
n-1) *
k_m *
k_m * oldCoefficients[j];
148 coefficients[j+2] += -1./(
n)/(
n-1) * oldCoefficients[j];
Tps< T > exp(const Tps< T > &x)
Exponential.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &)=0
Apply the algorithm to a vertical FFA magnet.
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
Bending magnet with an exponential dependence on field in the vertical plane.
void finalise()
Finalise the VerticalFFAMagnet - sets bunch to nullptr.
ElementBase * clone() const
Inheritable copy constructor.
void accept(BeamlineVisitor &visitor) const
Accept a beamline visitor.
bool getFieldValue(const Vector_t &R, Vector_t &B) const
Calculate the field at some arbitrary position in cartesian coordinates.
void initialise()
Initialise the VerticalFFAMagnet.
std::unique_ptr< endfieldmodel::EndFieldModel > endField_m
void calculateDfCoefficients()
BGeometryBase & getGeometry()
Return the cell geometry.
void setMaxOrder(size_t maxOrder)
Set the maximum power of x used in the off-midplane expansion;.
std::vector< std::vector< double > > dfCoefficients_m
StraightGeometry straightGeometry_m
EMField & getField()
Return a dummy (0.) field value (what is this for?)
VerticalFFAMagnet(const std::string &name)
Construct a new VerticalFFAMagnet.
~VerticalFFAMagnet()
Destructor - deletes the field.
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
Initialise the VerticalFFAMagnet.
void setEndField(endfieldmodel::EndFieldModel *endField)
Set the fringe field.
Abstract base class for accelerator geometry classes.
virtual void setElementLength(double length)
Set design length.
Abstract base class for electromagnetic fields.