OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Ring.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2014, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef RING_H
29#define RING_H
30
31#include <string>
32
34
36
39
40class LossDataSink;
41class FieldMap;
42
62class Ring : public Component {
63public:
68 Ring(std::string ring);
69
74 Ring(const Ring& ring);
75
77 virtual ~Ring();
78
92 virtual bool apply(
93 const size_t& id, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B) override;
94
111 virtual bool apply(
112 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
114
123 virtual void initialise(PartBunch_t* bunch, double& startField, double& endField) override;
124
130 virtual void initialise(PartBunch_t* bunch);
131
136 virtual void finalise() override;
137
139 virtual bool bends() const override {
140 return true;
141 }
142
149 virtual void accept(BeamlineVisitor& visitor) const override;
150
152 virtual void getDimensions(double& zBegin, double& zEnd) const override;
153
155 virtual ElementBase* clone() const override {
156 return new Ring(*this);
157 }
158
178 void appendElement(const Component& element);
179
181 virtual EMField& getField() override {
182 throw GeneralClassicException("Ring::getField", "Not implemented");
183 }
184
186 virtual const EMField& getField() const override {
187 throw GeneralClassicException("Ring::getField", "Not implemented");
188 }
189
191 virtual PlanarArcGeometry& getGeometry() override {
192 return planarArcGeometry_m;
193 }
194
196 virtual const PlanarArcGeometry& getGeometry() const override {
197 return planarArcGeometry_m;
198 }
199
205 void setLossDataSink(LossDataSink* sink);
206
212
220 void setRefPartBunch(PartBunch_t* bunch);
221
227
229 void setHarmonicNumber(double cyclHarm) {
230 cyclHarm_m = cyclHarm;
231 }
232
235 return cyclHarm_m;
236 }
237 // note this is not a const method to follow parent
238
240 void setRFFreq(double rfFreq) {
241 rfFreq_m = rfFreq;
242 }
243
245 double getRFFreq() const {
246 return rfFreq_m;
247 }
248
250 void setBeamRInit(double rInit) {
251 beamRInit_m = rInit;
252 }
253
255 double getBeamRInit() const {
256 return beamRInit_m;
257 }
258
260 void setBeamPhiInit(double phiInit) {
261 beamPhiInit_m = phiInit;
262 }
263
265 double getBeamPhiInit() const {
266 return beamPhiInit_m;
267 }
268
270 void setBeamPRInit(double pRInit) {
271 beamPRInit_m = pRInit;
272 }
273
275 double getBeamPRInit() const {
276 return beamPRInit_m;
277 }
278
280 void setLatticeRInit(double rInit) {
281 latticeRInit_m = rInit;
282 }
283
285 double getLatticeRInit() const {
286 return latticeRInit_m;
287 }
288
290 void setLatticePhiInit(double phiInit) {
291 latticePhiInit_m = phiInit;
292 }
293
295 double getLatticePhiInit() const {
296 return latticePhiInit_m;
297 }
298
301
304
309 void setLatticeThetaInit(double thetaInit) {
310 latticeThetaInit_m = thetaInit;
311 }
312
317 double getLatticeThetaInit() const {
318 return latticeThetaInit_m;
319 }
320
322 void setSymmetry(double symmetry) {
323 symmetry_m = symmetry;
324 }
325
327 void setScale(double scale) {
328 scale_m = scale;
329 }
330
332 double getSymmetry() const {
333 return symmetry_m;
334 }
335
337 void setIsClosed(bool isClosed) {
338 isClosed_m = isClosed;
339 }
340
342 double getIsClosed() const {
343 return isClosed_m;
344 }
345
350 void setRingAperture(double minR, double maxR);
351
353 double getRingMinR() const {
354 return std::sqrt(minR2_m);
355 }
356
358 double getRingMaxR() const {
359 return std::sqrt(maxR2_m);
360 }
361
371 void lockRing();
372
375
377 std::vector<RingSection*> getSectionsAt(const Vector_t<double, 3>& pos);
378
380 static inline Vector_t<double, 3> convert(const Vector3D& vec);
381
383 static inline Vector3D convert(const Vector_t<double, 3>& vec);
384
385private:
386 // Force end to have azimuthal angle > start unless crossing phi = pi/-pi
387 void resetAzimuths();
388
389 // check for closure; throw an exception is ring is not closed within
390 // tolerance; enforce closure to floating point precision
391 void checkAndClose();
392
393 // build a map that maps section to sections that overlap it
394 void buildRingSections();
395
396 void rotateToCyclCoordinates(Euclid3D& euclid3d) const;
397
398 // predicate for sorting
399 static bool sectionCompare(RingSection const* const sec1, RingSection const* const sec2);
400
403
405 Ring& operator=(const Ring& ring);
406
407 void checkMidplane(Euclid3D delta) const;
409
411
412 // points to same location as RefPartBunch_m on the child bunch, but we
413 // rename to keep in line with style guide
414 //
415 // Ring borrows this memory
417
418 // store for particles out of the aperture
419 //
420 // Ring owns this memory
422
423 // initial position of the beam
427
428 // position, orientation of the first lattice element
432
433 // aperture cut on the ring (before any field maps tracking)
434 // note we store r^2
435 bool willDoAperture_m = false;
436 double minR2_m;
437 double maxR2_m;
438
439 // Ring is locked - new elements cannot be added
441
442 // Set to false to enable a non-circular ring (e.g. some weird spiral
443 // geometry)
445
446 // number of cells/rotational symmetry of the ring
448
449 double scale_m = 1.;
450
451 // rf harmonic number
453
454 // nominal rf frequency
455 double rfFreq_m;
456
457 // vector of RingSection sorted by phi (Component placement)
458 double phiStep_m;
459 std::vector<RingSectionList> ringSections_m;
461
462 // tolerance on checking for geometry consistency
463 static const double lengthTolerance_m;
464 static const double angleTolerance_m;
465};
466
468 return Vector_t<double, 3>({vec_3d(0), vec_3d(1), vec_3d(2)});
469}
470
472 return Vector3D({vec_t[0], vec_t[1], vec_t[2]});
473}
474
475#endif // #ifndef RING_H
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
std::vector< RingSection * > RingSectionList
Interface for a single beam element.
Definition Component.h:50
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
ElementBase(const std::string &name)
Constructor with given name.
virtual const EMField & getField() const override
Definition Ring.h:186
double rfFreq_m
Definition Ring.h:455
double getBeamRInit() const
Definition Ring.h:255
bool isClosed_m
Definition Ring.h:444
LossDataSink * lossDS_m
Definition Ring.h:421
void buildRingSections()
Definition Ring.cpp:365
void setSymmetry(double symmetry)
Definition Ring.h:322
PartBunch_t * getRefPartBunch() const
double maxR2_m
Definition Ring.h:437
double getLatticePhiInit() const
Definition Ring.h:295
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Definition Ring.cpp:186
double getRingMinR() const
Definition Ring.h:353
static Vector_t< double, 3 > convert(const Vector3D &vec)
Definition Ring.h:467
Rotation3D getRotationStartToEnd(Euclid3D delta) const
Definition Ring.cpp:205
double beamPhiInit_m
Definition Ring.h:426
virtual EMField & getField() override
Definition Ring.h:181
double minR2_m
Definition Ring.h:436
bool willDoAperture_m
Definition Ring.h:435
static bool sectionCompare(RingSection const *const sec1, RingSection const *const sec2)
Definition Ring.cpp:386
double getBeamPRInit() const
Definition Ring.h:275
virtual void finalise() override
Definition Ring.cpp:190
void checkAndClose()
Definition Ring.cpp:351
Vector_t< double, 3 > getNextPosition() const
Definition Ring.cpp:234
void resetAzimuths()
Definition Ring.cpp:336
double getSymmetry() const
Definition Ring.h:332
virtual ~Ring()
Definition Ring.cpp:104
Vector_t< double, 3 > getNextNormal() const
Definition Ring.cpp:243
Ring & operator=(const Ring &ring)
RingSection * getLastSectionPlaced() const
Definition Ring.cpp:379
virtual bool apply(const size_t &id, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Definition Ring.cpp:109
void setBeamRInit(double rInit)
Definition Ring.h:250
virtual const PlanarArcGeometry & getGeometry() const override
Definition Ring.h:196
void setIsClosed(bool isClosed)
Definition Ring.h:337
void setLatticeThetaInit(double thetaInit)
Definition Ring.h:309
virtual ElementBase * clone() const override
Definition Ring.h:155
void setHarmonicNumber(double cyclHarm)
Definition Ring.h:229
void setLatticePhiInit(double phiInit)
Definition Ring.h:290
virtual bool bends() const override
Definition Ring.h:139
double getLatticeThetaInit() const
Definition Ring.h:317
double latticeThetaInit_m
Definition Ring.h:431
std::vector< RingSectionList > ringSections_m
Definition Ring.h:459
virtual void accept(BeamlineVisitor &visitor) const override
Definition Ring.cpp:69
void setRingAperture(double minR, double maxR)
Definition Ring.cpp:390
double beamRInit_m
Definition Ring.h:424
void setScale(double scale)
Definition Ring.h:327
double latticePhiInit_m
Definition Ring.h:430
RingSectionList section_list_m
Definition Ring.h:460
double getBeamPhiInit() const
Definition Ring.h:265
void setBeamPRInit(double pRInit)
Definition Ring.h:270
double getIsClosed() const
Definition Ring.h:342
double scale_m
Definition Ring.h:449
std::vector< RingSection * > getSectionsAt(const Vector_t< double, 3 > &pos)
Definition Ring.cpp:201
double getRingMaxR() const
Definition Ring.h:358
void checkMidplane(Euclid3D delta) const
Definition Ring.cpp:216
double beamPRInit_m
Definition Ring.h:425
void setLossDataSink(LossDataSink *sink)
Definition Ring.cpp:171
PartBunch_t * refPartBunch_m
Definition Ring.h:416
int symmetry_m
Definition Ring.h:447
void setBeamPhiInit(double phiInit)
Definition Ring.h:260
double latticeRInit_m
Definition Ring.h:429
void setRefPartBunch(PartBunch_t *bunch)
Definition Ring.cpp:196
PlanarArcGeometry planarArcGeometry_m
Definition Ring.h:410
double getHarmonicNumber()
Definition Ring.h:234
virtual void getDimensions(double &zBegin, double &zEnd) const override
Definition Ring.cpp:176
void setRFFreq(double rfFreq)
Definition Ring.h:240
Ring(std::string ring)
Definition Ring.cpp:47
double phiStep_m
Definition Ring.h:458
void lockRing()
Definition Ring.cpp:306
double getRFFreq() const
Definition Ring.h:245
void setLatticeRInit(double rInit)
Definition Ring.h:280
virtual PlanarArcGeometry & getGeometry() override
Definition Ring.h:191
bool isLocked_m
Definition Ring.h:440
void appendElement(const Component &element)
Definition Ring.cpp:252
void rotateToCyclCoordinates(Euclid3D &euclid3d) const
Definition Ring.cpp:226
double cyclHarm_m
Definition Ring.h:452
double getLatticeRInit() const
Definition Ring.h:285
static const double lengthTolerance_m
Definition Ring.h:463
static const double angleTolerance_m
Definition Ring.h:464
PartBunch_t * getLossDataSink() const
Displacement and rotation in space.
Definition Euclid3D.h:68
A simple arc in the XZ plane.
Rotation in 3-dimensional space.
Definition Rotation3D.h:46
A 3-dimension vector.
Definition Vector3D.h:31
Abstract base class for electromagnetic fields.
Definition EMField.h:188
Component placement handler in ring geometry.
Definition RingSection.h:67