OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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//
22#include "Physics/Physics.h"
23
25 : OpalElement(SIZE, "SOLENOID", "The \"SOLENOID\" element defines a Solenoid.") {
26 itsAttr[KS] = Attributes::makeReal("KS", "Normalised solenoid strength in m**(-1)");
27 itsAttr[DKS] = Attributes::makeReal("DKS", "Normalised solenoid strength error in m**(-1)");
28 itsAttr[FMAPFN] = Attributes::makeString("FMAPFN", "Solenoid field map filename ");
29 itsAttr[FAST] = Attributes::makeBool("FAST", "Faster but less accurate", true);
30
32
33 setElement(new SolenoidRep("SOLENOID"));
34}
35
36OpalSolenoid::OpalSolenoid(const std::string& name, OpalSolenoid* parent)
37 : OpalElement(name, parent) {
38 setElement(new SolenoidRep(name));
39}
40
42
43OpalSolenoid* OpalSolenoid::clone(const std::string& name) { return new OpalSolenoid(name, this); }
44
47
48 SolenoidRep* sol = dynamic_cast<SolenoidRep*>(getElement());
49 double length = Attributes::getReal(itsAttr[LENGTH]);
51 bool fast = Attributes::getBool(itsAttr[FAST]);
52
53 sol->setElementLength(length);
55 sol->setFast(fast);
56 sol->setBz(Bz);
59
60 // Transmit "unknown" attributes.
62}
@ SIZE
Definition IndexMap.cpp:179
virtual void setElementLength(double length)
Set design length.
ElementBase * getElement() const
Return the embedded OPALX element.
Definition Element.h:119
void setElement(ElementBase *)
Assign new OPALX element.
Definition Element.h:123
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
double getP0() const
Return value of global reference momentum.
Definition OpalData.cpp:479
static OpalData * getInstance()
Definition OpalData.cpp:193
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPALX) attributes to OPALX.
virtual void update()
Update the embedded OPALX element.
void registerOwnership() const
virtual ~OpalSolenoid()
virtual OpalSolenoid * clone(const std::string &name)
Make clone.
OpalSolenoid()
Exemplar constructor.
virtual void update()
Update the embedded OPALX solenoid.
virtual void setBz(double Bz)
Set field.
void setFast(bool fast)
Set the fast flag.
Definition Solenoid.cpp:216
void setDKS(double ks)
Set the strength scaling error dks.
Definition Solenoid.cpp:159
void setKS(double ks)
Set the strength scaling factor ks.
Definition Solenoid.cpp:156
void setFieldMapFN(std::string fn)
Assign the field filename.
Definition Solenoid.cpp:213
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
constexpr double c
The velocity of light in m/s.
Definition Physics.h:60