OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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" // OPALX
21#include "AbsBeamline/VerticalFFAMagnet.h" // OPALX
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 Attributes::makeReal("FIELD_INDEX", "Exponent term in the field index [m^(-1)].");
36 "WIDTH",
37 "The full width of the magnet. Particles moving more than WIDTH/2 horizontally, in "
38 "either direction, are out of the aperture.");
40 "MAX_HORIZONTAL_POWER",
41 "The maximum power in horizontal coordinate that will be considered in the field "
42 "expansion.");
44 Attributes::makeReal("END_LENGTH", "The end length of the FFA fringe field [m].");
46 "CENTRE_LENGTH", "The centre length of the FFA (i.e. length of the flat top) [m].");
48 "BB_LENGTH",
49 "Determines the length of the bounding box. Magnet is situated symmetrically in the "
50 "bounding box. [m]");
52 "HEIGHT_POS_EXTENT",
53 "Height of the magnet above z=0. Particles moving upwards more than HEIGHT_POS_EXTENT "
54 "are out of the aperture [m].");
56 "HEIGHT_NEG_EXTENT",
57 "Height of the magnet below z=0. Particles moving downwards more than "
58 "HEIGHT_NEG_EXTENT are out of the aperture [m].");
59
61
62 VerticalFFAMagnet* magnet = new VerticalFFAMagnet("VerticalFFAMagnet");
63 magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
64 setElement(magnet);
65}
66
68 : OpalElement(name, parent) {
69 VerticalFFAMagnet* magnet = new VerticalFFAMagnet(name);
70 magnet->setEndField(new endfieldmodel::Tanh(1., 1., 1));
71 setElement(magnet);
72}
73
75
77 return new OpalVerticalFFAMagnet(name, this);
78}
79
81 VerticalFFAMagnet* magnet = dynamic_cast<VerticalFFAMagnet*>(getElement());
83 int maxOrder = floor(Attributes::getReal(itsAttr[MAX_HORIZONTAL_POWER]));
84 magnet->setMaxOrder(maxOrder);
90
91 // get centre length and end length in radians
92 endfieldmodel::Tanh* endField = dynamic_cast<endfieldmodel::Tanh*>(magnet->getEndField());
93 double end_length = Attributes::getReal(itsAttr[END_LENGTH]) * Units::m2mm;
94 double centre_length = Attributes::getReal(itsAttr[CENTRE_LENGTH]) * Units::m2mm;
95 endField->setLambda(end_length);
96 // x0 is the distance between B=0.5*B0 and B=B0 i.e. half the centre length
97 endField->setX0(centre_length / 2.);
98 endField->setTanhDiffIndices(maxOrder + 2);
99 magnet->initialise();
100 // setElement(magnet);
101}
@ SIZE
Definition IndexMap.cpp:179
ElementBase * getElement() const
Return the embedded OPALX element.
Definition Element.h:119
void setElement(ElementBase *)
Assign new OPALX element.
Definition Element.h:123
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
void registerOwnership() const
static std::string docstring_m
virtual OpalVerticalFFAMagnet * clone(const std::string &name)
void setBBLength(double bbLength)
endfieldmodel::EndFieldModel * getEndField() const
void setWidth(double width)
void initialise(PartBunch_t *bunch, double &startField, double &endField)
void setMaxOrder(size_t maxOrder)
void setB0(double Bz)
void setNegativeVerticalExtent(double negativeExtent)
void setFieldIndex(double index)
void setEndField(endfieldmodel::EndFieldModel *endField)
void setPositiveVerticalExtent(double positiveExtent)
static void setTanhDiffIndices(size_t n)
Definition Tanh.cpp:72
void setX0(double x0)
Definition Tanh.h:110
void setLambda(double lambda)
Definition Tanh.h:107
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
constexpr double m2mm
Definition Units.h:26