OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalHKicker.cpp
Go to the documentation of this file.
1 //
2 // Class OpalHKicker
3 // The HKICKER element.
4 // Note the sign convention: A positive kick bend particles to positive x.
5 //
6 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
19 #include "Elements/OpalHKicker.h"
22 #include "Attributes/Attributes.h"
24 #include "Physics/Physics.h"
25 
27  OpalElement(SIZE, "HKICKER",
28  "The \"HKICKER\" element defines a closed orbit corrector "
29  "acting on the horizontal plane.") {
31  ("KICK", "Horizontal deflection in rad");
33  ("DESIGNENERGY", "the mean energy of the particles");
35  ("K0", "Normal dipole field in T");
36 
38 
39  setElement(new XCorrectorRep("HKICKER"));
40 }
41 
42 
43 OpalHKicker::OpalHKicker(const std::string &name, OpalHKicker *parent):
44  OpalElement(name, parent) {
46 }
47 
48 
50 {}
51 
52 
53 OpalHKicker *OpalHKicker::clone(const std::string &name) {
54  return new OpalHKicker(name, this);
55 }
56 
57 
60 
61  XCorrectorRep *corr =
62  dynamic_cast<XCorrectorRep *>(getElement());
63  double length = Attributes::getReal(itsAttr[LENGTH]);
64  double factor = OpalData::getInstance()->getP0() / Physics::c;
65  double kick = Attributes::getReal(itsAttr[KICK]);
66 
67  corr->setElementLength(length);
68  corr->setBy(- kick * factor);
69 
70  corr->setKickX(kick);
71  if(itsAttr[DESIGNENERGY]) {
72  double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]) * 1e6;
73  corr->setDesignEnergy(kineticEnergy, false);
74  }
75 
76  if (itsAttr[K0]) {
78  }
79 
80  // Transmit "unknown" attributes.
82 }
@ 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
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
void setKickField(const Vector_t &k0)
Definition: Corrector.h:152
virtual void setDesignEnergy(const double &ekin, bool changeable=true)
Definition: Corrector.cpp:126
void setKickX(double k)
Definition: Corrector.h:132
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
virtual void setBy(double)
Set vertical field component in Teslas.
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
OpalHKicker()
Exemplar constructor.
Definition: OpalHKicker.cpp:26
virtual OpalHKicker * clone(const std::string &name)
Make clone.
Definition: OpalHKicker.cpp:53
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalHKicker.cpp:58
virtual ~OpalHKicker()
Definition: OpalHKicker.cpp:49
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6