OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Multipole.h
Go to the documentation of this file.
1//
2// Class Multipole
3// The MULTIPOLE element defines a thick multipole.
4//
5// Copyright (c) 2012-2021, 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//
18
19#ifndef CLASSIC_Multipole_HH
20#define CLASSIC_Multipole_HH
21
25
26class Fieldmap;
27
28// Class Multipole
29// ------------------------------------------------------------------------
31// Class Multipole defines the abstract interface for magnetic multipoles.
32// The order n of multipole components runs from 1 to N and is dynamically
33// adjusted. It is connected with the number of poles by the table
34//
35// [tab 2 b]
36// [ROW]1[&]dipole[/ROW]
37// [ROW]2[&]quadrupole[/ROW]
38// [ROW]3[&]sextupole[/ROW]
39// [ROW]4[&]octupole[/ROW]
40// [ROW]5[&]decapole[/ROW]
41// [ROW]n[&]multipole with 2*n poles[/ROW]
42// [/TAB]
43// Units for multipole strengths are Teslas / m**(n-1).
44
45class Multipole : public Component {
46public:
48 explicit Multipole(const std::string& name);
49
50 Multipole();
51 Multipole(const Multipole&);
52 virtual ~Multipole();
53
55 virtual void accept(BeamlineVisitor&) const override;
56
58 virtual BMultipoleField& getField() override = 0;
59
61 virtual const BMultipoleField& getField() const override = 0;
62
64 // Return the normal component of order [b]n[/b] in T/m**(n-1).
65 // If [b]n[/b] is larger than the maximum order, the return value is zero.
66 double getNormalComponent(int n) const;
67
69 // Return the skew component of order [b]n[/b] in T/m**(n-1).
70 // If [b]n[/b] is larger than the maximum order, the return value is zero.
71 double getSkewComponent(int n) const;
72
74 // Set the normal component of order [b]n[/b] in T/m**(n-1).
75 // If [b]n[/b] is larger than the maximum order, the component is created.
76 void setNormalComponent(int, double);
77
79 // Set the normal component of order [b]n[/b] in T/m**(n-1).
80 // If [b]n[/b] is larger than the maximum order, the component is created.
81 void setNormalComponent(int, double, double);
82
84 // Set the skew component of order [b]n[/b] in T/m**(n-1).
85 // If [b]n[/b] is larger than the maximum order, the component is created.
86 void setSkewComponent(int, double);
87
89 // Set the skew component of order [b]n[/b] in T/m**(n-1).
90 // If [b]n[/b] is larger than the maximum order, the component is created.
91 void setSkewComponent(int, double, double);
92
93 size_t getMaxNormalComponentIndex() const;
94 size_t getMaxSkewComponentIndex() const;
95
96 // set number of slices for map tracking
97 void setNSlices(const std::size_t& nSlices);
98
99 // set number of slices for map tracking
100 std::size_t getNSlices() const;
101
102 bool isFocusing(unsigned int component) const;
103
105 virtual StraightGeometry& getGeometry() override = 0;
106
108 virtual const StraightGeometry& getGeometry() const override = 0;
109
110 virtual bool apply(
111 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B) override;
112
113 virtual bool apply(
114 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
116
117 virtual bool applyToReferenceParticle(
118 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
120
121 virtual void initialise(PartBunch_t* bunch, double& startField, double& endField) override;
122
123 virtual void finalise() override;
124
125 virtual bool bends() const override;
126
127 virtual ElementType getType() const override;
128
129 virtual void getDimensions(double& zBegin, double& zEnd) const override;
130
131 virtual bool isInside(const Vector_t<double, 3>& r) const override;
132
133private:
135
136 // Not implemented.
137 void operator=(const Multipole&);
138 std::vector<double> NormalComponents;
139 std::vector<double> NormalComponentErrors;
140 std::vector<double> SkewComponents;
141 std::vector<double> SkewComponentErrors;
144 std::size_t nSlices_m;
145};
146
147inline void Multipole::setNormalComponent(int n, double v) {
148 setNormalComponent(n, v, 0.0);
149}
150
151inline void Multipole::setSkewComponent(int n, double v) {
152 setSkewComponent(n, v, 0.0);
153}
154
156 return NormalComponents.size();
157}
158
160 return SkewComponents.size();
161}
162
163#endif // CLASSIC_Multipole_HH
ElementType
Definition ElementBase.h:88
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
std::vector< double > SkewComponents
Definition Multipole.h:140
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Multipole.
Definition Multipole.cpp:70
int max_NormalComponent_m
Definition Multipole.h:143
size_t getMaxSkewComponentIndex() const
Definition Multipole.h:159
size_t getMaxNormalComponentIndex() const
Definition Multipole.h:155
virtual const StraightGeometry & getGeometry() const override=0
Get geometry.
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual const BMultipoleField & getField() const override=0
Get multipole field. Version for const object.
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
virtual bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
std::vector< double > SkewComponentErrors
Definition Multipole.h:141
virtual bool applyToReferenceParticle(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
virtual StraightGeometry & getGeometry() override=0
Get geometry.
virtual void finalise() override
void setNSlices(const std::size_t &nSlices)
virtual bool bends() const override
bool isFocusing(unsigned int component) const
virtual ElementType getType() const override
Get element type std::string.
virtual bool isInside(const Vector_t< double, 3 > &r) const override
std::vector< double > NormalComponents
Definition Multipole.h:138
void computeField(Vector_t< double, 3 > R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
void setNormalComponent(int, double)
Set normal component.
Definition Multipole.h:147
Multipole(const std::string &name)
Constructor with given name.
Definition Multipole.cpp:56
double getSkewComponent(int n) const
Get skew component.
Definition Multipole.cpp:81
int max_SkewComponent_m
Definition Multipole.h:142
std::size_t getNSlices() const
virtual ~Multipole()
Definition Multipole.cpp:67
void setSkewComponent(int, double)
Set skew component.
Definition Multipole.h:151
std::vector< double > NormalComponentErrors
Definition Multipole.h:139
double getNormalComponent(int n) const
Get normal component.
Definition Multipole.cpp:74
std::size_t nSlices_m
Definition Multipole.h:144
virtual BMultipoleField & getField() override=0
Get multipole field.
void operator=(const Multipole &)
A geometry representing a straight line.
The magnetic field of a multipole.