OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalMultipoleTStraight.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 OpalMultipoleTStraight
45// ------------------------------------------------------------------------
46
48 OpalElement(SIZE, "MULTIPOLETSTRAIGHT",
49 "The \"MULTIPOLETSTRAIGHT\" element defines a straight, combined function multipole magnet.") {
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 ("EANGLE", "The entrance angle (rad)");
63 ("MAXFORDER",
64 "Number of terms used in each field component");
66 ("ROTATION",
67 "Rotation angle about its axis for skew elements (rad)");
69 ("BBLENGTH",
70 "Distance between centre of magnet and entrance in m");
71
73
74 setElement(new MultipoleTStraight("MULTIPOLETSTRAIGHT"));
75}
76
77
80 OpalElement(name, parent) {
82}
83
84
86{}
87
88
90 return new OpalMultipoleTStraight(name, this);
91}
92
93
94void OpalMultipoleTStraight::print(std::ostream &os) const {
96}
97
98
101
102 // Magnet length.
103 MultipoleTStraight *multT =
104 dynamic_cast<MultipoleTStraight*>(getElement());
105 double length = Attributes::getReal(itsAttr[LENGTH]);
106 double boundingBoxLength = Attributes::getReal(itsAttr[BBLENGTH]);
107 multT->setElementLength(length);
108 multT->setLength(length);
111
116 const std::vector<double> transProfile =
118 int transSize = transProfile.size();
119
120 multT->setTransMaxOrder(transSize - 1);
124
125 StraightGeometry &geometry = multT->getGeometry();
126
127 geometry = StraightGeometry(2 * boundingBoxLength);
128
129 for(int comp = 0; comp < transSize; comp++) {
130 multT->setTransProfile(comp, transProfile[comp]);
131 }
132 // Transmit "unknown" attributes.
134
135 setElement(multT);
136}
@ 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 setMaxOrder(const std::size_t &maxOrder) override
StraightGeometry & getGeometry() override
A geometry representing a straight line.
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
virtual OpalMultipoleTStraight * clone(const std::string &name)
void print(std::ostream &os) const
Print the object.