OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Multipole.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Multipole_HH
2 #define CLASSIC_Multipole_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Multipole.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 // Description:
12 // ------------------------------------------------------------------------
13 // Class category: AbsBeamline
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:31 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "AbsBeamline/Component.h"
23 #include "Fields/BMultipoleField.h"
24 
25 template <class T, unsigned Dim>
26 class PartBunchBase;
27 class Fieldmap;
28 
29 // Class Multipole
30 // ------------------------------------------------------------------------
32 // Class Multipole defines the abstract interface for magnetic multipoles.
33 // The order n of multipole components runs from 1 to N and is dynamically
34 // adjusted. It is connected with the number of poles by the table
35 //
36 // [tab 2 b]
37 // [ROW]1[&]dipole[/ROW]
38 // [ROW]2[&]quadrupole[/ROW]
39 // [ROW]3[&]sextupole[/ROW]
40 // [ROW]4[&]octupole[/ROW]
41 // [ROW]5[&]decapole[/ROW]
42 // [ROW]n[&]multipole with 2*n poles[/ROW]
43 // [/TAB]
44 // Units for multipole strengths are Teslas / m**(n-1).
45 
46 class Multipole: public Component {
47 
48 public:
49 
51  explicit Multipole(const std::string &name);
52 
53  Multipole();
54  Multipole(const Multipole &);
55  virtual ~Multipole();
56 
58  virtual void accept(BeamlineVisitor &) const override;
59 
60 
62  virtual BMultipoleField &getField() override = 0;
63 
65  virtual const BMultipoleField &getField() const override = 0;
66 
68  // Return the normal component of order [b]n[/b] in T/m**(n-1).
69  // If [b]n[/b] is larger than the maximum order, the return value is zero.
70  double getNormalComponent(int n) const;
71 
73  // Return the skew component of order [b]n[/b] in T/m**(n-1).
74  // If [b]n[/b] is larger than the maximum order, the return value is zero.
75  double getSkewComponent(int n) const;
76 
78  // Set the normal component of order [b]n[/b] in T/m**(n-1).
79  // If [b]n[/b] is larger than the maximum order, the component is created.
80  void setNormalComponent(int, double);
81 
83  // Set the normal component of order [b]n[/b] in T/m**(n-1).
84  // If [b]n[/b] is larger than the maximum order, the component is created.
85  void setNormalComponent(int, double, double);
86 
88  // Set the skew component of order [b]n[/b] in T/m**(n-1).
89  // If [b]n[/b] is larger than the maximum order, the component is created.
90  void setSkewComponent(int, double);
91 
93  // Set the skew component of order [b]n[/b] in T/m**(n-1).
94  // If [b]n[/b] is larger than the maximum order, the component is created.
95  void setSkewComponent(int, double, double);
96 
97  size_t getMaxNormalComponentIndex() const;
98  size_t getMaxSkewComponentIndex() const;
99 
100  //set number of slices for map tracking
101  void setNSlices(const std::size_t& nSlices);
102 
103  //set number of slices for map tracking
104  std::size_t getNSlices() const;
105 
106  bool isFocusing(unsigned int component) const;
107 
109  virtual StraightGeometry &getGeometry() override = 0;
110 
112  virtual const StraightGeometry &getGeometry() const override = 0;
113 
114  virtual void addKR(int i, double t, Vector_t &K) override;
115 
116  virtual void addKT(int i, double t, Vector_t &K) override;
117 
118  virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override;
119 
120  virtual bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
121 
122  virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
123 
124  virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override;
125 
126  virtual void finalise() override;
127 
128  virtual bool bends() const override;
129 
130  virtual ElementBase::ElementType getType() const override;
131 
132  virtual void getDimensions(double &zBegin, double &zEnd) const override;
133 
134  virtual bool isInside(const Vector_t &r) const override;
135 private:
136  void computeField(Vector_t R, Vector_t &E, Vector_t &B);
137 
138  // Not implemented.
139  void operator=(const Multipole &);
140  std::vector<double> NormalComponents;
141  std::vector<double> NormalComponentErrors;
142  std::vector<double> SkewComponents;
143  std::vector<double> SkewComponentErrors;
146  std::size_t nSlices_m;
147 };
148 
149 inline
150 void Multipole::setNormalComponent(int n, double v) {
151  setNormalComponent(n, v, 0.0);
152 }
153 
154 inline
155 void Multipole::setSkewComponent(int n, double v) {
156  setSkewComponent(n, v, 0.0);
157 }
158 
159 inline
161  return NormalComponents.size();
162 }
163 
164 inline
166  return SkewComponents.size();
167 }
168 
169 #endif // CLASSIC_Multipole_HH
virtual bool isInside(const Vector_t &r) const override
Definition: Multipole.cpp:419
double getNormalComponent(int n) const
Get normal component.
Definition: Multipole.cpp:82
void setSkewComponent(int, double)
Set skew component.
Definition: Multipole.h:155
virtual ~Multipole()
Definition: Multipole.cpp:73
virtual void addKT(int i, double t, Vector_t &K) override
Definition: Multipole.cpp:195
virtual BMultipoleField & getField() override=0
Get multipole field.
std::vector< double > NormalComponentErrors
Definition: Multipole.h:141
size_t getMaxSkewComponentIndex() const
Definition: Multipole.h:165
bool isFocusing(unsigned int component) const
Definition: Multipole.cpp:427
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Multipole.
Definition: Multipole.cpp:77
void setNormalComponent(int, double)
Set normal component.
Definition: Multipole.h:150
void operator=(const Multipole &)
virtual void getDimensions(double &zBegin, double &zEnd) const override
Definition: Multipole.cpp:408
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
Definition: Multipole.cpp:369
Interface for general multipole.
Definition: Multipole.h:46
int max_NormalComponent_m
Definition: Multipole.h:145
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
Definition: Multipole.cpp:344
Class: DataSink.
Definition: OpalData.h:29
std::vector< double > NormalComponents
Definition: Multipole.h:140
double getSkewComponent(int n) const
Get skew component.
Definition: Multipole.cpp:90
std::size_t getNSlices() const
Definition: Multipole.cpp:165
virtual bool bends() const override
Definition: Multipole.cpp:403
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Definition: Multipole.cpp:392
void computeField(Vector_t R, Vector_t &E, Vector_t &B)
Definition: Multipole.cpp:221
std::vector< double > SkewComponents
Definition: Multipole.h:142
A geometry representing a straight line.
The magnetic field of a multipole.
virtual void finalise() override
Definition: Multipole.cpp:399
const std::string name
std::vector< double > SkewComponentErrors
Definition: Multipole.h:143
virtual StraightGeometry & getGeometry() override=0
Get geometry.
Interface for a single beam element.
Definition: Component.h:51
int max_SkewComponent_m
Definition: Multipole.h:144
#define K
Definition: integrate.cpp:118
Abstract algorithm.
size_t getMaxNormalComponentIndex() const
Definition: Multipole.h:160
std::size_t nSlices_m
Definition: Multipole.h:146
void setNSlices(const std::size_t &nSlices)
Definition: Multipole.cpp:160
virtual void addKR(int i, double t, Vector_t &K) override
Definition: Multipole.cpp:171
virtual ElementBase::ElementType getType() const override
Get element type std::string.
Definition: Multipole.cpp:414