OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
OpalVariableRFCavity.cpp
Go to the documentation of this file.
1//
2// Class OpalVariableRFCavity
3// The class provides the user interface for the VARIABLE_RF_CAVITY object.
4//
5// Copyright (c) 2014 - 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
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//
19
23
24const std::string OpalVariableRFCavity::doc_string =
25 std::string("The \"VARIABLE_RF_CAVITY\" element defines an RF cavity ") +
26 std::string("with time dependent frequency, phase and amplitude.");
27
29 OpalElement(SIZE, "VARIABLE_RF_CAVITY", doc_string.c_str()) {
30
32 ("PHASE_MODEL",
33 "The name of the phase time dependence model, which should give the phase in [rad].");
34
36 ("AMPLITUDE_MODEL",
37 "The name of the amplitude time dependence model, which should give the field in [MV/m]");
38
40 ("FREQUENCY_MODEL",
41 "The name of the frequency time dependence model, which should give the field in [MHz].");
42
44 ("WIDTH",
45 "Full width of the cavity [m].");
46
48 ("HEIGHT",
49 "Full height of the cavity [m].");
50
52
53 setElement(new VariableRFCavity("VARIABLE_RF_CAVITY"));
54}
55
57 OpalVariableRFCavity* parent):
58 OpalElement(name, parent) {
59 VariableRFCavity* cavity = dynamic_cast<VariableRFCavity*>(parent->getElement());
60 setElement(new VariableRFCavity(*cavity));
61}
62
65
67 return new OpalVariableRFCavity(name, this);
68}
69
73
76
77 VariableRFCavity*cavity = dynamic_cast<VariableRFCavity*>(getElement());
78
79 double length = Attributes::getReal(itsAttr[LENGTH]);
80 cavity->setLength(length);
81
82 std::string phaseName = Attributes::getString(itsAttr[PHASE_MODEL]);
83 cavity->setPhaseName(phaseName);
84
85 std::string ampName = Attributes::getString(itsAttr[AMPLITUDE_MODEL]);
86 cavity->setAmplitudeName(ampName);
87
88 std::string freqName = Attributes::getString(itsAttr[FREQUENCY_MODEL]);
89 cavity->setFrequencyName(freqName);
90
91 double width = Attributes::getReal(itsAttr[WIDTH]);
92 cavity->setWidth(width);
93
94 double height = Attributes::getReal(itsAttr[HEIGHT]);
95 cavity->setHeight(height);
96
97 setElement(cavity);
98}
const std::string name
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition Element.h:125
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
virtual void setHeight(double fullHeight)
virtual void setPhaseName(const std::string &phase)
virtual void setAmplitudeName(const std::string &amplitude)
virtual void setLength(double length)
virtual void setFrequencyName(const std::string &frequency)
virtual void setWidth(double fullWidth)
virtual void update()
Update the embedded CLASSIC element.
OpalElement(int size, const char *name, const char *help)
Exemplar constructor.
void registerOwnership() const
OpalVariableRFCavity * clone()
OpalVariableRFCavity(const std::string &name, OpalVariableRFCavity *parent)
static const std::string doc_string