OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 #include "Physics/Units.h"
25 
27  OpalElement(SIZE, "SEPTUM",
28  "The \"SEPTUM\" element defines a Septum."),
29  owk_m(nullptr) {
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(nullptr) {
51  setElement(new SeptumRep(name));
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  double xstart = Units::mm2m * Attributes::getReal(itsAttr[XSTART]);
72  double xend = Units::mm2m * Attributes::getReal(itsAttr[XEND]);
73  double ystart = Units::mm2m * Attributes::getReal(itsAttr[YSTART]);
74  double yend = Units::mm2m * Attributes::getReal(itsAttr[YEND]);
75  double width = Units::mm2m * Attributes::getReal(itsAttr[WIDTH]);
76 
77  double length = Attributes::getReal(itsAttr[LENGTH]);
78 
79  if(itsAttr[WAKEF] && owk_m == nullptr) {
80  owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
81  owk_m->initWakefunction(*sept);
82  sept->setWake(owk_m->wf_m);
83  }
84  sept->setElementLength(length);
85  sept->setDimensions(xstart, xend, ystart, yend);
86  sept->setWidth(width);
88 
89  // Transmit "unknown" attributes.
91 }
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
WakeFunction * wf_m
Definition: OpalWake.h:56
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
virtual OpalSeptum * clone(const std::string &name)
Make clone.
Definition: OpalSeptum.cpp:61
OpalWake * owk_m
Definition: OpalSeptum.h:58
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
constexpr double mm2m
Definition: Units.h:29
OpalSeptum()
Exemplar constructor.
Definition: OpalSeptum.cpp:26
void setOutputFN(std::string fn)
Set output filename.
virtual void update()
Update the embedded CLASSIC septum.
Definition: OpalSeptum.cpp:66
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void initWakefunction(const ElementBase &element)
Definition: OpalWake.cpp:147
virtual ~OpalSeptum()
Definition: OpalSeptum.cpp:55
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:127
void setWidth(double width)
Member variable access.
Definition: Septum.cpp:61
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const