OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SingleMultipole.h
Go to the documentation of this file.
1//
2// Class SingleMultipole
3// Representation for single multipoles.
4// Template for representation of single multipoles.
5// Represents all the basic (design) multipole magnets found in an
6// accelerator. A single multipole has only one multipole component,
7// the pole-number of which cannot be changed (once a quadrupole, always
8// a quadrupole). This differs from a MultipoleRep object which can
9// have an arbitrary number of multipole components.
10// [P]
11// This template class can be used to instantiate classes like:
12// [UL]
13// [LI]Quadrupole (order = 2),
14// [LI]Sextupole (order = 3),
15// [LI]Octupole (order = 4),
16// [LI]SkewQuadrupole (order = -2),
17// [LI]SkewSextupole (order = -3),
18// [LI]SkewOctupole (order = -4).
19// [/UL]
20// The order and the skew flag are encoded in the template parameter.
21// A positive [b]order[/b] implies a normal multipole,
22// A negative [b]order[/b] implies a skew multipole.
23//
24// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
25// All rights reserved
26//
27// This file is part of OPAL.
28//
29// OPAL is free software: you can redistribute it and/or modify
30// it under the terms of the GNU General Public License as published by
31// the Free Software Foundation, either version 3 of the License, or
32// (at your option) any later version.
33//
34// You should have received a copy of the GNU General Public License
35// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
36//
37#ifndef CLASSIC_SingleMultipole_HH
38#define CLASSIC_SingleMultipole_HH
39
44
45
46template <int order>
48
49public:
50
52 explicit SingleMultipole(const std::string &name);
53
56 virtual ~SingleMultipole();
57
59 // Version for non-constant object.
60 virtual BMultipoleField &getField() ;
61
63 // Version for constant object.
64 virtual const BMultipoleField &getField() const;
65
67 // Version for non-constant object.
69
71 // Version for constant object.
72 virtual const StraightGeometry &getGeometry() const;
73
75 // Return the single multipole component in T/m**(n-1).
76 virtual double getComponent() const;
77
79 // Assign the single multipole component in T/m**(n-1).
80 virtual void setComponent(double Bn);
81
83 // Return an identical deep copy of the element.
84 virtual ElementBase *clone() const;
85
87 // This method constructs a Channel permitting read/write access to
88 // the attribute [b]aKey[/b] and returns it.
89 // If the attribute does not exist, it returns nullptr.
90 virtual Channel *getChannel(const std::string &aKey, bool = false);
91
92private:
93
94 // Not implemented.
96
97 // A temporary for magnetic field conversion.
99
102
105
106 // The type string returned.
107 static const std::string type;
108
109 // Attribute access table.
110 struct Entry {
111 const char *name;
112 double(SingleMultipole<order>::*get)() const;
113 void (SingleMultipole<order>::*set)(double);
114 };
115
116 // The table of attributes.
117 static const Entry entries[];
118};
119
120
121// Implementation of template class SingleMultipole
122// ------------------------------------------------------------------------
123
124template <int order>
126 Multipole(),
127 geometry(),
128 field()
129{}
130
131
132template <int order>
134(const SingleMultipole &multipole):
135 Multipole(multipole),
136 geometry(multipole.geometry),
137 field(multipole.field)
138{}
139
140
141template <int order>
144 geometry(),
145 field()
146{}
147
148
149template <int order>
151{}
152
153
154template <int order> inline
156 return field.getComponent();
157}
158
159template <int order> inline
161 field.setComponent(value);
162}
163
164
165template <int order>
167 tempField = BMultipoleField(field);
168 return tempField;
169}
170
171
172template <int order>
174 tempField = BMultipoleField(field);
175 return tempField;
176}
177
178
179template <int order> inline
181 return geometry;
182}
183
184template <int order> inline
186 return geometry;
187}
188
189
190template <int order> inline
192 return new SingleMultipole<order>(*this);
193}
194
195
196template <int order> inline
197Channel *SingleMultipole<order>::getChannel(const std::string &aKey, bool) {
198 for(const Entry *entry = entries; entry->name != 0; ++entry) {
199 if(aKey == entry->name) {
201 (*this, entry->get, entry->set);
202 }
203 }
204
205 return ElementBase::getChannel(aKey);
206}
207
208#endif // __SingleMultipole_HH
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
Interface for general multipole.
Definition: Multipole.h:47
virtual ~SingleMultipole()
static const std::string type
virtual double getComponent() const
Get component.
static const Entry entries[]
virtual void setComponent(double Bn)
Set component.
BMultipoleField tempField
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
StraightGeometry geometry
Multipole geometry.
BSingleMultipoleField< order > field
The single multipole component.
virtual BMultipoleField & getField()
Get field.
virtual ElementBase * clone() const
Return clone.
virtual StraightGeometry & getGeometry()
Get geometry.
void operator=(const SingleMultipole &)
void(SingleMultipole< order >::* set)(double)
double(SingleMultipole< order >::* get)() const
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
The magnetic field of a multipole.
Representation for a single magnetic multipole field.