OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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"
22 #include "Attributes/Attributes.h"
24 #include "Physics/Physics.h"
25 
26 
28  OpalElement(SIZE, "VKICKER",
29  "The \"VKICKER\" element defines a closed orbit corrector "
30  "acting on the vertical plane.") {
32  ("KICK", "Vertical deflection in rad");
34  ("DESIGNENERGY", "the mean energy of the particles");
36  ("K0", "Normal dipole field in T");
37 
39 
40  setElement(new YCorrectorRep("VKICKER"));
41 }
42 
43 
44 OpalVKicker::OpalVKicker(const std::string &name, OpalVKicker *parent):
45  OpalElement(name, parent) {
47 }
48 
49 
51 {}
52 
53 
54 OpalVKicker *OpalVKicker::clone(const std::string &name) {
55  return new OpalVKicker(name, this);
56 }
57 
58 
61 
62  YCorrectorRep *corr = dynamic_cast<YCorrectorRep *>(getElement());
63 
64  double length = Attributes::getReal(itsAttr[LENGTH]);
65  double factor = OpalData::getInstance()->getP0() / Physics::c;
66  double kick = Attributes::getReal(itsAttr[KICK]);
67 
68  corr->setElementLength(length);
69  corr->setBx(kick * factor);
70  corr->setKickY(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  // Transmit "unknown" attributes.
81 }
@ 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
void setKickY(double k)
Definition: Corrector.h:137
virtual void setDesignEnergy(const double &ekin, bool changeable=true)
Definition: Corrector.cpp:126
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
virtual void setBx(double)
Set horizontal 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
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalVKicker.cpp:59
virtual OpalVKicker * clone(const std::string &name)
Make clone.
Definition: OpalVKicker.cpp:54
OpalVKicker()
Exemplar constructor.
Definition: OpalVKicker.cpp:27
virtual ~OpalVKicker()
Definition: OpalVKicker.cpp:50
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6