OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
OpalTravelingWave.cpp
Go to the documentation of this file.
1//
2// Class OpalTravelingWave
3// The TRAVELINGWAVE 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//
22#include "Physics/Physics.h"
23#include "Physics/Units.h"
24
26 OpalElement(SIZE, "TRAVELINGWAVE",
27 "The \"TRAVELINGWAVE\" element defines a traveling wave structure.")
28 {
30 ("VOLT", "RF voltage in MV/m");
32 ("DVOLT", "RF voltage error in MV/m");
34 ("FREQ", "RF frequency in MHz");
36 ("LAG", "Phase lag in rad");
38 ("DLAG", "Phase lag error in rad");
40 ("FMAPFN", "Filename for the fieldmap");
42 ("FAST", "Faster but less accurate", true);
44 ("APVETO", "Do not use this cavity in the Autophase procedure", false);
46 ("NUMCELLS", "Number of cells in a TW structure");
48 ("DESIGNENERGY", "the mean energy of the particles at exit", -1.0);
50 ("MODE", "The phase shift between neighboring cells in 2*pi", 1.0/3.0);
51
53
54 setElement(new TravelingWaveRep("TRAVELINGWAVE"));
55}
56
57
59 OpalElement(name, parent) {
61}
62
63
65}
66
67
69 return new OpalTravelingWave(name, this);
70}
71
72
75
76 TravelingWaveRep *rfc =
77 dynamic_cast<TravelingWaveRep *>(getElement());
78
79 double length = Attributes::getReal(itsAttr[LENGTH]);
80 double vPeak = Attributes::getReal(itsAttr[VOLT]);
81 double vPeakError = Attributes::getReal(itsAttr[DVOLT]);
82 double phase = Attributes::getReal(itsAttr[LAG]);
83 double phaseError = Attributes::getReal(itsAttr[DLAG]);
85 std::string fmapfm = Attributes::getString(itsAttr[FMAPFN]);
86 bool fast = Attributes::getBool(itsAttr[FAST]);
87 bool apVeto = Attributes::getBool(itsAttr[APVETO]);
88
89 // std::string type = Attributes::getString(itsAttr[TYPE]);
90 double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]);
91
92 rfc->setElementLength(length);
93 rfc->setAmplitude(Units::MVpm2Vpm * vPeak);
94 rfc->setFrequency(freq);
95 rfc->setPhase(phase);
96
97 rfc->setFieldMapFN(fmapfm);
98 rfc->setFast(fast);
99 rfc->setAutophaseVeto(apVeto);
100 rfc->setAmplitudem(vPeak);
101 rfc->setAmplitudeError(vPeakError);
102 rfc->setFrequencym(freq);
103 rfc->setPhasem(phase);
104 rfc->setPhaseError(phaseError);
107 rfc->setDesignEnergy(kineticEnergy);
108
109 // Transmit "unknown" attributes.
111}
@ SIZE
Definition: IndexMap.cpp:173
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
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
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
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
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.
Definition: ElementBase.h:400
virtual void setAmplitudeError(double vPeakError)
Definition: RFCavity.h:324
virtual void setAmplitudem(double vPeak)
Definition: RFCavity.h:316
virtual void setPhaseError(double phaseError)
Definition: RFCavity.h:356
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
virtual void setAutophaseVeto(bool veto=true)
Definition: RFCavity.h:376
virtual void setDesignEnergy(const double &ekin, bool changeable=true) override
Definition: RFCavity.h:300
virtual void setFast(bool fast)
Definition: RFCavity.h:368
void setNumCells(int NumCells)
void setMode(double mode)
virtual void setPhasem(double phase) override
ElementBase * getElement() const
Return the embedded CLASSIC element.
void setElement(ElementBase *)
Assign new CLASSIC element.
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 void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC cavity.
OpalTravelingWave()
Exemplar constructor.
virtual OpalTravelingWave * clone(const std::string &name)
Make clone.