OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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"
20 
23 #include "Attributes/Attributes.h"
25 #include "Physics/Physics.h"
26 #include "Physics/Units.h"
27 
29  OpalElement(SIZE, "HKICKER",
30  "The \"HKICKER\" element defines a closed orbit corrector "
31  "acting on the horizontal plane.") {
33  ("KICK", "Horizontal deflection in rad");
35  ("DESIGNENERGY", "the mean energy of the particles");
37  ("K0", "Normal dipole field in T");
38 
40 
41  setElement(new XCorrectorRep("HKICKER"));
42 }
43 
44 
45 OpalHKicker::OpalHKicker(const std::string &name, OpalHKicker *parent):
46  OpalElement(name, parent) {
47  setElement(new XCorrectorRep(name));
48 }
49 
50 
52 {}
53 
54 
55 OpalHKicker *OpalHKicker::clone(const std::string &name) {
56  return new OpalHKicker(name, this);
57 }
58 
59 
62 
63  XCorrectorRep *corr =
64  dynamic_cast<XCorrectorRep *>(getElement());
65  double length = Attributes::getReal(itsAttr[LENGTH]);
66  double factor = OpalData::getInstance()->getP0() / Physics::c;
67  double kick = Attributes::getReal(itsAttr[KICK]);
68 
69  corr->setElementLength(length);
70  corr->setBy(- kick * factor);
71 
72  corr->setKickX(kick);
73  if(itsAttr[DESIGNENERGY]) {
74  double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]) * Units::MeV2eV;
75  corr->setDesignEnergy(kineticEnergy, false);
76  }
77 
78  if (itsAttr[K0]) {
80  }
81 
82  // Transmit "unknown" attributes.
84 }
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
static OpalData * getInstance()
Definition: OpalData.cpp:196
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
virtual void setDesignEnergy(const double &ekin, bool changeable=true)
Definition: Corrector.cpp:126
virtual ~OpalHKicker()
Definition: OpalHKicker.cpp:51
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
virtual void setBy(double)
Set vertical field component in Teslas.
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalHKicker.cpp:60
void setKickX(double k)
Definition: Corrector.h:132
void setKickField(const Vector_t &k0)
Definition: Corrector.h:152
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
double getP0() const
Return value of global reference momentum.
Definition: OpalData.cpp:575
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 OpalHKicker * clone(const std::string &name)
Make clone.
Definition: OpalHKicker.cpp:55
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.
constexpr double MeV2eV
Definition: Units.h:74
OpalHKicker()
Exemplar constructor.
Definition: OpalHKicker.cpp:28
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const