OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 - 2023 Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
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 //
19 
22 #include "Attributes/Attributes.h"
23 
24 const std::string OpalVerticalFFAMagnet::docstring_m =
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.");
28 
30  OpalElement(SIZE, "VERTICALFFAMAGNET", docstring_m.c_str()) {
31 
33  ("B0", "The nominal dipole field of the magnet at zero height [T].");
34 
36  ("FIELD_INDEX", "Exponent term in the field index [m^(-1)].");
37 
39  ("WIDTH",
40  "The full width of the magnet. Particles moving more than WIDTH/2 horizontally, "
41  "in either direction, are out of the aperture.");
42 
44  ("MAX_HORIZONTAL_POWER",
45  "The maximum power in horizontal coordinate that will be considered in the field expansion.");
46 
48  ("END_LENGTH", "The end length of the FFA fringe field [m].");
49 
51  ("CENTRE_LENGTH", "The centre length of the FFA (i.e. length of the flat top) [m].");
52 
54  ("BB_LENGTH",
55  "Determines the length of the bounding box. Magnet is situated "
56  "symmetrically in the bounding box. [m]");
57 
59  ("HEIGHT_POS_EXTENT",
60  "Height of the magnet above z=0. Particles moving upwards more than "
61  "HEIGHT_POS_EXTENT are out of the aperture [m].");
62 
64  ("HEIGHT_NEG_EXTENT",
65  "Height of the magnet below z=0. Particles moving downwards more than "
66  "HEIGHT_NEG_EXTENT are out of the aperture [m].");
67 
69 
70  VerticalFFAMagnet* magnet = new VerticalFFAMagnet("VerticalFFAMagnet");
71  magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
72  setElement(magnet);
73 }
74 
76  OpalVerticalFFAMagnet* parent) :
77  OpalElement(name, parent) {
79  magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
80  setElement(magnet);
81 }
82 
84 }
85 
87  return new OpalVerticalFFAMagnet(name, this);
88 }
89 
92 
95  magnet->setMaxOrder(maxOrder);
101 
102  // get centre length and end length in radians
103  endfieldmodel::Tanh* endField = dynamic_cast<endfieldmodel::Tanh*>(magnet->getEndField());
104  double end_length = Attributes::getReal(itsAttr[END_LENGTH]);
105  double centre_length = Attributes::getReal(itsAttr[CENTRE_LENGTH]);
106  endField->setLambda(end_length);
107  // x0 is the distance between B=0.5*B0 and B=B0 i.e. half the centre length
108  endField->setX0(centre_length / 2.);
109  endField->setTanhDiffIndices(maxOrder + 2);
110  magnet->initialise();
111  setElement(magnet);
112 }
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
void setPositiveVerticalExtent(double positiveExtent)
void setFieldIndex(double index)
void setEndField(endfieldmodel::EndFieldModel *endField)
void setLambda(double lambda)
Definition: Tanh.h:107
void setB0(double Bz)
static const std::string docstring_m
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
endfieldmodel::EndFieldModel * getEndField() const
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
void setX0(double x0)
Definition: Tanh.h:110
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
virtual OpalVerticalFFAMagnet * clone(const std::string &name)
void setWidth(double width)
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
void setBBLength(double bbLength)
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
void setNegativeVerticalExtent(double negativeExtent)
void setMaxOrder(size_t maxOrder)
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:733
static void setTanhDiffIndices(size_t n)
Definition: Tanh.cpp:81
void registerOwnership() const
item[EANGLE] Entrance edge counterclockwise This enables to obtain skew at each point along the magnet
Definition: multipole_t.tex:32