OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
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 
23 namespace {
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 
58 {}
59 
60 
62  TravelingWave(right)
63 {}
64 
65 
68 {}
69 
70 
72 {}
73 
74 
76  return new TravelingWaveRep(*this);
77 }
78 
79 
80 Channel *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 
93  return field;
94 }
95 
97  return field;
98 }
99 
100 
102  return geometry;
103 }
104 
106  return geometry;
107 }
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 
125 void TravelingWaveRep::setAmplitude(double amplitude) {
126  field.setEz(amplitude);
127 }
128 
129 
130 void TravelingWaveRep::setFrequency(double frequency) {
131  field.setFrequency(frequency);
132 }
133 
134 
135 void TravelingWaveRep::setPhase(double phase) {
136  field.setPhase(phase);
137 }
138 
139 void TravelingWaveRep::setIgnore(bool ignore) {
140  ignoreCavities = ignore;
141 }
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
virtual double getElementLength() const override
Get design length.
Definition: RFCavity.cpp:722
Interface for Traveling Wave.
Definition: TravelingWave.h:37
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.
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.
virtual ~TravelingWaveRep()
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.
virtual double getEz() const
Get component.
virtual void setEz(double)
Set component.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
virtual double getFrequency() const
Return the RF frequency in Hz.
virtual void setPhase(double phi)
Assign the RF phase in rad.
virtual double getPhase() const
Return the RF phase in rad.