OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalMultipoleTCurvedVarRadius.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 OpalMultipoleTCurvedVarRadius
45// ------------------------------------------------------------------------
46
48 OpalElement(SIZE, "MULTIPOLETCURVEDVARRADIUS",
49 "The \"MULTIPOLETCURVEDVARRADIUS\" element defines a combined function multipole.") {
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 setElement(new MultipoleTCurvedVarRadius("MULTIPOLETCURVEDVARRADIUS"));
80}
81
82
85 OpalElement(name, parent) {
87}
88
89
91{}
92
93
95 return new OpalMultipoleTCurvedVarRadius(name, this);
96}
97
98
99void OpalMultipoleTCurvedVarRadius::print(std::ostream &os) const {
101}
102
103
106
107 // Magnet length.
109 dynamic_cast<MultipoleTCurvedVarRadius*>(getElement());
110 double length = Attributes::getReal(itsAttr[LENGTH]);
111 double angle = Attributes::getReal(itsAttr[ANGLE]);
112 double boundingBoxLength = Attributes::getReal(itsAttr[BBLENGTH]);
113 multT->setElementLength(length);
114 multT->setLength(length);
115 multT->setBendAngle(angle);
118
123 const std::vector<double> transProfile =
125 std::size_t transSize = transProfile.size();
126
127 if (transSize == 0) {
128 multT->setTransMaxOrder(0);
129 } else {
130 multT->setTransMaxOrder(transSize - 1);
131 }
136
137 VarRadiusGeometry &geometry = multT->getGeometry();
138
139 geometry = VarRadiusGeometry(2 * boundingBoxLength,
140 (length / angle),
141 length / 2,
144
145 for(std::size_t comp = 0; comp < transSize; comp++) {
146 multT->setTransProfile(comp, transProfile[comp]);
147 }
148 // Transmit "unknown" attributes.
150
151 setElement(multT);
152}
@ 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)
virtual void setBendAngle(const double &angle) override
VarRadiusGeometry & getGeometry() override
virtual void setMaxOrder(const std::size_t &maxOrder) override
void setMaxXOrder(const std::size_t &maxXOrder)
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 OpalMultipoleTCurvedVarRadius * clone(const std::string &name)