OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalVariableRFCavity.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 "Physics/Physics.h"
35
36extern Inform *gmsg;
37
38const std::string OpalVariableRFCavity::doc_string =
39 std::string("The \"VARIABLE_RF_CAVITY\" element defines an RF cavity ")+
40 std::string("with time dependent frequency, phase and amplitude.");
41
43 OpalElement(SIZE, "VARIABLE_RF_CAVITY", doc_string.c_str()) {
45 "The name of the phase time dependence model, which should give the phase in [rad].");
47 "The name of the amplitude time dependence model, which should give the field in [MV/m]");
49 "The name of the frequency time dependence model, which should give the field in [MHz].");
51 "Full width of the cavity [m].");
53 "Full height of the cavity [m].");
54
56
57 setElement(new VariableRFCavity("VARIABLE_RF_CAVITY"));
58}
59
61 OpalVariableRFCavity *parent) :
62 OpalElement(name, parent) {
63 VariableRFCavity *cavity = dynamic_cast<VariableRFCavity*>(
64 parent->getElement());
65 setElement(new VariableRFCavity(*cavity));
66}
67
69}
70
72 return new OpalVariableRFCavity(name, this);
73}
74
76 return new OpalVariableRFCavity(this->getOpalName(), this);
77}
78
81
82 VariableRFCavity *cavity = dynamic_cast<VariableRFCavity*>(
83 getElement());
84 double length = Attributes::getReal(itsAttr[LENGTH]);
85 cavity->setLength(length);
86 std::string phaseName = Attributes::getString(itsAttr[PHASE_MODEL]);
87 cavity->setPhaseName(phaseName);
88 std::string ampName = Attributes::getString(itsAttr[AMPLITUDE_MODEL]);
89 cavity->setAmplitudeName(ampName);
90 std::string freqName = Attributes::getString(itsAttr[FREQUENCY_MODEL]);
91 cavity->setFrequencyName(freqName);
92 double width = Attributes::getReal(itsAttr[WIDTH]);
93 cavity->setWidth(width);
94 double height = Attributes::getReal(itsAttr[HEIGHT]);
95 cavity->setHeight(height);
96 setElement(cavity);
97}
@ SIZE
Definition: IndexMap.cpp:174
Inform * gmsg
Definition: Main.cpp:61
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
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 setPhaseName(std::string phase)
virtual void setHeight(double fullHeight)
virtual void setAmplitudeName(std::string amplitude)
virtual void setLength(double length)
virtual void setWidth(double fullWidth)
virtual void setFrequencyName(std::string frequency)
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
OpalVariableRFCavity * clone()
static const std::string doc_string
Definition: Inform.h:42