OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalSolenoid.cpp
Go to the documentation of this file.
1 //
2 // Class OpalSolenoid
3 // The SOLENOID 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/OpalSolenoid.h"
20 #include "Attributes/Attributes.h"
22 #include "Physics/Physics.h"
23 
24 
26  OpalElement(SIZE, "SOLENOID",
27  "The \"SOLENOID\" element defines a Solenoid.") {
29  ("KS", "Normalised solenoid strength in m**(-1)");
31  ("DKS", "Normalised solenoid strength error in m**(-1)");
33  ("FMAPFN", "Solenoid field map filename ");
35  ("FAST", "Faster but less accurate", true);
36 
38 
39  setElement(new SolenoidRep("SOLENOID"));
40 }
41 
42 
43 OpalSolenoid::OpalSolenoid(const std::string &name, OpalSolenoid *parent):
44  OpalElement(name, parent) {
46 }
47 
48 
50 {}
51 
52 
53 OpalSolenoid *OpalSolenoid::clone(const std::string &name) {
54  return new OpalSolenoid(name, this);
55 }
56 
57 
60 
61  SolenoidRep *sol =
62  dynamic_cast<SolenoidRep *>(getElement());
63  double length = Attributes::getReal(itsAttr[LENGTH]);
65  bool fast = Attributes::getBool(itsAttr[FAST]);
66 
67  sol->setElementLength(length);
69  sol->setFast(fast);
70  sol->setBz(Bz);
73 
74  // Transmit "unknown" attributes.
76 }
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
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
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:51
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
double getP0() const
Return value of global reference momentum.
Definition: OpalData.cpp:569
static OpalData * getInstance()
Definition: OpalData.cpp:195
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
void setFast(bool fast)
Definition: Solenoid.cpp:75
void setDKS(double ks)
Definition: Solenoid.cpp:161
void setKS(double ks)
Definition: Solenoid.cpp:157
void setFieldMapFN(std::string fn)
Definition: Solenoid.cpp:71
virtual void setBz(double Bz)
Set field.
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 ~OpalSolenoid()
virtual OpalSolenoid * clone(const std::string &name)
Make clone.
OpalSolenoid()
Exemplar constructor.
virtual void update()
Update the embedded CLASSIC solenoid.