OPAL (Object Oriented Parallel Accelerator Library) 2022.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//
20
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
45OpalHKicker::OpalHKicker(const std::string &name, OpalHKicker *parent):
46 OpalElement(name, parent) {
48}
49
50
52{}
53
54
55OpalHKicker *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);
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}
@ 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
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:418
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:28
virtual OpalHKicker * clone(const std::string &name)
Make clone.
Definition: OpalHKicker.cpp:55
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalHKicker.cpp:60
virtual ~OpalHKicker()
Definition: OpalHKicker.cpp:51
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6