OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalVerticalFFAMagnet.cpp
Go to the documentation of this file.
1 //
2 // Class OpalVerticalFFAMagnet
3 // The class provides the user interface for the VERTICALFFA object
4 //
5 // Copyright (c) 2019 Chris Rogers
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #include "Attributes/Attributes.h"
19 
20 #include "AbsBeamline/EndFieldModel/Tanh.h" // classic
21 #include "AbsBeamline/VerticalFFAMagnet.h" // classic
23 
25  std::string("The \"VerticalFFAMagnet\" element defines a vertical FFA ")+
26  std::string("magnet, which has a field that increases in the vertical ")+
27  std::string("direction while maintaining similar orbits.");
29  OpalElement(SIZE, "VERTICALFFAMAGNET", docstring_m.c_str()) {
31  ("B0", "The nominal dipole field of the magnet at zero height [T].");
32  itsAttr[FIELD_INDEX] = Attributes::makeReal("FIELD_INDEX",
33  "Exponent term in the field index [m^(-1)].");
35  "The full width of the magnet. Particles moving more than WIDTH/2 horizontally, in either direction, are out of the aperture.");
36  itsAttr[MAX_HORIZONTAL_POWER] = Attributes::makeReal("MAX_HORIZONTAL_POWER",
37  "The maximum power in horizontal coordinate that will be considered in the field expansion.");
38  itsAttr[END_LENGTH] = Attributes::makeReal("END_LENGTH",
39  "The end length of the FFA fringe field [m].");
40  itsAttr[CENTRE_LENGTH] = Attributes::makeReal("CENTRE_LENGTH",
41  "The centre length of the FFA (i.e. length of the flat top) [m].");
42  itsAttr[BB_LENGTH] = Attributes::makeReal("BB_LENGTH",
43  "Determines the length of the bounding box. Magnet is situated symmetrically in the bounding box. [m]");
44  itsAttr[HEIGHT_POS_EXTENT] = Attributes::makeReal("HEIGHT_POS_EXTENT",
45  "Height of the magnet above z=0. Particles moving upwards more than HEIGHT_POS_EXTENT are out of the aperture [m].");
46  itsAttr[HEIGHT_NEG_EXTENT] = Attributes::makeReal("HEIGHT_NEG_EXTENT",
47  "Height of the magnet below z=0. Particles moving downwards more than HEIGHT_NEG_EXTENT are out of the aperture [m].");
48 
50 
51  VerticalFFAMagnet* magnet = new VerticalFFAMagnet("VerticalFFAMagnet");
52  magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
53  setElement(magnet);
54 }
55 
56 
58  OpalVerticalFFAMagnet *parent) :
59  OpalElement(name, parent) {
61  magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
62  setElement(magnet);
63 }
64 
65 
67 }
68 
69 
71  return new OpalVerticalFFAMagnet(name, this);
72 }
73 
74 
76  VerticalFFAMagnet *magnet =
77  dynamic_cast<VerticalFFAMagnet*>(getElement());
80  magnet->setMaxOrder(maxOrder);
86 
87  // get centre length and end length in radians
88  endfieldmodel::Tanh* endField = dynamic_cast<endfieldmodel::Tanh*>(magnet->getEndField());
89  double mm = 1e3;
90  double end_length = Attributes::getReal(itsAttr[END_LENGTH])*mm;
91  double centre_length = Attributes::getReal(itsAttr[CENTRE_LENGTH])*mm/2.;
92  endField->setLambda(end_length);
93  // x0 is the distance between B=0.5*B0 and B=B0 i.e. half the centre length
94  endField->setX0(centre_length/2.);
95  endField->setTanhDiffIndices(maxOrder+2);
96  magnet->initialise();
97  setElement(magnet);
98 }
@ SIZE
Definition: IndexMap.cpp:174
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:733
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
static void setTanhDiffIndices(size_t n)
Definition: Tanh.cpp:76
void setX0(double x0)
Definition: Tanh.h:101
void setLambda(double lambda)
Definition: Tanh.h:98
void setBBLength(double bbLength)
void setWidth(double width)
void setMaxOrder(size_t maxOrder)
void setB0(double Bz)
void setNegativeVerticalExtent(double negativeExtent)
void setFieldIndex(double index)
endfieldmodel::EndFieldModel * getEndField() const
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
void setEndField(endfieldmodel::EndFieldModel *endField)
void setPositiveVerticalExtent(double positiveExtent)
void registerOwnership() const
static std::string docstring_m
virtual OpalVerticalFFAMagnet * clone(const std::string &name)