OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalKicker.cpp
Go to the documentation of this file.
1 //
2 // Class OpalKicker
3 // The KICKER element.
4 // Note the sign convention: Positive kicks bend particles to positive x or
5 // y respectively.
6 //
7 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
8 // All rights reserved
9 //
10 // This file is part of OPAL.
11 //
12 // OPAL is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19 //
20 #include "Elements/OpalKicker.h"
23 #include "Attributes/Attributes.h"
24 // JMJ 18/12/2000 no longer need this, see code commented out below.
25 //#include "Utilities/Options.h"
27 #include "Physics/Physics.h"
28 
29 
31  OpalElement(SIZE, "KICKER",
32  "The \"KICKER\" element defines a closed orbit corrector "
33  "acting on both planes.") {
35  ("HKICK", "Horizontal deflection in rad");
37  ("VKICK", "Vertical deflection in rad");
39  ("DESIGNENERGY", "the mean energy of the particles");
41  ("K0", "Normal dipole field in T");
43  ("K0S", "Skew dipole field in T");
44 
46 
47  setElement(new CorrectorRep("KICKER"));
48 }
49 
50 
51 OpalKicker::OpalKicker(const std::string &name, OpalKicker *parent):
52  OpalElement(name, parent) {
54 }
55 
56 
58 {}
59 
60 
61 OpalKicker *OpalKicker::clone(const std::string &name) {
62  return new OpalKicker(name, this);
63 }
64 
65 
68 
69  CorrectorRep *corr =
70  dynamic_cast<CorrectorRep *>(getElement());
71  double length = Attributes::getReal(itsAttr[LENGTH]);
72  double factor = OpalData::getInstance()->getP0() / Physics::c;
73  double hKick = Attributes::getReal(itsAttr[HKICK]);
74  double vKick = Attributes::getReal(itsAttr[VKICK]);
75 
76  corr->setElementLength(length);
77  corr->setBy(- hKick * factor);
78  corr->setBx(vKick * factor);
79 
80  corr->setKickX(hKick);
81  corr->setKickY(vKick);
82  if(itsAttr[DESIGNENERGY]) {
83  double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]) * 1e6;
84  corr->setDesignEnergy(kineticEnergy, false);
85  }
86 
87  double Bx = 0.0, By = 0.0;
88  bool fieldSet = false;
89  if (itsAttr[K0]) {
91  fieldSet = true;
92  }
93  if (itsAttr[K0S]) {
95  fieldSet = true;
96  }
97 
98  if (fieldSet) {
99  corr->setKickField(Vector_t(Bx, By, 0));
100  }
101 
102  // Transmit "unknown" attributes.
104 }
@ 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
void setKickX(double k)
Definition: Corrector.h:132
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
virtual void setBx(double)
Set horizontal field component in Teslas.
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
@ DESIGNENERGY
Definition: OpalKicker.h:34
virtual OpalKicker * clone(const std::string &name)
Make clone.
Definition: OpalKicker.cpp:61
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalKicker.cpp:66
virtual ~OpalKicker()
Definition: OpalKicker.cpp:57
OpalKicker()
Exemplar constructor.
Definition: OpalKicker.cpp:30
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6