OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalParallelPlate.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalParallelPlate.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalParallelPlate
10 // The class of OPAL cavities.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
22 #include "Attributes/Attributes.h"
24 #include "Physics/Physics.h"
25 
26 extern Inform *gmsg;
27 
28 // Class OpalParallelPlate
29 // ------------------------------------------------------------------------
30 
32  OpalElement(SIZE, "PARALLELPLATE",
33  "The \"PARALLELPLATE\" element defines an cavity."),
34  obgeo_m(NULL)
35 {
37  ("VOLT", " voltage in MV");
39  ("FREQ", " frequency in MHz");
41  ("LAG", "Phase lag (rad), !!!! was before in multiples of (2*pi) !!!!");
42 
44  ("GEOMETRY", "BoundaryGeometry for ParallelPlate");
45 
47  ("PLENGTH", " Gap length in Meter");
48 
49 
50  registerRealAttribute("VOLT");
51  registerRealAttribute("FREQ");
52  registerRealAttribute("LAG");
53  registerStringAttribute("GEOMETRY");
54  registerRealAttribute("PLENGTH");
55 
57 
58  setElement((new ParallelPlateRep("ParallelPlate"))->makeAlignWrapper());
59 }
60 
61 
63  OpalElement(name, parent),
64  obgeo_m(NULL)
65 {
66  setElement((new ParallelPlateRep(name))->makeAlignWrapper());
67 }
68 
69 
71 
72 }
73 
74 
76  return new OpalParallelPlate(name, this);
77 }
78 
79 
82 
83  if(flag != ERROR_FLAG) {
84  const ParallelPlateRep *pplate =
85  dynamic_cast<const ParallelPlateRep *>(base.removeWrappers());
86  attributeRegistry["VOLT"]->setReal(pplate->getAmplitude());
87  attributeRegistry["FREQ"]->setReal(pplate->getFrequency());
88  attributeRegistry["LAG"]->setReal(pplate->getPhase());
89  attributeRegistry["PLENGTH"]->setReal(pplate->getElementLength());
90  }
91 }
92 
93 
95  using Physics::two_pi;
96 
98 
99  ParallelPlateRep *pplate =
100  dynamic_cast<ParallelPlateRep *>(getElement()->removeWrappers());
101 
102  double vPeak = Attributes::getReal(itsAttr[VOLT]);
103  // double phase = two_pi * Attributes::getReal(itsAttr[LAG]);
104  double phase = Attributes::getReal(itsAttr[LAG]);
105  double freq = (1.0e6 * two_pi) * Attributes::getReal(itsAttr[FREQ]);
106  double length = Attributes::getReal(itsAttr[PLENGTH]);
107 
108  if(itsAttr[GEOMETRY] && obgeo_m == NULL) {
110  if(obgeo_m) {
111  //obgeo_m->initialize();
112 
113  pplate->setBoundaryGeometry(obgeo_m);
114  }
115  }
116 
117  pplate->setAmplitude(1.0e6 * vPeak);
118  pplate->setFrequency(freq);
119  pplate->setPhase(phase);
120 
121  pplate->setElementLength(length);
122 
123  // Transmit "unknown" attributes.
125 }
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
void setPhase(double phase)
BoundaryGeometry * obgeo_m
void setFrequency(double freq)
constexpr double two_pi
The value of .
Definition: Physics.h:34
virtual ElementBase * removeWrappers()
Return the design element.
Inform * gmsg
Definition: Main.cpp:21
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
void setAmplitude(double vPeak)
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
virtual void setBoundaryGeometry(BoundaryGeometry *geo)
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
double getPhase() const
static BoundaryGeometry * find(const std::string &name)
Base class for all beam line elements.
Definition: OpalElement.h:41
OpalParallelPlate()
Exemplar constructor.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
The ParallelPlate element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
double getAmplitude() const
virtual void update()
Update the embedded CLASSIC cavity.
const std::string name
Representation for a RF cavity.
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Definition: Inform.h:41
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
double getFrequency() const
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
virtual OpalParallelPlate * clone(const std::string &name)
Make clone.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307