OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
OpalVKicker.cpp
Go to the documentation of this file.
1 //
2 // Class OpalVKicker
3 // The VKICKER element.
4 // Note the sign convention: A positive kick bend particles to positive y.
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/OpalVKicker.h"
20 
23 #include "Attributes/Attributes.h"
25 #include "Physics/Physics.h"
26 #include "Physics/Units.h"
27 
28 
30  OpalElement(SIZE, "VKICKER",
31  "The \"VKICKER\" element defines a closed orbit corrector "
32  "acting on the vertical plane.") {
34  ("KICK", "Vertical deflection in rad");
36  ("DESIGNENERGY", "the mean energy of the particles");
38  ("K0", "Normal dipole field in T");
39 
41 
42  setElement(new YCorrectorRep("VKICKER"));
43 }
44 
45 
46 OpalVKicker::OpalVKicker(const std::string &name, OpalVKicker *parent):
47  OpalElement(name, parent) {
48  setElement(new YCorrectorRep(name));
49 }
50 
51 
53 {}
54 
55 
56 OpalVKicker *OpalVKicker::clone(const std::string &name) {
57  return new OpalVKicker(name, this);
58 }
59 
60 
63 
64  YCorrectorRep *corr = dynamic_cast<YCorrectorRep *>(getElement());
65 
66  double length = Attributes::getReal(itsAttr[LENGTH]);
67  double factor = OpalData::getInstance()->getP0() / Physics::c;
68  double kick = Attributes::getReal(itsAttr[KICK]);
69 
70  corr->setElementLength(length);
71  corr->setBx(kick * factor);
72  corr->setKickY(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  // Transmit "unknown" attributes.
83 }
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
OpalVKicker()
Exemplar constructor.
Definition: OpalVKicker.cpp:29
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
virtual void setDesignEnergy(const double &ekin, bool changeable=true)
Definition: Corrector.cpp:126
virtual void setBx(double)
Set horizontal field component in Teslas.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
virtual ~OpalVKicker()
Definition: OpalVKicker.cpp:52
void setKickY(double k)
Definition: Corrector.h:137
void setKickField(const Vector_t &k0)
Definition: Corrector.h:152
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
virtual OpalVKicker * clone(const std::string &name)
Make clone.
Definition: OpalVKicker.cpp:56
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 void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalVKicker.cpp:61
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
constexpr double MeV2eV
Definition: Units.h:74
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const