OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 
67  TravelingWave(name)
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 }
virtual double getFrequency() const
Get frequency.
A geometry representing a straight line.
virtual void setPhase(double phi)
Set phase.
virtual void setAmplitude(double V)
Set amplitude.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual double getPhase() const
Return the RF phase in rad.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
static bool ignoreCavities
Cavities are ignored (amplitude = 0) when this switch is set.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE:162
virtual double getEz() const
Get component.
virtual void setEz(double)
Set component.
set(_SRCS Action.cpp Attribute.cpp AttributeBase.cpp AttributeHandler.cpp BeamSequence.cpp Definition.cpp Directory.cpp Element.cpp Invalidator.cpp OpalData.cpp Object.cpp ObjectFunction.cpp PlaceRep.cpp RangeRep.cpp Table.cpp TableRowRep.cpp ValueDefinition.cpp) include_directories($
Definition: CMakeLists.txt:1
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
virtual double getAmplitude() const
Get amplitude.
const std::string name
virtual StraightGeometry & getGeometry()
Get geometry.
virtual double getElementLength() const override
Get design length.
Definition: RFCavity.cpp:732
virtual ~TravelingWaveRep()
virtual double getFrequency() const
Return the RF frequency in Hz.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual ElementBase * clone() const
Return clone.
virtual void setFrequency(double f)
Set frequency.
static void setIgnore(bool ignore=false)
Set ignore switch.
StraightGeometry geometry
The cavity&#39;s geometry.
AcceleratingField field
The cavity&#39;s field.
virtual void setPhase(double phi)
Assign the RF phase in rad.
virtual double getPhase() const
Get phase.
virtual AcceleratingField & getField()
Get field.