OPAL (Object Oriented Parallel Accelerator Library) 2022.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 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//
19
20#include "AbsBeamline/EndFieldModel/Tanh.h" // classic
21#include "AbsBeamline/VerticalFFAMagnet.h" // classic
23#include "Physics/Units.h"
24
26 std::string("The \"VerticalFFAMagnet\" element defines a vertical FFA ")+
27 std::string("magnet, which has a field that increases in the vertical ")+
28 std::string("direction while maintaining similar orbits.");
30 OpalElement(SIZE, "VERTICALFFAMAGNET", docstring_m.c_str()) {
32 ("B0", "The nominal dipole field of the magnet at zero height [T].");
34 "Exponent term in the field index [m^(-1)].");
36 "The full width of the magnet. Particles moving more than WIDTH/2 horizontally, in either direction, are out of the aperture.");
37 itsAttr[MAX_HORIZONTAL_POWER] = Attributes::makeReal("MAX_HORIZONTAL_POWER",
38 "The maximum power in horizontal coordinate that will be considered in the field expansion.");
40 "The end length of the FFA fringe field [m].");
42 "The centre length of the FFA (i.e. length of the flat top) [m].");
44 "Determines the length of the bounding box. Magnet is situated symmetrically in the bounding box. [m]");
45 itsAttr[HEIGHT_POS_EXTENT] = Attributes::makeReal("HEIGHT_POS_EXTENT",
46 "Height of the magnet above z=0. Particles moving upwards more than HEIGHT_POS_EXTENT are out of the aperture [m].");
47 itsAttr[HEIGHT_NEG_EXTENT] = Attributes::makeReal("HEIGHT_NEG_EXTENT",
48 "Height of the magnet below z=0. Particles moving downwards more than HEIGHT_NEG_EXTENT are out of the aperture [m].");
49
51
52 VerticalFFAMagnet* magnet = new VerticalFFAMagnet("VerticalFFAMagnet");
53 magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
54 setElement(magnet);
55}
56
57
59 OpalVerticalFFAMagnet *parent) :
60 OpalElement(name, parent) {
62 magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
63 setElement(magnet);
64}
65
66
68}
69
70
72 return new OpalVerticalFFAMagnet(name, this);
73}
74
75
77 VerticalFFAMagnet *magnet =
78 dynamic_cast<VerticalFFAMagnet*>(getElement());
81 magnet->setMaxOrder(maxOrder);
87
88 // get centre length and end length in radians
89 endfieldmodel::Tanh* endField = dynamic_cast<endfieldmodel::Tanh*>(magnet->getEndField());
90 double end_length = Attributes::getReal(itsAttr[END_LENGTH]) * Units::m2mm;
91 double centre_length = Attributes::getReal(itsAttr[CENTRE_LENGTH]) * Units::m2mm;
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
constexpr double m2mm
Definition: Units.h:26
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:81
void setX0(double x0)
Definition: Tanh.h:110
void setLambda(double lambda)
Definition: Tanh.h:107
void setBBLength(double bbLength)
endfieldmodel::EndFieldModel * getEndField() const
void setWidth(double width)
void setMaxOrder(size_t maxOrder)
void setB0(double Bz)
void setNegativeVerticalExtent(double negativeExtent)
void setFieldIndex(double index)
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)