OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SBendRep.cpp
Go to the documentation of this file.
1//
2// Class SBendRep
3// Representation for a sector bend magnet.
4// A sector bend magnet has a planar arc geometry about which its
5// multipole components are specified.
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//
23#include <cctype>
24
25namespace {
26 struct Entry {
27 const char *name;
28 double(SBendRep::*get)() const;
29 void (SBendRep::*set)(double);
30 };
31
32 static const Entry entries[] = {
33 {
34 "L",
37 },
38 {
39 "BY",
42 },
43 {
44 "E1",
47 },
48 {
49 "E2",
52 },
53 {
54 "H1",
57 },
58 {
59 "H2",
62 },
63 { 0, 0, 0 }
64 };
65}
66
67
69 SBend(),
70 geometry(0.0, 0.0),
71 field() {
72 rEntry = rExit = hEntry = hExit = 0.0;
73}
74
75
77 SBend(rhs),
78 geometry(rhs.geometry),
79 field(rhs.field) {
80 rEntry = rhs.rEntry;
81 rExit = rhs.hExit;
82 hEntry = rhs.rEntry;
83 hExit = rhs.hExit;
84}
85
86
87SBendRep::SBendRep(const std::string &name):
88 SBend(name),
89 geometry(0.0, 0.0),
90 field() {
91 rEntry = rExit = hEntry = hExit = 0.0;
92}
93
94
96{}
97
98
100 return new SBendRep(*this);
101}
102
103
104Channel *SBendRep::getChannel(const std::string &aKey, bool create) {
105 if(aKey[0] == 'a' || aKey[0] == 'b') {
106 int n = 0;
107
108 for(std::string::size_type k = 1; k < aKey.length(); k++) {
109 if(isdigit(aKey[k])) {
110 n = 10 * n + aKey[k] - '0';
111 } else {
112 return 0;
113 }
114 }
115
116 if(aKey[0] == 'b') {
117 return new IndexedChannel<SBendRep>
120 } else {
121 return new IndexedChannel<SBendRep>
124 }
125 } else {
126 for(const Entry *table = entries; table->name != 0; ++table) {
127 if(aKey == table->name) {
128 return new IndirectChannel<SBendRep>(*this, table->get, table->set);
129 }
130 }
131
132 return ElementBase::getChannel(aKey, create);
133 }
134}
135
136
138 return field;
139}
140
142 return field;
143}
144
145
147 return geometry;
148}
149
151 return geometry;
152}
153
154
155double SBendRep::getB() const {
156 return field.getNormalComponent(1);
157}
158
159void SBendRep::setB(double B) {
161}
162
163
165 return rEntry;
166}
167
168
170 return rExit;
171}
172
174 rEntry = e1;
175}
176
178 rExit = e2;
179}
180
182 return hEntry;
183}
184
186 return hExit;
187}
188
190 hEntry = h1;
191}
192
194 hExit = h2;
195}
196
197
198double SBendRep::getSlices() const {
199 return slices;
200}
201
202double SBendRep::getStepsize() const {
203 return stepsize;
204}
205
206void SBendRep::setSlices(double sl) {
207 slices = sl;
208}
209
210void SBendRep::setStepsize(double ds) {
211 stepsize = ds;
212}
213
214
216 field = f;
217}
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:414
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
Definition: SBend.h:68
void setSkewComponent(int, double)
Set skew component.
Definition: SBend.cpp:71
double getSkewComponent(int) const
Get skew component.
Definition: SBend.cpp:63
double getNormalComponent(int) const
Get normal component.
Definition: SBend.cpp:59
void setNormalComponent(int, double)
Set normal component.
Definition: SBend.cpp:67
virtual BMultipoleField & getField()
Get field.
Definition: SBendRep.cpp:137
double rEntry
Definition: SBendRep.h:145
virtual double getEntryFaceCurvature() const
Get entry pole face curvature.
Definition: SBendRep.cpp:181
virtual void setEntryFaceCurvature(double h1)
Set entry pole face curvature.
Definition: SBendRep.cpp:189
double hExit
Definition: SBendRep.h:148
virtual void setEntryFaceRotation(double e1)
Set pole entry face rotation.
Definition: SBendRep.cpp:173
virtual void setExitFaceCurvature(double h2)
Set exit pole face curvature.
Definition: SBendRep.cpp:193
virtual PlanarArcGeometry & getGeometry()
Get geometry.
Definition: SBendRep.cpp:146
PlanarArcGeometry geometry
The bend geometry.
Definition: SBendRep.h:139
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SBendRep.cpp:104
virtual void setSlices(double sl)
Set number of slices.
Definition: SBendRep.cpp:206
virtual double getExitFaceCurvature() const
Get exit pole face curvature.
Definition: SBendRep.cpp:185
virtual void setField(const BMultipoleField &field)
Set field.
Definition: SBendRep.cpp:215
double stepsize
Definition: SBendRep.h:152
virtual ElementBase * clone() const
Return clone.
Definition: SBendRep.cpp:99
double slices
Definition: SBendRep.h:151
double hEntry
Definition: SBendRep.h:147
virtual void setExitFaceRotation(double e2)
Set exit pole face rotation.
Definition: SBendRep.cpp:177
virtual double getStepsize() const
Get stepsize.
Definition: SBendRep.cpp:202
virtual double getB() const
Get field.
Definition: SBendRep.cpp:155
virtual void setB(double By)
Set vertical component.
Definition: SBendRep.cpp:159
double rExit
Definition: SBendRep.h:146
virtual double getSlices() const
Get number of slices.
Definition: SBendRep.cpp:198
SBendRep()
Definition: SBendRep.cpp:68
virtual double getEntryFaceRotation() const
Get pole entry face rotation.
Definition: SBendRep.cpp:164
virtual ~SBendRep()
Definition: SBendRep.cpp:95
virtual void setStepsize(double ds)
Set stepsize.
Definition: SBendRep.cpp:210
BMultipoleField field
The multipole expansion.
Definition: SBendRep.h:142
virtual double getExitFaceRotation() const
Get exit pole face rotation.
Definition: SBendRep.cpp:169
A simple arc in the XZ plane.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to an indexed [b]double[/b] data member.
Access to a [b]double[/b] data member.
The magnetic field of a multipole.
double getNormalComponent(int n) const
Get component.
void setNormalComponent(int n, double Bn)
Set component.