OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
22
23const std::string OpalVariableRFCavity::doc_string =
24 std::string("The \"VARIABLE_RF_CAVITY\" element defines an RF cavity ")
25 + std::string("with time dependent frequency, phase and amplitude.");
26
28 : OpalElement(SIZE, "VARIABLE_RF_CAVITY", doc_string.c_str()) {
30 "PHASE_MODEL",
31 "The name of the phase time dependence model, which should give the phase in [rad].");
32
34 "AMPLITUDE_MODEL",
35 "The name of the amplitude time dependence model, which should give the field in "
36 "[MV/m]");
37
39 "FREQUENCY_MODEL",
40 "The name of the frequency time dependence model, which should give the frequency in "
41 "[MHz].");
42
43 itsAttr[WIDTH] = Attributes::makeReal("WIDTH", "Full width of the cavity [m].");
44
45 itsAttr[HEIGHT] = Attributes::makeReal("HEIGHT", "Full height of the cavity [m].");
46
48
49 setElement(new VariableRFCavity("VARIABLE_RF_CAVITY"));
50}
51
53 : OpalElement(name, parent) {
54 const VariableRFCavity* cavity = dynamic_cast<VariableRFCavity*>(parent->getElement());
55 setElement(new VariableRFCavity(*cavity));
56}
57
59 return new OpalVariableRFCavity(name, this);
60}
61
65
68
69 auto* cavity = dynamic_cast<VariableRFCavity*>(getElement());
70
71 const double length = Attributes::getReal(itsAttr[LENGTH]);
72 cavity->setLength(length);
73
74 const std::string phaseName = Attributes::getString(itsAttr[PHASE_MODEL]);
75 cavity->setPhaseName(phaseName);
76
77 const std::string ampName = Attributes::getString(itsAttr[AMPLITUDE_MODEL]);
78 cavity->setAmplitudeName(ampName);
79
80 const std::string freqName = Attributes::getString(itsAttr[FREQUENCY_MODEL]);
81 cavity->setFrequencyName(freqName);
82
83 const double width = Attributes::getReal(itsAttr[WIDTH]);
84 cavity->setWidth(width);
85
86 const double height = Attributes::getReal(itsAttr[HEIGHT]);
87 cavity->setHeight(height);
88
89 setElement(cavity);
90}
@ 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
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:267
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
virtual void update()
Update the embedded OPALX element.
void registerOwnership() const
OpalVariableRFCavity * clone()
static const std::string doc_string
double getReal(const Attribute &attr)
Return real value.
Attribute makeUpperCaseString(const std::string &name, const std::string &help)
Make uppercase string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
std::string getString(const Attribute &attr)
Get string value.