OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
TravelingWaveRep.cpp
Go to the documentation of this file.
1//
2// Class TravelingWaveRep
3// Representation for a traveling wave.
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//
20
22
23namespace {
24 struct Entry {
25 const char *name;
26 double(TravelingWaveRep::*get)() const;
27 void (TravelingWaveRep::*set)(double);
28 };
29
30 static const Entry entries[] = {
31 {
32 "L",
35 },
36 {
37 "AMPLITUDE",
40 },
41 {
42 "FREQUENCY",
45 },
46 {
47 "PHASE",
50 },
51 { 0, 0, 0 }
52 };
53}
54
55
59
60
64
65
66TravelingWaveRep::TravelingWaveRep(const std::string &name):
67 TravelingWave(name)
68{}
69
70
73
74
76 return new TravelingWaveRep(*this);
77}
78
79
80Channel *TravelingWaveRep::getChannel(const std::string &aKey, bool create) {
81 for(const Entry *entry = entries; entry->name != 0; ++entry) {
82 if(aKey == entry->name) {
83
84 return new IndirectChannel<TravelingWaveRep>(*this, entry->get, entry->set);
85 }
86 }
87
88 return ElementBase::getChannel(aKey, create);
89}
90
91
95
97 return field;
98}
99
100
104
108
109
111 return ignoreCavities ? 0.0 : field.getEz();
112}
113
114
116 return field.getFrequency();
117}
118
119
121 return field.getPhase();
122}
123
124
125void TravelingWaveRep::setAmplitude(double amplitude) {
126 field.setEz(amplitude);
127}
128
129
130void TravelingWaveRep::setFrequency(double frequency) {
131 field.setFrequency(frequency);
132}
133
134
135void TravelingWaveRep::setPhase(double phase) {
136 field.setPhase(phase);
137}
138
140 ignoreCavities = ignore;
141}
OscillatingField< ConstEzField > AcceleratingField
The electromagnetic field of an RF cavity.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.
TravelingWave(const std::string &name)
Constructor with given name.
virtual double getPhase() const
Get phase.
virtual void setPhase(double phi)
Set phase.
virtual StraightGeometry & getGeometry()
Get geometry.
static bool ignoreCavities
Cavities are ignored (amplitude = 0) when this switch is set.
virtual void setFrequency(double f)
Set frequency.
static void setIgnore(bool ignore=false)
Set ignore switch.
virtual ElementBase * clone() const
Return clone.
StraightGeometry geometry
The cavity's geometry.
TravelingWaveRep(const std::string &name)
Constructor with given name.
virtual double getAmplitude() const
Get amplitude.
virtual void setAmplitude(double V)
Set amplitude.
virtual double getFrequency() const
Get frequency.
AcceleratingField field
The cavity's field.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual AcceleratingField & getField()
Get field.
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition Channel.h:32
Access to a [b]double[/b] data member.