OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
OpalRingDefinition.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
29
30#include <limits>
31
32#include "AbsBeamline/Ring.h"
34#include "Physics/Units.h"
35
38 SIZE, "RINGDEFINITION",
39 "The \"RINGDEFINITION\" element defines basic ring parameters.") {
41 "HARMONIC_NUMBER",
42 "The assumed harmonic number of the ring (i.e. number of bunches in the ring on a "
43 "given "
44 "turn).");
46 "LAT_RINIT", "The initial radius of the first element to be placed in the ring [m].");
48 "LAT_PHIINIT",
49 "The initial angle around the ring of the first element to be placed. [deg]");
51 "LAT_THETAINIT",
52 "The angle relative to the tangent of the ring for the first element to be placed "
53 "[deg].");
55 "BEAM_PHIINIT", "The initial angle around the ring of the beam [deg].");
57 Attributes::makeReal("BEAM_PRINIT", "An initial pr momentum offset of the beam.");
58 itsAttr[BEAM_RINIT] = Attributes::makeReal("BEAM_RINIT", "The initial radius of the beam [m].");
59 itsAttr[SYMMETRY] = Attributes::makeReal("SYMMETRY", "The rotational symmetry of the lattice.");
60 itsAttr[SCALE] =
61 Attributes::makeReal("SCALE", "Scale the fields by a multiplicative factor", 1.0);
62 // should be in RF cavity definition; this comes from cyclotron definition,
63 // but not right
64 itsAttr[RFFREQ] = Attributes::makeReal("RFFREQ", "The nominal RF frequency of the ring [MHz].");
65 // I see also makeBool, but dont know how it works; no registerBoolAttribute
67 "IS_CLOSED", "Set to 'false' to disable checking for closure of the ring");
69 "MIN_R",
70 "Minimum allowed radius during tracking [m]. If not defined, any radius is allowed. If "
71 "MIN_R is defined, MAX_R must also be defined.");
73 "MAX_R",
74 "Maximum allowed radius during tracking [m]. If not defined, any radius is allowed. If "
75 "MAX_R is defined, MIN_R must also be defined.");
76
78
79 setElement(new Ring("RING"));
80}
81
83 return new OpalRingDefinition(name, this);
84}
85
86void OpalRingDefinition::print(std::ostream& out) const { OpalElement::print(out); }
87
89 : OpalElement(name, parent) {
90 setElement(new Ring(name));
91}
92
94
97
98 Ring* ring = dynamic_cast<Ring*>(getElement());
99
104
109
113
114 double minR = -1;
115 double maxR = -1;
116
117 if (itsAttr[MIN_R]) {
119 if (!itsAttr[MAX_R]) {
120 throw(""); // EXCEPTION
121 }
122 }
123 if (itsAttr[MAX_R]) {
125 if (!itsAttr[MIN_R]) {
126 throw(""); // EXCEPTION
127 }
128 ring->setRingAperture(minR, maxR);
129 }
130
133}
@ 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
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPALX) attributes to OPALX.
virtual void print(std::ostream &) const
Print the object.
virtual void update()
Update the embedded OPALX element.
void registerOwnership() const
virtual void print(std::ostream &) const
virtual OpalRingDefinition * clone(const std::string &name)
Ring describes a ring type geometry for tracking.
Definition Ring.h:62
void setSymmetry(double symmetry)
Definition Ring.h:285
void setBeamRInit(double rInit)
Definition Ring.h:237
void setIsClosed(bool isClosed)
Definition Ring.h:294
void setLatticeThetaInit(double thetaInit)
Definition Ring.h:276
void setHarmonicNumber(double cyclHarm)
Definition Ring.h:224
void setLatticePhiInit(double phiInit)
Definition Ring.h:261
void setRingAperture(double minR, double maxR)
Definition Ring.cpp:392
void setScale(double scale)
Definition Ring.h:288
void setBeamPRInit(double pRInit)
Definition Ring.h:249
void setBeamPhiInit(double phiInit)
Definition Ring.h:243
void setRFFreq(double rfFreq)
Definition Ring.h:231
void setLatticeRInit(double rInit)
Definition Ring.h:255
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
constexpr double m2mm
Definition Units.h:26
constexpr double deg2rad
Definition Units.h:143