OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
MultipoleTCurvedVarRadius.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Titus Dascalu
3 * Copyright (c) 2018, Martin Duy Tat
4 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * 3. Neither the name of STFC nor the names of its contributors may be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29
30#ifndef CLASSIC_MULTIPOLET_CURVED_VAR_RADIUS_H
31#define CLASSIC_MULTIPOLET_CURVED_VAR_RADIUS_H
32
82
85#include <vector>
86
88public:
92 explicit MultipoleTCurvedVarRadius(const std::string &name);
98 virtual ElementBase* clone() const override;
100 void accept(BeamlineVisitor &visitor) const override;
102 VarRadiusGeometry& getGeometry() override;
104 const VarRadiusGeometry& getGeometry() const override;
109 virtual void setMaxOrder(const std::size_t &maxOrder) override;
111 std::size_t getMaxXOrder() const;
115 void setMaxXOrder(const std::size_t &maxXOrder);
117 virtual void setBendAngle(const double &angle) override;
119 virtual double getBendAngle() const override;
125 virtual void initialise(PartBunch_t* bunch,
126 double &startField,
127 double &endField) override;
128private:
131 std::size_t maxOrderX_m;
133 std::vector<polynomial::RecursionRelationTwo> recursion_m;
137 virtual void transformCoords(Vector_t<double, 3> &R) override;
139 virtual void transformBField(Vector_t<double, 3> &B, const Vector_t<double, 3> &R) override;
140 double angle_m;
147 virtual double getRadius(const double &s) override;
152 virtual double getScaleFactor(const double &x, const double &s) override;
159 virtual double getFn(const std::size_t &n,
160 const double &x,
161 const double &s) override;
162};
163
164inline
166 visitor.visitMultipoleTCurvedVarRadius(*this);
167}
168inline
170 const std::size_t &maxXorder) {
171 maxOrderX_m = maxXorder;
172}
173inline
175 return maxOrderX_m;
176}
177inline
179 return varRadiusGeometry_m;
180}
181inline
183 return varRadiusGeometry_m;
184}
185inline
186 void MultipoleTCurvedVarRadius::setBendAngle(const double &angle) {
187 angle_m = angle;
188}
189inline
191 return angle_m;
192}
193inline
195 double &/*startField*/,
196 double &/*endField*/) {
197 RefPartBunch_m = bunch;
198 double length = getLength();
201 varRadiusGeometry_m.setS0(length / 2);
202 std::vector<double> fringeLength = getFringeLength();
203 varRadiusGeometry_m.setLambdaLeft(fringeLength[0]);
204 varRadiusGeometry_m.setLambdaRight(fringeLength[1]);
205}
206
207#endif
virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &)=0
Apply the algorithm to an arbitrary curved multipole of variable radius.
PartBunch_t * RefPartBunch_m
Definition: Component.h:185
double getBoundingBoxLength() const
Get distance between centre of magnet and entrance.
std::vector< double > getFringeLength() const
Return vector of 2 doubles [left fringe length, right fringelength].
double getLength() const
Get the length of the magnet.
std::vector< polynomial::RecursionRelationTwo > recursion_m
Objects for storing differential operator acting on Fn.
virtual void transformCoords(Vector_t< double, 3 > &R) override
Transform to Frenet-Serret coordinates for sector magnets.
virtual double getScaleFactor(const double &x, const double &s) override
Returns the scale factor .
virtual void setBendAngle(const double &angle) override
Set the bending angle of the magnet.
VarRadiusGeometry & getGeometry() override
Return the cell geometry.
virtual void transformBField(Vector_t< double, 3 > &B, const Vector_t< double, 3 > &R) override
Transform B-field from Frenet-Serret coordinates to lab coordinates.
virtual double getRadius(const double &s) override
Radius of curvature If radius of curvature is infinite, -1 is returned where S(s) is the fringe f...
virtual void setMaxOrder(const std::size_t &maxOrder) override
Set the number of terms used in calculation of field components Maximum power of z in Bz is 2 * maxO...
void setMaxXOrder(const std::size_t &maxXOrder)
Set the number of terms used in polynomial expansions.
virtual ElementBase * clone() const override
Inheritable copy constructor.
VarRadiusGeometry varRadiusGeometry_m
Geometry.
void accept(BeamlineVisitor &visitor) const override
Accept a beamline visitor.
virtual double getFn(const std::size_t &n, const double &x, const double &s) override
Calculate fn(x, s) by expanding the differential operator (from Laplacian and scalar potential) in te...
MultipoleTCurvedVarRadius(const std::string &name)
Constructor.
std::size_t getMaxXOrder() const
Get highest power of x in polynomial expansions.
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Initialise the MultipoleT.
MultipoleTCurvedVarRadius operator=(const MultipoleTCurvedVarRadius &rhs)
virtual double getBendAngle() const override
Get the bending angle of the magnet.
std::size_t maxOrderX_m
Highest order of polynomial expansions in x.
void setS0(const double &s_0)
Set central fringe field length.
virtual void setElementLength(double length)
Set arc length.
void setLambdaRight(const double &lambda_right)
Set right end fringe field length.
void setLambdaLeft(const double &lambda_left)
Set left end fringe field length.
void setRadius(const double &rho)
Set centre radius of curvature.