OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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", "The \"RINGDEFINITION\" element defines basic ring parameters.") {
40 "HARMONIC_NUMBER",
41 "The assumed harmonic number of the ring (i.e. number of bunches in the ring on a given "
42 "turn).");
44 "LAT_RINIT", "The initial radius of the first element to be placed in the ring [m].");
46 "LAT_PHIINIT",
47 "The initial angle around the ring of the first element to be placed. [deg]");
49 "LAT_THETAINIT",
50 "The angle relative to the tangent of the ring for the first element to be placed [deg].");
52 "BEAM_PHIINIT", "The initial angle around the ring of the beam [deg].");
54 Attributes::makeReal("BEAM_PRINIT", "An initial pr momentum offset of the beam.");
55 itsAttr[BEAM_RINIT] = Attributes::makeReal("BEAM_RINIT", "The initial radius of the beam [m].");
56 itsAttr[SYMMETRY] = Attributes::makeReal("SYMMETRY", "The rotational symmetry of the lattice.");
57 itsAttr[SCALE] =
58 Attributes::makeReal("SCALE", "Scale the fields by a multiplicative factor", 1.0);
59 // should be in RF cavity definition; this comes from cyclotron definition,
60 // but not right
61 itsAttr[RFFREQ] = Attributes::makeReal("RFFREQ", "The nominal RF frequency of the ring [MHz].");
62 // I see also makeBool, but dont know how it works; no registerBoolAttribute
64 "IS_CLOSED", "Set to 'false' to disable checking for closure of the ring");
66 "MIN_R",
67 "Minimum allowed radius during tracking [m]. If not defined, any radius is allowed. If "
68 "MIN_R is defined, MAX_R must also be defined.");
70 "MAX_R",
71 "Maximum allowed radius during tracking [m]. If not defined, any radius is allowed. If "
72 "MAX_R is defined, MIN_R must also be defined.");
73
75
76 setElement(new Ring("RING"));
77}
78
80 return new OpalRingDefinition(name, this);
81}
82
83void OpalRingDefinition::print(std::ostream& out) const {
85}
86
88 : OpalElement(name, parent) {
89 setElement(new Ring(name));
90}
91
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}
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
Ring describes a ring type geometry for tracking.
Definition Ring.h:62
void setSymmetry(double symmetry)
Definition Ring.h:322
void setBeamRInit(double rInit)
Definition Ring.h:250
void setIsClosed(bool isClosed)
Definition Ring.h:337
void setLatticeThetaInit(double thetaInit)
Definition Ring.h:309
void setHarmonicNumber(double cyclHarm)
Definition Ring.h:229
void setLatticePhiInit(double phiInit)
Definition Ring.h:290
void setRingAperture(double minR, double maxR)
Definition Ring.cpp:390
void setScale(double scale)
Definition Ring.h:327
void setBeamPRInit(double pRInit)
Definition Ring.h:270
void setBeamPhiInit(double phiInit)
Definition Ring.h:260
void setRFFreq(double rfFreq)
Definition Ring.h:240
void setLatticeRInit(double rInit)
Definition Ring.h:280
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition Element.h:121
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition Element.h:126
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
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.
OpalElement(int size, const char *name, const char *help)
Exemplar constructor.
void registerOwnership() const
virtual void print(std::ostream &) const
virtual OpalRingDefinition * clone(const std::string &name)