OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalQuadrupole.cpp
Go to the documentation of this file.
1//
2// Class OpalQuadrupole
3// The QUADRUPOLE element.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
23#include "Physics/Physics.h"
24#include "Utilities/Options.h"
26
27#include <cmath>
28#include <iostream>
29#include <sstream>
30
31
33 OpalElement(SIZE, "QUADRUPOLE",
34 "The \"QUADRUPOLE\" element defines a Quadrupole."),
35 parmatint_m(nullptr) {
37 ("K1", "Normalised upright quadrupole coefficient in m^(-2)");
39 ("DK1", "Normalised upright quadrupole coefficient error in m^(-2)");
41 ("K1S", "Normalised skew quadrupole coefficient in m^(-2)");
43 ("DK1S", "Normalised skew quadrupole coefficient error in m^(-2)");
45 ("NSLICES", "The number of slices/ steps for this element in Map Tracking", 1);
46
48
49 setElement((new MultipoleRep("QUADRUPOLE")));
50}
51
52
54 OpalElement(name, parent),
55 parmatint_m(nullptr) {
57}
58
59
61 delete parmatint_m;
62}
63
64
66 return new OpalQuadrupole(name, this);
67}
68
69
70void OpalQuadrupole::print(std::ostream& os) const {
72}
73
74
77
78 MultipoleRep* quad =
79 dynamic_cast<MultipoleRep*>(getElement());
80
82 double factor = OpalData::getInstance()->getP0() / Physics::c;
83
84 BMultipoleField field;
85 field.setNormalComponent(2, factor * Attributes::getReal(itsAttr[K1])); // this is for the maps
86 field.setSkewComponent(2, factor * Attributes::getReal(itsAttr[K1S])); // this is for the maps
87 quad->setField(field);
91
93 const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
95 parmatint_m = orig->clone(matterDescriptor);
98 }
99
100 // Transmit "unknown" attributes.
102}
@ 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
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
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
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
void setNSlices(const std::size_t &nSlices)
Definition: Multipole.cpp:142
void setNormalComponent(int, double)
Set normal component.
Definition: Multipole.h:147
void setSkewComponent(int, double)
Set skew component.
Definition: Multipole.h:152
virtual void setField(const BMultipoleField &field)
Set mulitpole field.
The magnetic field of a multipole.
void setNormalComponent(int n, double Bn)
Set component.
void setSkewComponent(int n, double Bn)
Set component.
@ PARTICLEMATTERINTERACTION
Definition: OpalElement.h:39
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void print(std::ostream &) const
Print the object.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
virtual void print(std::ostream &) const
Print the quadrupole.
virtual ~OpalQuadrupole()
virtual OpalQuadrupole * clone(const std::string &name)
Make clone.
ParticleMatterInteraction * parmatint_m
OpalQuadrupole()
Exemplar constructor.
virtual void update()
Update the embedded CLASSIC multipole.
virtual ParticleMatterInteraction * clone(const std::string &name)
Make clone.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
void initParticleMatterInteractionHandler(ElementBase &element)