OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
OpalCavity.cpp
Go to the documentation of this file.
1//
2// Class OpalCavity
3// The RFCAVITY element.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#include "Elements/OpalCavity.h"
19
24#include "Physics/Physics.h"
25#include "Physics/Units.h"
27
28
30 OpalElement(SIZE, "RFCAVITY",
31 "The \"RFCAVITY\" element defines an RF cavity."),
32 obgeo_m(nullptr) {
34 ("VOLT", "RF voltage in MV");
36 ("DVOLT", "RF voltage error in MV");
38 ("FREQ", "RF frequency in MHz");
40 ("LAG", "Phase lag (rad)");
42 ("DLAG", "Phase lag error (rad)");
44 ("FMAPFN", "Filename of the fieldmap");
46 ("GEOMETRY", "BoundaryGeometry for Cavities");
48 ("FAST", "Faster but less accurate", true);
50 ("APVETO", "Do not use this cavity in the Autophase procedure", false);
52 ("RMIN", " Minimal Radius of a cyclotron cavity [mm]");
54 ("RMAX", " Maximal Radius of a cyclotron cavity [mm]");
56 ("ANGLE", "Azimuth position of a cyclotron cavity [deg]");
58 ("PDIS", "Shift distance of cavity gap from center of cyclotron [mm]");
60 ("GAPWIDTH", "Gap width of a cyclotron cavity [mm]");
62 ("PHI0", "Initial phase of cavity [deg]");
64 ("DESIGNENERGY", "the mean energy of the particles at exit", -1.0);
65 // attibutes for timedependent values
67 "The name of the phase time dependence model.");
69 "The name of the amplitude time dependence model.");
71 "The name of the frequency time dependence model.");
72
74
75 setElement(new RFCavityRep("RFCAVITY"));
76}
77
78
79OpalCavity::OpalCavity(const std::string &name, OpalCavity *parent):
80 OpalElement(name, parent),
81 obgeo_m(nullptr) {
82 setElement(new RFCavityRep(name));
83}
84
85
88
89
90OpalCavity *OpalCavity::clone(const std::string &name) {
91 return new OpalCavity(name, this);
92}
93
94
97
98 RFCavityRep *rfc =
99 dynamic_cast<RFCavityRep *>(getElement());
100
101 double length = Attributes::getReal(itsAttr[LENGTH]);
102 double peak = Attributes::getReal(itsAttr[VOLT]);
103 double peakError = Attributes::getReal(itsAttr[DVOLT]);
104 double phase = Attributes::getReal(itsAttr[LAG]);
105 double phaseError = Attributes::getReal(itsAttr[DLAG]);
107 std::string fmapfn = Attributes::getString(itsAttr[FMAPFN]);
108 std::string type = Attributes::getString(itsAttr[TYPE]);
109 bool fast = Attributes::getBool(itsAttr[FAST]);
110 bool apVeto = (Attributes::getBool(itsAttr[APVETO]));
111
112 double rmin = Attributes::getReal(itsAttr[RMIN]);
113 double rmax = Attributes::getReal(itsAttr[RMAX]);
114 double angle = Attributes::getReal(itsAttr[ANGLE]);
115 double pdis = Attributes::getReal(itsAttr[PDIS]);
116 double gapwidth = Attributes::getReal(itsAttr[GAPWIDTH]);
117 double phi0 = Attributes::getReal(itsAttr[PHI0]);
118 double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]);
119
120 rfc->setElementLength(length);
121
122 rfc->setAmplitude(Units::MVpm2Vpm * peak);
123 rfc->setFrequency(freq);
124 rfc->setPhase(phase);
125
126 rfc->dropFieldmaps();
127
128 rfc->setAmplitudem(peak);
129 rfc->setAmplitudeError(peakError);
130 rfc->setFrequencym(freq);
131 rfc->setPhasem(phase);
132 rfc->setPhaseError(phaseError);
133 rfc->setFieldMapFN(fmapfn);
134
135 rfc->setFast(fast);
136 rfc->setAutophaseVeto(apVeto);
137 rfc->setCavityType(type);
138 rfc->setRmin(rmin);
139 rfc->setRmax(rmax);
140 rfc->setAzimuth(angle);
141 rfc->setPerpenDistance(pdis);
142 rfc->setGapWidth(gapwidth);
143 rfc->setPhi0(phi0);
144 rfc->setDesignEnergy(kineticEnergy);
145
149
150 // Transmit "unknown" attributes.
152}
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.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
constexpr double two_pi
The value of.
Definition Physics.h:33
constexpr double MHz2Hz
Definition Units.h:113
constexpr double MVpm2Vpm
Definition Units.h:128
virtual void setElementLength(double length)
Set design length.
void setPerpenDistance(double pdis)
Definition RFCavity.cpp:274
virtual void setAmplitudeError(double vPeakError)
Definition RFCavity.h:324
void setPhaseModelName(std::string name)
Definition RFCavity.h:400
void setRmin(double rmin)
Definition RFCavity.cpp:262
void setFrequencyModelName(std::string name)
Definition RFCavity.h:412
void setAmplitudeModelName(std::string name)
Definition RFCavity.h:388
virtual void setAmplitudem(double vPeak)
Definition RFCavity.h:316
virtual void setPhaseError(double phaseError)
Definition RFCavity.h:356
virtual void setPhasem(double phase)
Definition RFCavity.h:344
void setPhi0(double phi0)
Definition RFCavity.cpp:282
virtual void setFrequencym(double freq)
Definition RFCavity.h:336
virtual void setFieldMapFN(const std::string &fmapfn)
Set the name of the field map.
Definition RFCavity.h:312
void setAzimuth(double angle)
Definition RFCavity.cpp:270
void setCavityType(const std::string &type)
Definition RFCavity.cpp:318
void dropFieldmaps()
Definition RFCavity.h:308
virtual void setAutophaseVeto(bool veto=true)
Definition RFCavity.h:376
virtual void setDesignEnergy(const double &ekin, bool changeable=true) override
Definition RFCavity.h:300
void setGapWidth(double gapwidth)
Definition RFCavity.cpp:278
virtual void setFast(bool fast)
Definition RFCavity.h:368
void setRmax(double rmax)
Definition RFCavity.cpp:266
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 setPhase(double phi)
Set phase.
virtual void setFrequency(double f)
Set frequency.
virtual void setAmplitude(double V)
Set amplitude.
virtual ~OpalCavity()
@ AMPLITUDE_MODEL
Definition OpalCavity.h:49
@ FREQUENCY_MODEL
Definition OpalCavity.h:50
virtual OpalCavity * clone(const std::string &name)
Make clone.
virtual void update()
Update the embedded CLASSIC cavity.
BoundaryGeometry * obgeo_m
Definition OpalCavity.h:74
OpalCavity()
Exemplar constructor.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown'' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
OpalElement(int size, const char *name, const char *help)
Exemplar constructor.
void registerOwnership() const