OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
27 SIZE, "TRAVELINGWAVE",
28 "The \"TRAVELINGWAVE\" element defines a traveling wave structure.") {
29 itsAttr[VOLT] = Attributes::makeReal("VOLT", "RF voltage in MV/m");
30 itsAttr[DVOLT] = Attributes::makeReal("DVOLT", "RF voltage error in MV/m");
31 itsAttr[FREQ] = Attributes::makeReal("FREQ", "RF frequency in MHz");
32 itsAttr[LAG] = Attributes::makeReal("LAG", "Phase lag in rad");
33 itsAttr[DLAG] = Attributes::makeReal("DLAG", "Phase lag error in rad");
34 itsAttr[FMAPFN] = Attributes::makeString("FMAPFN", "Filename for the fieldmap");
35 itsAttr[FAST] = Attributes::makeBool("FAST", "Faster but less accurate", true);
37 "APVETO", "Do not use this cavity in the Autophase procedure", false);
38 itsAttr[NUMCELLS] = Attributes::makeReal("NUMCELLS", "Number of cells in a TW structure");
40 Attributes::makeReal("DESIGNENERGY", "the mean energy of the particles at exit", -1.0);
42 "MODE", "The phase shift between neighboring cells in 2*pi", 1.0 / 3.0);
43
45
46 setElement(new TravelingWaveRep("TRAVELINGWAVE"));
47}
48
50 : OpalElement(name, parent) {
52}
53
55
57 return new OpalTravelingWave(name, this);
58}
59
62
63 TravelingWaveRep* rfc = dynamic_cast<TravelingWaveRep*>(getElement());
64
65 double length = Attributes::getReal(itsAttr[LENGTH]);
66 double vPeak = Attributes::getReal(itsAttr[VOLT]);
67 double vPeakError = Attributes::getReal(itsAttr[DVOLT]);
68 double phase = Attributes::getReal(itsAttr[LAG]);
69 double phaseError = Attributes::getReal(itsAttr[DLAG]);
71 std::string fmapfm = Attributes::getString(itsAttr[FMAPFN]);
72 bool fast = Attributes::getBool(itsAttr[FAST]);
73 bool apVeto = Attributes::getBool(itsAttr[APVETO]);
74
75 // std::string type = Attributes::getString(itsAttr[TYPE]);
76 double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]);
77
78 rfc->setElementLength(length);
79 rfc->setAmplitude(Units::MVpm2Vpm * vPeak);
80 rfc->setFrequency(freq);
81 rfc->setPhase(phase);
82
83 rfc->setFieldMapFN(fmapfm);
84 rfc->setFast(fast);
85 rfc->setAutophaseVeto(apVeto);
86 rfc->setAmplitudem(vPeak);
87 rfc->setAmplitudeError(vPeakError);
88 rfc->setFrequencym(freq);
89 rfc->setPhasem(phase);
90 rfc->setPhaseError(phaseError);
93 rfc->setDesignEnergy(kineticEnergy);
94
95 // Transmit "unknown" attributes.
97}
@ SIZE
Definition IndexMap.cpp:179
virtual void setElementLength(double length)
Set design length.
ElementBase * getElement() const
Return the embedded OPALX element.
Definition Element.h:119
void setElement(ElementBase *)
Assign new OPALX element.
Definition Element.h:123
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPALX) attributes to OPALX.
virtual void update()
Update the embedded OPALX element.
void registerOwnership() const
virtual void update()
Update the embedded OPALX cavity.
OpalTravelingWave()
Exemplar constructor.
virtual OpalTravelingWave * clone(const std::string &name)
Make clone.
virtual void setAmplitudeError(double vPeakError)
Definition RFCavity.h:333
virtual void setAmplitudem(double vPeak)
Definition RFCavity.h:329
virtual void setPhaseError(double phaseError)
Definition RFCavity.h:349
virtual void setFrequencym(double freq)
Definition RFCavity.h:339
virtual void setFieldMapFN(const std::string &fmapfn)
Set the name of the field map.
Definition RFCavity.h:327
virtual void setAutophaseVeto(bool veto=true)
Definition RFCavity.h:359
virtual void setDesignEnergy(const double &ekin, bool changeable=true) override
Definition RFCavity.h:321
virtual void setFast(bool fast)
Definition RFCavity.h:355
virtual void setPhase(double phi)
Set phase.
virtual void setFrequency(double f)
Set frequency.
virtual void setAmplitude(double V)
Set amplitude.
void setNumCells(int NumCells)
void setMode(double mode)
virtual void setPhasem(double phase) override
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:40
constexpr double MHz2Hz
Definition Units.h:113
constexpr double MVpm2Vpm
Definition Units.h:128