OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
RFCavityRep.cpp
Go to the documentation of this file.
1 //
2 // Class RFCavityRep
3 // Representation for a RF cavity.
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 
21 
22 bool RFCavityRep::ignoreCavities = false;
23 
24 namespace {
25  struct Entry {
26  const char *name;
27  double(RFCavityRep::*get)() const;
28  void (RFCavityRep::*set)(double);
29  };
30 
31  static const Entry entries[] = {
32  {
33  "L",
36  },
37  {
38  "AMPLITUDE",
41  },
42  {
43  "FREQUENCY",
46  },
47  {
48  "PHASE",
51  },
52  { 0, 0, 0 }
53  };
54 }
55 
56 
58  RFCavity()
59 {}
60 
61 
63  RFCavity(right),
64  geometry(right.geometry)
65 {}
66 
67 
68 RFCavityRep::RFCavityRep(const std::string &name):
69  RFCavity(name)
70 {}
71 
72 
74 {}
75 
76 
78  return new RFCavityRep(*this);
79 }
80 
81 
82 Channel *RFCavityRep::getChannel(const std::string &aKey, bool create) {
83  for(const Entry *entry = entries; entry->name != 0; ++entry) {
84  if(aKey == entry->name) {
85  return new IndirectChannel<RFCavityRep>(*this, entry->get, entry->set);
86  }
87  }
88 
89  return ElementBase::getChannel(aKey, create);
90 }
91 
92 
94  return field;
95 }
96 
98  return field;
99 }
100 
101 
103  return geometry;
104 }
105 
107  return geometry;
108 }
109 
110 
112  return ignoreCavities ? 0.0 : field.getEz();
113 }
114 
115 
117  return field.getFrequency();
118 }
119 
120 
121 double RFCavityRep::getPhase() const {
122  return field.getPhase();
123 }
124 
125 
126 void RFCavityRep::setAmplitude(double amplitude) {
127  field.setEz(amplitude);
128 }
129 
130 
131 void RFCavityRep::setFrequency(double frequency) {
132  field.setFrequency(frequency);
133 }
134 
135 
136 void RFCavityRep::setPhase(double phase) {
137  field.setPhase(phase);
138 }
139 
140 void RFCavityRep::setIgnore(bool ignore) {
141  ignoreCavities = ignore;
142 }
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: RFCavityRep.cpp:82
virtual StraightGeometry & getGeometry()
Get geometry.
A geometry representing a straight line.
virtual void setPhase(double phi)
Set phase.
AcceleratingField field
The cavity&#39;s field.
Definition: RFCavityRep.h:102
virtual void setAmplitude(double V)
Set amplitude.
static bool ignoreCavities
Cavities are ignored (amplitude = 0) when this switch is set.
Definition: RFCavityRep.h:105
virtual ElementBase * clone() const
Return clone.
Definition: RFCavityRep.cpp:77
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.
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 double getAmplitude() const
Get amplitude.
virtual ~RFCavityRep()
Definition: RFCavityRep.cpp:73
static void setIgnore(bool ignore=false)
Set ignore switch.
virtual double getFrequency() const
Get frequency.
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 void setFrequency(double f)
Set frequency.
const std::string name
virtual double getElementLength() const override
Get design length.
Definition: RFCavity.cpp:732
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
StraightGeometry geometry
The cavity&#39;s geometry.
Definition: RFCavityRep.h:99
virtual void setPhase(double phi)
Assign the RF phase in rad.
virtual double getPhase() const
Get phase.
virtual AcceleratingField & getField()
Get field.
Definition: RFCavityRep.cpp:93