OPAL (Object Oriented Parallel Accelerator Library) 2022.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//
20
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
46OpalVKicker::OpalVKicker(const std::string &name, OpalVKicker *parent):
47 OpalElement(name, parent) {
49}
50
51
53{}
54
55
56OpalVKicker *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);
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}
@ 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:45
constexpr double MeV2eV
Definition: Units.h:74
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:570
static OpalData * getInstance()
Definition: OpalData.cpp:196
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:418
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:61
virtual OpalVKicker * clone(const std::string &name)
Make clone.
Definition: OpalVKicker.cpp:56
OpalVKicker()
Exemplar constructor.
Definition: OpalVKicker.cpp:29
virtual ~OpalVKicker()
Definition: OpalVKicker.cpp:52
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6