OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalSeptum.cpp
Go to the documentation of this file.
1 //
2 // Class OpalSeptum
3 // The Septum element.
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 //
18 #include "Elements/OpalSeptum.h"
20 #include "Attributes/Attributes.h"
21 #include "BeamlineCore/SeptumRep.h"
22 #include "Structure/OpalWake.h"
23 #include "Physics/Physics.h"
24 
25 
27  OpalElement(SIZE, "SEPTUM",
28  "The \"SEPTUM\" element defines a Septum."),
29  owk_m(NULL) {
30 
32  ("XSTART", " Start of x coordinate");
34  ("XEND", " End of x coordinate");
36  ("YSTART", "Start of y coordinate");
38  ("YEND", "End of y coordinate");
40  ("WIDTH", "Width of the septum");
41 
43 
44  setElement(new SeptumRep("SEPTUM"));
45 }
46 
47 
48 OpalSeptum::OpalSeptum(const std::string &name, OpalSeptum *parent):
49  OpalElement(name, parent),
50  owk_m(NULL) {
52 }
53 
54 
56  if(owk_m)
57  delete owk_m;
58 }
59 
60 
61 OpalSeptum *OpalSeptum::clone(const std::string &name) {
62  return new OpalSeptum(name, this);
63 }
64 
65 
68 
69  SeptumRep *sept = dynamic_cast<SeptumRep *>(getElement());
70 
71  const double mm2m = 0.001;
72  double xstart = mm2m * Attributes::getReal(itsAttr[XSTART]);
73  double xend = mm2m * Attributes::getReal(itsAttr[XEND]);
74  double ystart = mm2m * Attributes::getReal(itsAttr[YSTART]);
75  double yend = mm2m * Attributes::getReal(itsAttr[YEND]);
76  double width = mm2m * Attributes::getReal(itsAttr[WIDTH]);
77 
78  double length = Attributes::getReal(itsAttr[LENGTH]);
79 
80  if(itsAttr[WAKEF] && owk_m == NULL) {
81  owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
82  owk_m->initWakefunction(*sept);
83  sept->setWake(owk_m->wf_m);
84  }
85  sept->setElementLength(length);
86  sept->setDimensions(xstart, xend, ystart, yend);
87  sept->setWidth(width);
89 
90  // Transmit "unknown" attributes.
92 }
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:281
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
void setOutputFN(std::string fn)
Set output filename.
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
void setWidth(double width)
Member variable access.
Definition: Septum.cpp:61
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
virtual OpalSeptum * clone(const std::string &name)
Make clone.
Definition: OpalSeptum.cpp:61
OpalWake * owk_m
Definition: OpalSeptum.h:58
virtual ~OpalSeptum()
Definition: OpalSeptum.cpp:55
OpalSeptum()
Exemplar constructor.
Definition: OpalSeptum.cpp:26
virtual void update()
Update the embedded CLASSIC septum.
Definition: OpalSeptum.cpp:66
WakeFunction * wf_m
Definition: OpalWake.h:57
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:125
void initWakefunction(const ElementBase &element)
Definition: OpalWake.cpp:146