OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
MultipoleT.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#ifndef CLASSIC_MULTIPOLET_H
30#define CLASSIC_MULTIPOLET_H
31
80//
81#include <vector>
86#include "gsl/gsl_sf.h"
87
88class MultipoleT : public Component {
89public:
93 explicit MultipoleT(const std::string& name);
95 MultipoleT(const MultipoleT& right);
99 ElementBase* clone() const override;
101 EMField& getField() override;
103 const EMField& getField() const override;
105 void getDimensions(double& zBegin, double& zEnd) const override;
115 bool apply(
116 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
127 bool apply(
128 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B) override;
134 void initialise(PartBunch_t*, double& startField, double& endField) override;
136 void initialise();
137
139 void finalise() override;
141 bool bends() const override;
143 PlanarArcGeometry& getGeometry() override;
145 const PlanarArcGeometry& getGeometry() const override;
147 void accept(BeamlineVisitor& visitor) const override;
149 double getDipoleConstant() const;
151 void setDipoleConstant(double B0);
153 std::size_t getMaxOrder() const;
158 void setMaxOrder(std::size_t maxOrder);
160 std::size_t getMaxXOrder() const;
164 void setMaxXOrder(std::size_t maxXOrder);
166 std::size_t getTransMaxOrder() const;
170 void setTransMaxOrder(std::size_t transMaxOrder);
176 void setTransProfile(std::size_t n, double Bn);
180 double getTransProfile(int n) const;
182 std::vector<double> getTransProfile() const;
191 bool setFringeField(double s0, double lambda_left, double lambda_right);
195 std::vector<double> getFringeLength() const;
197 void setBendAngle(double angle);
199 double getBendAngle() const;
203 void setEntranceAngle(double entranceAngle);
205 double getEntranceAngle() const;
209 double getBendRadius() const;
214 void setLength(double length);
216 double getLength() const;
218 double getChordLength() const;
224 void setAperture(double vertAp, double horizAp);
228 std::vector<double> getAperture() const;
233 void setRotation(double rot);
235 double getRotation() const;
237 void setVarRadius();
239 bool getVarRadius() const;
241 double getBoundingBoxLength() const;
245 void setBoundingBoxLength(const double& boundingBoxLength);
246
247private:
249 // End fields
255 std::size_t maxOrder_m = 0;
257 std::size_t maxOrderX_m = 0;
259 std::vector<polynomial::RecursionRelationTwo> recursion_VarRadius_m;
260 std::vector<polynomial::RecursionRelation> recursion_ConstRadius_m;
262 std::size_t transMaxOrder_m = 0;
264 std::vector<double> transProfile_m;
281 double length_m;
282 double angle_m;
291 double getBx(const Vector_t<double, 3>& R);
292 double getBz(const Vector_t<double, 3>& R);
293 double getBs(const Vector_t<double, 3>& R);
303 double getFringeDeriv(int n, double s);
308 double getTransDeriv(std::size_t n, double x);
312 bool insideAperture(const Vector_t<double, 3>& R);
322 double getRadius(double s);
327 double getScaleFactor(double x, double s);
335 double getFnDerivX(std::size_t n, double x, double s);
343 double getFnDerivS(std::size_t n, double x, double s);
350 double getFn(std::size_t n, double x, double s);
351};
352
354 variableRadius_m = true;
355}
356inline bool MultipoleT::getVarRadius() const {
357 return variableRadius_m;
358}
359inline void MultipoleT::setEntranceAngle(double entranceAngle) {
360 entranceAngle_m = entranceAngle;
361}
362inline double MultipoleT::getEntranceAngle() const {
363 return entranceAngle_m;
364}
365inline double MultipoleT::getTransProfile(int n) const {
366 return transProfile_m[n];
367}
368inline std::vector<double> MultipoleT::getTransProfile() const {
369 return transProfile_m;
370}
371inline double MultipoleT::getDipoleConstant() const {
372 return transProfile_m[0];
373}
374inline std::size_t MultipoleT::getMaxOrder() const {
375 return maxOrder_m;
376}
377
378inline std::size_t MultipoleT::getMaxXOrder() const {
379 return maxOrderX_m;
380}
381
382inline void MultipoleT::setMaxXOrder(std::size_t maxOrderX) {
383 maxOrderX_m = maxOrderX;
384}
385inline std::size_t MultipoleT::getTransMaxOrder() const {
386 return transMaxOrder_m;
387}
388inline void MultipoleT::setTransMaxOrder(std::size_t transMaxOrder) {
389 transMaxOrder_m = transMaxOrder;
390 transProfile_m.resize(transMaxOrder + 1, 0.);
391}
392inline double MultipoleT::getRotation() const {
393 return rotation_m;
394}
395inline void MultipoleT::setRotation(double rot) {
396 rotation_m = rot;
397}
398inline void MultipoleT::setBendAngle(double angle) {
399 angle_m = angle;
400}
401inline double MultipoleT::getBendAngle() const {
402 return angle_m;
403}
404inline void MultipoleT::setLength(double length) {
405 length_m = std::abs(length);
406}
407inline double MultipoleT::getLength() const {
408 return length_m;
409}
410inline double MultipoleT::getBoundingBoxLength() const {
411 return boundingBoxLength_m;
412}
413inline void MultipoleT::setBoundingBoxLength(const double& boundingBoxLength) {
414 boundingBoxLength_m = boundingBoxLength;
415}
416
417#endif
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
ElementBase(const std::string &name)
Constructor with given name.
void setBendAngle(double angle)
Definition MultipoleT.h:398
void setRotation(double rot)
Definition MultipoleT.h:395
std::size_t getTransMaxOrder() const
Definition MultipoleT.h:385
std::vector< double > transProfile_m
Definition MultipoleT.h:264
void setDipoleConstant(double B0)
double getBoundingBoxLength() const
Definition MultipoleT.h:410
std::size_t transMaxOrder_m
Definition MultipoleT.h:262
void setMaxXOrder(std::size_t maxXOrder)
Definition MultipoleT.h:382
double horizApert_m
Definition MultipoleT.h:296
void setAperture(double vertAp, double horizAp)
BMultipoleField dummy
Definition MultipoleT.h:298
Vector_t< double, 3 > rotateFrameInverse(Vector_t< double, 3 > &B)
Vector_t< double, 3 > transformCoords(const Vector_t< double, 3 > &R)
MultipoleT operator=(const MultipoleT &rhs)
double getTransDeriv(std::size_t n, double x)
double entranceAngle_m
Definition MultipoleT.h:283
void setMaxOrder(std::size_t maxOrder)
std::vector< polynomial::RecursionRelationTwo > recursion_VarRadius_m
Definition MultipoleT.h:259
void initialise()
bool apply(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
endfieldmodel::Tanh fringeField_r
Definition MultipoleT.h:251
endfieldmodel::Tanh fringeField_l
Definition MultipoleT.h:250
void setEntranceAngle(double entranceAngle)
Definition MultipoleT.h:359
double getBz(const Vector_t< double, 3 > &R)
ElementBase * clone() const override
bool insideAperture(const Vector_t< double, 3 > &R)
double getLength() const
Definition MultipoleT.h:407
void setTransMaxOrder(std::size_t transMaxOrder)
Definition MultipoleT.h:388
EMField & getField() override
double getScaleFactor(double x, double s)
double getFnDerivX(std::size_t n, double x, double s)
void accept(BeamlineVisitor &visitor) const override
void setBoundingBoxLength(const double &boundingBoxLength)
Definition MultipoleT.h:413
double verticalApert_m
Definition MultipoleT.h:295
double getChordLength() const
std::size_t getMaxOrder() const
Definition MultipoleT.h:374
double rotation_m
Definition MultipoleT.h:284
void getDimensions(double &zBegin, double &zEnd) const override
bool getVarRadius() const
Definition MultipoleT.h:356
double angle_m
Definition MultipoleT.h:282
double getFnDerivS(std::size_t n, double x, double s)
std::size_t maxOrderX_m
Definition MultipoleT.h:257
double getRadius(double s)
std::vector< polynomial::RecursionRelation > recursion_ConstRadius_m
Definition MultipoleT.h:260
double getBx(const Vector_t< double, 3 > &R)
std::size_t getMaxXOrder() const
Definition MultipoleT.h:378
double length_m
Definition MultipoleT.h:281
double getFn(std::size_t n, double x, double s)
bool setFringeField(double s0, double lambda_left, double lambda_right)
void initialise(PartBunch_t *, double &startField, double &endField) override
void finalise() override
double getFringeDeriv(int n, double s)
double getDipoleConstant() const
Definition MultipoleT.h:371
void setVarRadius()
Definition MultipoleT.h:353
PlanarArcGeometry planarArcGeometry_m
Definition MultipoleT.h:266
void setLength(double length)
Definition MultipoleT.h:404
bool bends() const override
std::vector< double > getAperture() const
double getRotation() const
Definition MultipoleT.h:392
void setTransProfile(std::size_t n, double Bn)
double getBendRadius() const
std::size_t maxOrder_m
Definition MultipoleT.h:255
bool variableRadius_m
Definition MultipoleT.h:286
double boundingBoxLength_m
Definition MultipoleT.h:288
MultipoleT(const std::string &name)
std::vector< double > getTransProfile() const
Definition MultipoleT.h:368
double getEntranceAngle() const
Definition MultipoleT.h:362
Vector_t< double, 3 > rotateFrame(const Vector_t< double, 3 > &R)
double getBendAngle() const
Definition MultipoleT.h:401
double getBs(const Vector_t< double, 3 > &R)
PlanarArcGeometry & getGeometry() override
std::vector< double > getFringeLength() const
A simple arc in the XZ plane.
The magnetic field of a multipole.
Abstract base class for electromagnetic fields.
Definition EMField.h:188