OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
|
#include <ScalingFFAMagnet.h>
Public Member Functions | |
ScalingFFAMagnet (const std::string &name) | |
~ScalingFFAMagnet () | |
ScalingFFAMagnet * | clone () const override |
bool | apply (const size_t &i, const double &t, Vector_t &E, Vector_t &B) override |
bool | apply (const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override |
bool | getFieldValue (const Vector_t &R, Vector_t &B) const |
bool | getFieldValueCylindrical (const Vector_t &R, Vector_t &B) const |
void | initialise (PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override |
void | initialise () |
void | finalise () override |
bool | bends () const override |
void | getDimensions (double &, double &) const override |
BGeometryBase & | getGeometry () override |
const BGeometryBase & | getGeometry () const override |
EMField & | getField () override |
const EMField & | getField () const override |
void | accept (BeamlineVisitor &visitor) const override |
double | getTanDelta () const |
void | setTanDelta (double tanDelta) |
double | getFieldIndex () const |
void | setFieldIndex (double k) |
double | getDipoleConstant () const |
void | setDipoleConstant (double Bz) |
double | getR0 () const |
void | setR0 (double r0) |
Vector_t | getCentre () const |
void | setCentre (Vector_t centre) |
endfieldmodel::EndFieldModel * | getEndField () const |
void | setEndField (endfieldmodel::EndFieldModel *endField) |
size_t | getMaxOrder () const |
void | setMaxOrder (size_t maxOrder) |
double | getPhiStart () const |
void | setPhiStart (double phiStart) |
double | getPhiEnd () const |
void | setPhiEnd (double phiEnd) |
double | getRMin () const |
void | setRMin (double rMin) |
double | getRMax () const |
void | setRMax (double rMax) |
double | getAzimuthalExtent () const |
void | setAzimuthalExtent (double azimuthalExtent) |
double | getVerticalExtent () const |
void | setVerticalExtent (double verticalExtent) |
std::vector< std::vector< double > > | getDfCoefficients () |
void | setupEndField () |
void | setEndFieldName (std::string name) |
std::string | getEndFieldName () const |
Public Member Functions inherited from Component | |
Component (const std::string &name) | |
Constructor with given name. More... | |
Component () | |
Component (const Component &right) | |
virtual | ~Component () |
virtual EMField & | getField ()=0 |
Return field. More... | |
virtual const EMField & | getField () const =0 |
Return field. More... | |
EVector | Efield (const Point3D &P) const |
Return the field in a point. More... | |
BVector | Bfield (const Point3D &P) const |
Return the field in a point. More... | |
EVector | Efield (const Point3D &P, double t) const |
Return the field in a point. More... | |
BVector | Bfield (const Point3D &P, double t) const |
Return the field in a point. More... | |
EBVectors | EBfield (const Point3D &P) const |
Return the field in a point. More... | |
EBVectors | EBfield (const Point3D &P, double t) const |
Return the field in a point. More... | |
virtual bool | apply (const size_t &i, const double &t, Vector_t &E, Vector_t &B) |
virtual bool | apply (const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) |
virtual bool | applyToReferenceParticle (const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) |
virtual bool | getPotential (const Vector_t &, const double &, Vector_t &, double &) |
virtual double | getDesignEnergy () const |
virtual void | setDesignEnergy (const double &energy, bool changeable=true) |
virtual void | initialise (PartBunchBase< double, 3 > *bunch, double &startField, double &endField)=0 |
virtual void | finalise ()=0 |
virtual bool | bends () const =0 |
virtual void | goOnline (const double &kineticEnergy) |
virtual void | goOffline () |
virtual bool | Online () |
virtual void | getDimensions (double &zBegin, double &zEnd) const =0 |
virtual ElementType | getType () const |
Get element type std::string. More... | |
virtual const ElementBase & | getDesign () const |
Return design element. More... | |
virtual void | trackBunch (PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const |
Track particle bunch. More... | |
virtual void | trackMap (FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const |
Track a map. More... | |
void | setExitFaceSlope (const double &) |
Public Member Functions inherited from ElementBase | |
ElementBase (const std::string &name) | |
Constructor with given name. More... | |
ElementBase () | |
ElementBase (const ElementBase &) | |
virtual | ~ElementBase () |
virtual const std::string & | getName () const |
Get element name. More... | |
virtual void | setName (const std::string &name) |
Set element name. More... | |
virtual ElementType | getType () const =0 |
Get element type std::string. More... | |
std::string | getTypeString () const |
virtual BGeometryBase & | getGeometry ()=0 |
Get geometry. More... | |
virtual const BGeometryBase & | getGeometry () const =0 |
Get geometry. More... | |
virtual double | getArcLength () const |
Get arc length. More... | |
virtual double | getElementLength () const |
Get design length. More... | |
virtual void | setElementLength (double length) |
Set design length. More... | |
virtual void | getElementDimensions (double &begin, double &end) const |
virtual double | getOrigin () const |
Get origin position. More... | |
virtual double | getEntrance () const |
Get entrance position. More... | |
virtual double | getExit () const |
Get exit position. More... | |
virtual Euclid3D | getTransform (double fromS, double toS) const |
Get transform. More... | |
virtual Euclid3D | getTransform (double s) const |
Get transform. More... | |
virtual Euclid3D | getTotalTransform () const |
Get transform. More... | |
virtual Euclid3D | getEntranceFrame () const |
Get transform. More... | |
virtual Euclid3D | getExitFrame () const |
Get transform. More... | |
virtual Euclid3D | getEntrancePatch () const |
Get patch. More... | |
virtual Euclid3D | getExitPatch () const |
Get patch. More... | |
virtual double | getAttribute (const std::string &aKey) const |
Get attribute value. More... | |
virtual bool | hasAttribute (const std::string &aKey) const |
Test for existence of an attribute. More... | |
virtual void | removeAttribute (const std::string &aKey) |
Remove an existing attribute. More... | |
virtual void | setAttribute (const std::string &aKey, double val) |
Set value of an attribute. More... | |
virtual Channel * | getChannel (const std::string &aKey, bool create=false) |
Construct a read/write channel. More... | |
virtual const ConstChannel * | getConstChannel (const std::string &aKey) const |
Construct a read-only channel. More... | |
virtual void | accept (BeamlineVisitor &visitor) const =0 |
Apply visitor. More... | |
virtual ElementBase * | clone () const =0 |
Return clone. More... | |
virtual ElementBase * | copyStructure () |
Make a structural copy. More... | |
bool | isSharable () const |
Test if the element can be shared. More... | |
virtual void | makeSharable () |
Set sharable flag. More... | |
bool | update (const AttributeSet &) |
Update element. More... | |
virtual void | setBoundaryGeometry (BoundaryGeometry *geo) |
virtual BoundaryGeometry * | getBoundaryGeometry () const |
return the attached boundary geometrt object if there is any More... | |
virtual bool | hasBoundaryGeometry () const |
virtual void | setWake (WakeFunction *wf) |
attach a wake field to the element More... | |
virtual WakeFunction * | getWake () const |
return the attached wake object if there is any More... | |
virtual bool | hasWake () const |
virtual void | setParticleMatterInteraction (ParticleMatterInteractionHandler *spys) |
virtual ParticleMatterInteractionHandler * | getParticleMatterInteraction () const |
virtual bool | hasParticleMatterInteraction () const |
void | setCSTrafoGlobal2Local (const CoordinateSystemTrafo &ori) |
CoordinateSystemTrafo | getCSTrafoGlobal2Local () const |
void | releasePosition () |
void | fixPosition () |
bool | isPositioned () const |
virtual CoordinateSystemTrafo | getEdgeToBegin () const |
virtual CoordinateSystemTrafo | getEdgeToEnd () const |
void | setAperture (const ApertureType &type, const std::vector< double > &args) |
std::pair< ApertureType, std::vector< double > > | getAperture () const |
virtual bool | isInside (const Vector_t &r) const |
void | setMisalignment (const CoordinateSystemTrafo &cst) |
void | getMisalignment (double &x, double &y, double &s) const |
CoordinateSystemTrafo | getMisalignment () const |
void | setActionRange (const std::queue< std::pair< double, double > > &range) |
void | setCurrentSCoordinate (double s) |
void | setRotationAboutZ (double rotation) |
Set rotation about z axis in bend frame. More... | |
double | getRotationAboutZ () const |
virtual BoundingBox | getBoundingBoxInLabCoords () const |
virtual int | getRequiredNumberOfTimeSteps () const |
void | setOutputFN (std::string fn) |
Set output filename. More... | |
std::string | getOutputFN () const |
Get output filename. More... | |
void | setFlagDeleteOnTransverseExit (bool=true) |
bool | getFlagDeleteOnTransverseExit () const |
void | setElementPosition (double elemedge) |
Access to ELEMEDGE attribute. More... | |
double | getElementPosition () const |
bool | isElementPositionSet () const |
Public Member Functions inherited from RCObject | |
int | addReference () const |
Increment reference count. More... | |
int | removeReference () const |
Decrement the reference count. More... | |
bool | isShared () const |
Test for sharing. More... | |
Private Member Functions | |
void | calculateDfCoefficients () |
ScalingFFAMagnet (const ScalingFFAMagnet &right) | |
ScalingFFAMagnet & | operator= (const ScalingFFAMagnet &rhs) |
Private Attributes | |
PlanarArcGeometry | planarArcGeometry_m |
BMultipoleField | dummy |
size_t | maxOrder_m = 0 |
double | tanDelta_m = 0. |
double | k_m = 0. |
double | Bz_m = 0. |
double | r0_m = 0. |
double | rMin_m = 0. |
double | rMax_m = 0. |
double | phiStart_m = 0. |
double | phiEnd_m = 0. |
double | azimuthalExtent_m = 0. |
double | verticalExtent_m = 0. |
Vector_t | centre_m |
endfieldmodel::EndFieldModel * | endField_m = nullptr |
std::string | endFieldName_m = "" |
const double | fp_tolerance = 1e-18 |
std::vector< std::vector< double > > | dfCoefficients_m |
Additional Inherited Members | |
Static Public Member Functions inherited from ElementBase | |
static std::string | getTypeString (ElementType type) |
Protected Member Functions inherited from ElementBase | |
bool | isInsideTransverse (const Vector_t &r) const |
Protected Member Functions inherited from RCObject | |
RCObject () | |
Default constructor. More... | |
RCObject (const RCObject &) | |
Copy constructor. More... | |
virtual | ~RCObject ()=0 |
RCObject & | operator= (const RCObject &right) |
Protected Attributes inherited from Component | |
double | exit_face_slope_m |
PartBunchBase< double, 3 > * | RefPartBunch_m |
bool | online_m |
Protected Attributes inherited from ElementBase | |
bool | shareFlag |
CoordinateSystemTrafo | csTrafoGlobal2Local_m |
CoordinateSystemTrafo | misalignment_m |
std::pair< ApertureType, std::vector< double > > | aperture_m |
double | elementEdge_m |
double | rotationZAxis_m |
Static Protected Attributes inherited from Component | |
static const std::vector< double > | defaultAperture_m |
Sector bending magnet with an FFA-style field index and spiral end shape
Note about placement and end field; in order to get a user-defined end field shape, we do a lookup from user defined end fields, which is pulled from the EndFieldModel object and done by setupEndField(). Because end fields tie into the geometry, this has to be done before placements; but it also needs to be done after parsing has finished. setupEndField() is called by e.g. ParallelCyclotronTracker just before the object is handed to OpalRing for placement.
Definition at line 47 of file ScalingFFAMagnet.h.
|
explicit |
Construct a new ScalingFFAMagnet
name | User-defined name of the ScalingFFAMagnet |
Definition at line 34 of file ScalingFFAMagnet.cpp.
Referenced by clone().
ScalingFFAMagnet::~ScalingFFAMagnet | ( | ) |
|
private |
Copy constructor
Definition at line 39 of file ScalingFFAMagnet.cpp.
References Bz_m, endfieldmodel::EndFieldModel::clone(), endField_m, r0_m, and Component::RefPartBunch_m.
|
overridevirtual |
Accept a beamline visitor
Implements ElementBase.
Definition at line 103 of file ScalingFFAMagnet.cpp.
References BeamlineVisitor::visitScalingFFAMagnet().
|
overridevirtual |
Calculate the field at the position of the ith particle
i | index of the particle event override; field is calculated at this position |
t | time at which the field is to be calculated |
E | calculated electric field - always 0 (no E-field) |
B | calculated magnetic field |
Reimplemented from Component.
Definition at line 73 of file ScalingFFAMagnet.cpp.
References apply(), PartBunchBase< T, Dim >::P, PartBunchBase< T, Dim >::R, and Component::RefPartBunch_m.
Referenced by apply().
|
overridevirtual |
Calculate the field at some arbitrary position
R | position in the local coordinate system of the bend |
P | not used |
t | not used |
E | not used |
B | calculated magnetic field |
Reimplemented from Component.
Definition at line 171 of file ScalingFFAMagnet.cpp.
References getFieldValue(), and Attrib::Distribution::R.
|
inlineoverridevirtual |
Return true - ScalingFFAMagnet always bends the reference particle
Implements Component.
Definition at line 91 of file ScalingFFAMagnet.cpp.
|
private |
Calculate the df coefficients, ready for field generation
Must be called following any update to the the field parameters, in order for correct field to be calculated.
Definition at line 176 of file ScalingFFAMagnet.cpp.
References dfCoefficients_m, k_m, maxOrder_m, Hypervolume::n, and tanDelta_m.
Referenced by initialise().
|
overridevirtual |
Inheritable copy constructor
Implements ElementBase.
Definition at line 59 of file ScalingFFAMagnet.cpp.
References initialise(), and ScalingFFAMagnet().
Referenced by ParallelCyclotronTracker::visitScalingFFAMagnet().
|
overridevirtual |
Finalise the ScalingFFAMagnet - sets bunch to nullptr
Implements Component.
Definition at line 87 of file ScalingFFAMagnet.cpp.
References Component::RefPartBunch_m.
|
inline |
Get the maximum azimuthal displacement from \psi=0
Definition at line 227 of file ScalingFFAMagnet.h.
References azimuthalExtent_m.
|
inline |
Get the centre of the sector
Definition at line 166 of file ScalingFFAMagnet.h.
References centre_m.
|
inline |
Return the calculated df coefficients
Definition at line 242 of file ScalingFFAMagnet.h.
References dfCoefficients_m.
|
inlineoverridevirtual |
|
inline |
|
inline |
Get the fringe field
Returns the fringe field model; ScalingFFAMagnet retains ownership of the returned memory.
Definition at line 176 of file ScalingFFAMagnet.h.
References endField_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Return the end field name.
Definition at line 262 of file ScalingFFAMagnet.h.
References endFieldName_m.
|
overridevirtual |
Return a dummy (0.) field value (what is this for?)
Implements Component.
Definition at line 69 of file ScalingFFAMagnet.cpp.
References dummy.
|
overridevirtual |
Return a dummy (0.) field value (what is this for?)
Implements Component.
Definition at line 65 of file ScalingFFAMagnet.cpp.
References dummy.
|
inline |
Calculate the field at some arbitrary position in cartesian coordinates
R | position in the local coordinate system of the bend, in cartesian coordinates defined like (x, y, z) |
B | calculated magnetic field defined like (Bx, By, Bz) |
Definition at line 108 of file ScalingFFAMagnet.cpp.
References atan2(), centre_m, cos(), getFieldValueCylindrical(), Attrib::Distribution::R, sin(), and sqrt().
Referenced by apply().
Calculate the field at some arbitrary position in cylindrical coordinates
R | position in the local coordinate system of the bend, in cylindrical polar coordinates defined like (r, y, phi) |
B | calculated magnetic field defined like (Br, By, Bphi) |
Definition at line 124 of file ScalingFFAMagnet.cpp.
Referenced by getFieldValue().
|
overridevirtual |
Return the cell geometry
Implements ElementBase.
Definition at line 99 of file ScalingFFAMagnet.cpp.
References planarArcGeometry_m.
|
overridevirtual |
Return the cell geometry
Implements ElementBase.
Definition at line 95 of file ScalingFFAMagnet.cpp.
References planarArcGeometry_m.
|
inline |
Get the maximum power of y modelled in the off-midplane expansion;
Definition at line 187 of file ScalingFFAMagnet.h.
References maxOrder_m.
|
inline |
Get the offset of the magnet end from the start
Definition at line 203 of file ScalingFFAMagnet.h.
References phiEnd_m.
|
inline |
Get the offset of the magnet centre from the start
Definition at line 195 of file ScalingFFAMagnet.h.
References phiStart_m.
Referenced by setupEndField().
|
inline |
Get the radius constant R_0
Definition at line 160 of file ScalingFFAMagnet.h.
References r0_m.
Referenced by setupEndField().
|
inline |
|
inline |
|
inline |
Get tan delta - delta is the spiral angle
Definition at line 142 of file ScalingFFAMagnet.h.
References tanDelta_m.
|
inline |
Get the maximum vertical displacement from the midplane
Definition at line 235 of file ScalingFFAMagnet.h.
References verticalExtent_m.
void ScalingFFAMagnet::initialise | ( | ) |
Initialise the ScalingFFAMagnet
Sets up the field expansion and the geometry; call after changing any field parameters
Definition at line 78 of file ScalingFFAMagnet.cpp.
References calculateDfCoefficients().
Referenced by initialise().
|
overridevirtual |
Initialise the ScalingFFAMagnet
bunch | the global bunch object |
startField | not used |
endField | not used |
Implements Component.
Definition at line 82 of file ScalingFFAMagnet.cpp.
References initialise(), and Component::RefPartBunch_m.
Referenced by clone(), and OpalScalingFFAMagnet::update().
|
private |
|
inline |
Set the maximum azimuthal displacement from \psi=0
Definition at line 231 of file ScalingFFAMagnet.h.
References azimuthalExtent_m.
Referenced by setupEndField(), and OpalScalingFFAMagnet::update().
|
inline |
Set the centre of the sector
Definition at line 169 of file ScalingFFAMagnet.h.
References centre_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set the dipole constant B_0
Definition at line 157 of file ScalingFFAMagnet.h.
References Bz_m.
Referenced by OpalScalingFFAMagnet::update().
void ScalingFFAMagnet::setEndField | ( | endfieldmodel::EndFieldModel * | endField | ) |
Set the fringe field
Definition at line 199 of file ScalingFFAMagnet.cpp.
References endField_m.
Referenced by OpalScalingFFAMagnet::OpalScalingFFAMagnet(), and setupEndField().
|
inline |
Set the end field name.
Called during parsing of the input file; OPAL looks for the endFieldName when setupEndField() is called.
Definition at line 259 of file ScalingFFAMagnet.h.
References endFieldName_m, and name.
Referenced by OpalScalingFFAMagnet::setupDefaultEndField(), and OpalScalingFFAMagnet::setupNamedEndField().
|
inline |
Set the field index k
Definition at line 151 of file ScalingFFAMagnet.h.
References k_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set the maximum power of y modelled in the off-midplane expansion;
Definition at line 191 of file ScalingFFAMagnet.h.
References maxOrder_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set the offset of the magnet end from the start
Definition at line 207 of file ScalingFFAMagnet.h.
References phiEnd_m.
Referenced by setupEndField(), and OpalScalingFFAMagnet::update().
|
inline |
Set the offset of the magnet centre from the start
Definition at line 199 of file ScalingFFAMagnet.h.
References phiStart_m.
Referenced by setupEndField(), and OpalScalingFFAMagnet::update().
|
inline |
Set the radius constant R_0
Definition at line 163 of file ScalingFFAMagnet.h.
References r0_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set the maximum radius
Definition at line 223 of file ScalingFFAMagnet.h.
References rMax_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set the maximum radius
Definition at line 215 of file ScalingFFAMagnet.h.
References rMin_m.
Referenced by OpalScalingFFAMagnet::update().
|
inline |
Set tan delta - delta is the spiral angle
Definition at line 145 of file ScalingFFAMagnet.h.
References tanDelta_m.
Referenced by OpalScalingFFAMagnet::update().
void ScalingFFAMagnet::setupEndField | ( | ) |
setupEndField does some end field and geometry set-up
This is normally called just before the magnet is placed; can only set up the end field after everything has been parsed from input (otherwise OPAL may not know about an end field model).
sets PhiStart, PhiEnd, AzimuthalExtent and the end field model itself.
Definition at line 209 of file ScalingFFAMagnet.cpp.
References azimuthalExtent_m, endfieldmodel::EndFieldModel::clone(), endFieldName_m, endfieldmodel::EndFieldModel::getCentreLength(), endfieldmodel::EndFieldModel::getEndFieldModel(), endfieldmodel::EndFieldModel::getEndLength(), getPhiStart(), getR0(), Units::m2mm, phiEnd_m, phiStart_m, planarArcGeometry_m, r0_m, endfieldmodel::EndFieldModel::rescale(), setAzimuthalExtent(), PlanarArcGeometry::setCurvature(), PlanarArcGeometry::setElementLength(), setEndField(), setPhiEnd(), and setPhiStart().
Referenced by ParallelCyclotronTracker::visitScalingFFAMagnet().
|
inline |
Set the maximum vertical displacement from the midplane
Definition at line 239 of file ScalingFFAMagnet.h.
References verticalExtent_m.
Referenced by OpalScalingFFAMagnet::update().
|
private |
Definition at line 287 of file ScalingFFAMagnet.h.
Referenced by getAzimuthalExtent(), setAzimuthalExtent(), and setupEndField().
|
private |
Definition at line 281 of file ScalingFFAMagnet.h.
Referenced by getDipoleConstant(), ScalingFFAMagnet(), and setDipoleConstant().
|
private |
Definition at line 289 of file ScalingFFAMagnet.h.
Referenced by getCentre(), getFieldValue(), and setCentre().
|
private |
Definition at line 293 of file ScalingFFAMagnet.h.
Referenced by calculateDfCoefficients(), and getDfCoefficients().
|
private |
Definition at line 276 of file ScalingFFAMagnet.h.
Referenced by getField().
|
private |
Definition at line 290 of file ScalingFFAMagnet.h.
Referenced by getEndField(), ScalingFFAMagnet(), setEndField(), and ~ScalingFFAMagnet().
|
private |
Definition at line 291 of file ScalingFFAMagnet.h.
Referenced by getEndFieldName(), setEndFieldName(), and setupEndField().
|
private |
Definition at line 292 of file ScalingFFAMagnet.h.
|
private |
Definition at line 280 of file ScalingFFAMagnet.h.
Referenced by calculateDfCoefficients(), getFieldIndex(), and setFieldIndex().
|
private |
Definition at line 278 of file ScalingFFAMagnet.h.
Referenced by calculateDfCoefficients(), getMaxOrder(), and setMaxOrder().
|
private |
Definition at line 286 of file ScalingFFAMagnet.h.
Referenced by getPhiEnd(), setPhiEnd(), and setupEndField().
|
private |
Definition at line 285 of file ScalingFFAMagnet.h.
Referenced by getPhiStart(), setPhiStart(), and setupEndField().
|
private |
Definition at line 275 of file ScalingFFAMagnet.h.
Referenced by getGeometry(), and setupEndField().
|
private |
Definition at line 282 of file ScalingFFAMagnet.h.
Referenced by getFieldValueCylindrical(), getR0(), ScalingFFAMagnet(), setR0(), and setupEndField().
|
private |
Definition at line 284 of file ScalingFFAMagnet.h.
Referenced by getFieldValueCylindrical(), getRMax(), and setRMax().
|
private |
Definition at line 283 of file ScalingFFAMagnet.h.
|
private |
Definition at line 279 of file ScalingFFAMagnet.h.
Referenced by calculateDfCoefficients(), getTanDelta(), and setTanDelta().
|
private |
Definition at line 288 of file ScalingFFAMagnet.h.
Referenced by getVerticalExtent(), and setVerticalExtent().