OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Solenoid.h
Go to the documentation of this file.
1#ifndef OPALX_Solenoid_HH
2#define OPALX_Solenoid_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: Solenoid.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: Solenoid
13// Defines the abstract interface for a solenoid magnet.
14//
15// ------------------------------------------------------------------------
16// Class category: AbsBeamline
17// ------------------------------------------------------------------------
18//
19// $Date: 20.1.2026 $
20// $Author: PSI $
21//
22// ------------------------------------------------------------------------
23
26
27class Fieldmap;
28
33class Solenoid : public Component {
34public:
35 /* ============================== Constructors ============================== */
36 explicit Solenoid(const std::string& name);
37 Solenoid();
38 Solenoid(const Solenoid&);
39 virtual ~Solenoid();
40 /* ========================================================================== */
41 /* ============================== Apply Functions =========================== */
47 virtual bool apply(const std::shared_ptr<ParticleContainer_t>& pc) override;
48
59 virtual bool apply(
60 const size_t& i, const double& t, Vector_t<double, 3>& E,
61 Vector_t<double, 3>& B) override;
62
74 virtual bool apply(
75 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
77
89 virtual bool applyToReferenceParticle(
90 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
92 /* ========================================================================== */
93 /* ============================== Functions ================================= */
95 virtual void accept(BeamlineVisitor&) const override;
96
98 virtual double getBz() const = 0;
99
101 void setKS(double ks);
102
104 void setDKS(double ks);
105
113 virtual void initialise(PartBunch_t* bunch, double& startField, double& endField) override;
114
116 virtual void finalise() override;
117
118 virtual bool bends() const override;
119
121 virtual void goOnline(const double& kineticEnergy) override;
122
124 virtual void goOffline() override;
125
127 void setFieldMapFN(std::string fn);
128
129 void setFast(bool fast);
130
131 bool getFast() const;
132
133 virtual ElementType getType() const override;
134
144 virtual void getFieldExtend(double& zBegin, double& zEnd) const override;
145
155 virtual void getElementDimensions(double& zBegin, double& zEnd) const override;
156
169 bool getSupportEnvelope(double& horizontalRadius, double& verticalRadius) const;
170
172 virtual bool isInside(const Vector_t<double, 3>& r) const override;
173
175 virtual CoordinateSystemTrafo getEdgeToBegin() const override;
176
178 virtual CoordinateSystemTrafo getEdgeToEnd() const override;
179
180private:
181 /* ========================================================================== */
182 /* ============================== Variables ================================= */
183
185 std::string filename_m;
186
189
191 double scale_m;
192
195
198
201
203 bool fast_m;
204
206 void operator=(const Solenoid&);
207};
208
215 CoordinateSystemTrafo ret(Vector_t<double, 3>(0, 0, 0), Quaternion(1, 0, 0, 0));
216 return ret;
217}
218
226 Vector_t<double, 3>(0, 0, getElementLength()), Quaternion(1, 0, 0, 0));
227 return ret;
228}
229#endif // OPALX_Solenoid_HH
Defines the abstract interface for a single beamline component in the accelerator model.
ippl::Vector< T, Dim > Vector_t
ElementType
Definition ElementBase.h:94
Rigid spatial transform between a parent frame and a local frame.
virtual double getElementLength() const
Get design length.
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...
Definition Fieldmap.h:62
Quaternion storage and rotation algebra used by OPALX geometry code.
Abstract class for a solenoid magnet.
Definition Solenoid.h:33
virtual double getBz() const =0
Get solenoid field Bz.
virtual CoordinateSystemTrafo getEdgeToBegin() const override
Get the coordinate transformation to the begin of the element.
Definition Solenoid.h:214
double scaleError_m
Scale error multiplier.
Definition Solenoid.h:194
void setFast(bool fast)
Set the fast flag.
Definition Solenoid.cpp:216
double endField_m
End point of the field support in the local chart.
Definition Solenoid.h:200
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
initialise the solenoid element
Definition Solenoid.cpp:169
virtual void getElementDimensions(double &zBegin, double &zEnd) const override
Return the nominal body extent of the solenoid.
Definition Solenoid.cpp:243
virtual void getFieldExtend(double &zBegin, double &zEnd) const override
Return the local field-support interval of the solenoid.
Definition Solenoid.cpp:224
double startField_m
Starting point of the field.
Definition Solenoid.h:197
virtual void goOffline() override
Free field map and go offline.
Definition Solenoid.cpp:207
virtual ~Solenoid()
Definition Solenoid.cpp:56
virtual void goOnline(const double &kineticEnergy) override
Load field map and go online.
Definition Solenoid.cpp:201
virtual void finalise() override
Definition Solenoid.cpp:196
bool fast_m
Fast tracking flag.
Definition Solenoid.h:203
virtual CoordinateSystemTrafo getEdgeToEnd() const override
Get the coordinate transformation to the end of the element.
Definition Solenoid.h:224
bool getFast() const
Get the fast flag.
Definition Solenoid.cpp:219
virtual bool bends() const override
Definition Solenoid.cpp:198
void setDKS(double ks)
Set the strength scaling error dks.
Definition Solenoid.cpp:159
Fieldmap * fieldmap_m
Fieldmap pointer.
Definition Solenoid.h:188
virtual ElementType getType() const override
Get the element type.
Definition Solenoid.cpp:231
std::string filename_m
Name of the field map file.
Definition Solenoid.h:185
virtual bool isInside(const Vector_t< double, 3 > &r) const override
Check if position r is inside the field map.
Definition Solenoid.cpp:236
bool getSupportEnvelope(double &horizontalRadius, double &verticalRadius) const
Get a finite transverse support envelope for placement/export.
Definition Solenoid.cpp:248
virtual bool applyToReferenceParticle(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
Apply to reference particle with position R and momemtum P.
Definition Solenoid.cpp:136
void setKS(double ks)
Set the strength scaling factor ks.
Definition Solenoid.cpp:156
virtual bool apply(const std::shared_ptr< ParticleContainer_t > &pc) override
apply the solenoid field to all particles in the bunch
Definition Solenoid.cpp:67
void setFieldMapFN(std::string fn)
Assign the field filename.
Definition Solenoid.cpp:213
void operator=(const Solenoid &)
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Solenoid.
Definition Solenoid.cpp:153
double scale_m
Scale multiplier.
Definition Solenoid.h:191