OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalMultipoleTCurvedConstRadius.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Titus Dascalu
3 * Copyright (c) 2018, Martin Duy Tat
4 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * 3. Neither the name of STFC nor the names of its contributors may be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29
35#include "Expressions/SValue.h"
37#include "Physics/Physics.h"
38#include "Utilities/Options.h"
39#include <iostream>
40#include <sstream>
41#include <vector>
42
43
44// Class OpalMultipoleTCurvedConstRadius
45// ------------------------------------------------------------------------
46
48 OpalElement(SIZE, "MULTIPOLETCURVEDCONSTRADIUS",
49 "The \"MULTIPOLETCURVEDCONSTRADIUS\" element defines a curved combined function multipole magnet of constant curvature.") {
51 ("TP", "Transverse Profile derivatives in m^(-k)");
53 ("LFRINGE", "The length of the left end field in m");
55 ("RFRINGE", "The length of the right end field in m");
57 ("HAPERT", "The aperture width in m");
59 ("VAPERT", "The aperture height in m");
61 ("ANGLE", "The azimuthal angle of the magnet in ring (rad)");
63 ("EANGLE", "The entrance angle (rad)");
65 ("MAXFORDER",
66 "Number of terms used in each field component");
68 ("MAXXORDER",
69 "Number of terms used in polynomial expansions");
71 ("ROTATION",
72 "Rotation angle about its axis for skew elements (rad)");
74 ("BBLENGTH",
75 "Distance between centre of magnet and entrance in m");
76
78
79
80 setElement(new MultipoleTCurvedConstRadius("MULTIPOLETCURVEDCONSTRADIUS"));
81}
82
83
86 OpalElement(name, parent) {
88}
89
90
92{}
93
94
96 return new OpalMultipoleTCurvedConstRadius(name, this);
97}
98
99
100void OpalMultipoleTCurvedConstRadius::print(std::ostream &os) const {
102}
103
104
107
108 // Magnet length.
110 dynamic_cast<MultipoleTCurvedConstRadius*>(getElement());
111 double length = Attributes::getReal(itsAttr[LENGTH]);
112 double angle = Attributes::getReal(itsAttr[ANGLE]);
113 double boundingBoxLength = Attributes::getReal(itsAttr[BBLENGTH]);
114 multT->setElementLength(length);
115 multT->setLength(length);
116 multT->setBendAngle(angle);
119
124 const std::vector<double> transProfile =
126 std::size_t transSize = transProfile.size();
127 if (transSize == 0) {
128 multT->setTransMaxOrder(0);
129 } else {
130 multT->setTransMaxOrder(transSize - 1);
131 }
132
137
138 PlanarArcGeometry &geometry = multT->getGeometry();
139
140 if(length) {
141 geometry = PlanarArcGeometry(2 * boundingBoxLength, angle / length);
142 } else {
143 geometry = PlanarArcGeometry(angle);
144 }
145
146 for(std::size_t comp = 0; comp < transSize; comp++) {
147 multT->setTransProfile(comp, transProfile[comp]);
148 }
149 // Transmit "unknown" attributes.
151
152 setElement(multT);
153}
@ SIZE
Definition: IndexMap.cpp:174
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
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:289
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:294
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
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
void setRotation(const double &rot)
void setLength(const double &length)
void setEntranceAngle(const double &entranceAngle)
void setTransProfile(const std::size_t &n, const double &Bn)
bool setFringeField(const double &s0, const double &lambda_left, const double &lambda_right)
void setBoundingBoxLength(const double &boundingBoxLength)
void setAperture(const double &vertAp, const double &horizAp)
void setTransMaxOrder(const std::size_t &transMaxOrder)
void setMaxXOrder(const std::size_t &maxXOrder)
virtual void setBendAngle(const double &angle) override
PlanarArcGeometry & getGeometry() override
virtual void setMaxOrder(const std::size_t &maxOrder) override
A simple arc in the XZ plane.
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void print(std::ostream &) const
Print the object.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
void print(std::ostream &os) const
Print the object.
virtual OpalMultipoleTCurvedConstRadius * clone(const std::string &name)