BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
element.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef ELEMENT_H
20#define ELEMENT_H
21
22#include <iomanip>
23#include <iostream>
24#include <list>
25#include <map>
26#include <string>
27
28#include "published.h"
29
30namespace GMAD
31{
32 enum class ElementType;
33
34 struct Parameters;
35
42 struct Element: public Published<Element>
43 {
45 std::string name;
46 std::string userTypeName;
47 std::string userParameters;
48
49 double l;
50 double scaling;
52 double ks;
53 // double k0; // for dipole field B or angle is used
54 double k1;
55 double k2;
56 double k3;
57 double k4;
58 double angle;
59 double B;
60 double e1;
61 double e2;
62 double fint;
63 double fintx;
64 double fintK2;
65 double fintxK2;
66 double hgap;
67 double h1;
68 double h2;
69 double kick;
70 double hkick;
71 double vkick;
72 std::list<double> knl;
73 std::list<double> ksl;
74 double gradient;
75 double E;
76 double frequency;
77 double phase;
78 double tOffset;
79 std::string fieldModulator;
80
82 double kick1;
83 double kick2;
84 double kick3;
85 double kick4;
86 double rmat11;
87 double rmat12;
88 double rmat13;
89 double rmat14;
90 double rmat21;
91 double rmat22;
92 double rmat23;
93 double rmat24;
94 double rmat31;
95 double rmat32;
96 double rmat33;
97 double rmat34;
98 double rmat41;
99 double rmat42;
100 double rmat43;
101 double rmat44;
103
104
107 double aper1;
108 double aper2;
109 double aper3;
110 double aper4;
111 std::string apertureType;
112 std::string beampipeMaterial;
113 std::string vacuumMaterial;
115
116 // magnet geometry
117 std::string magnetGeometryType;
118 double horizontalWidth; // formerly outerDiameter
119 bool yokeOnInside;
120 int hStyle;
121 double vhRatio;
124 double tilt;
125 double xsize, ysize;
126 double xsizeOut, ysizeOut;
127 double xsizeLeft, xsizeRight;
128 double jawTiltLeft, jawTiltRight;
129 double offsetX;
130 double offsetY;
131
132 // screen parameters
133 double tscint;
134 double twindow;
135 double tmount;
137 double screenXSize, screenYSize;
139 std::list<double> layerThicknesses;
140 std::list<std::string> layerMaterials;
141 std::list<int> layerIsSampler;
143
145 double screenPSize;
150 std::string windowmaterial;
151 std::string scintmaterial;
152 std::string mountmaterial;
154
156 double xdir;
157 double ydir;
158 double zdir;
160 double waveLength;
161 double phi, theta, psi;
162 double axisX, axisY, axisZ;
163 bool axisAngle;
164
172
179 double wireAngle;
181
187
189 std::string bias;
190 std::string biasMaterial;
191 std::string biasVacuum;
194 std::list<std::string> biasMaterialList;
196 std::list<std::string> biasVacuumList;
197
200
201 std::string samplerName;
202 std::string samplerType;
208
209 std::string region;
210 std::string fieldOuter;
211 std::string fieldVacuum;
212 std::string fieldAll;
213
214 std::string geometryFile;
217
219
220 std::string material;
221 std::string namedVacuumVolumes;
222 bool markAsCollimator;
223 std::string spec;
224 std::string cavityModel;
225 std::string cavityFieldType;
226
227 std::string dicomDataPath;
228 std::string dicomDataFile;
229
231 std::string colour;
232
233 std::string crystalLeft;
234 std::string crystalRight;
235 std::string crystalBoth;
236 double crystalAngleYAxisLeft;
237 double crystalAngleYAxisRight;
238
243
244 bool scalingFieldOuterSet;
245
247 std::list<Element>* lst;
248
250 void print(int ident=0) const;
251
253 void flush();
254
256 bool isSpecial() const;
259 double property_lookup(std::string property_name) const;
260
262 void setSamplerInfo(std::string samplerType,
263 std::string samplerName,
264 double samplerRadius,
265 int samplerParticleSetIDIn = -1);
266
268 void set(const Parameters& params);
269 void set(const Parameters& params,std::string nameIn, ElementType typeIn);
272 template <typename T>
273 void set_value(std::string property, T value);
274
276 Element();
277
278 private:
280 void PublishMembers();
282 std::map<std::string,std::string> alternativeNames;
283
284 protected:
286 std::string getPublishedName(const std::string& name) const;
287 };
288
289 template <typename T>
290 void Element::set_value(std::string property, T value)
291 {
292#ifdef BDSDEBUG
293 std::cout << "element> Setting value " << std::setw(25) << std::left << property << value << std::endl;
294#endif
295 // member method can throw runtime_error, catch and exit gracefully
296 try
297 {Published<Element>::set(this,property,value);}
298 catch(const std::runtime_error&)
299 {
300 std::cerr << "Error: element> unknown property \"" << property << "\" with value \"" << value << "\"" << std::endl;
301 exit(1);
302 }
303 }
304}
305
306#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(C *instance, const std::string &name, double value)
Definition: published.h:99
Parser namespace for GMAD language. Combination of Geant4 and MAD.
ElementType
types of elements
Definition: elementtype.h:28
Element class.
Definition: element.h:43
double property_lookup(std::string property_name) const
Definition: element.cc:630
double hkick
fractional delta px for hkicker
Definition: element.h:70
std::string dicomDataFile
for CT, file for DICOM construction data
Definition: element.h:228
std::string spec
Arbitrary specification to pass to beamline builder.
Definition: element.h:223
void print(int ident=0) const
print method
Definition: element.cc:281
std::string biasMaterial
temporary string for bias setting
Definition: element.h:190
double twindow
thickness of window
Definition: element.h:134
double B
magnetic field
Definition: element.h:59
double aper4
beampipe information, new aperture model
Definition: element.h:110
double hgap
half distance of pole separation for purposes of fringe fields - 'half gap'
Definition: element.h:66
void set(const Parameters &params)
set method from Parameters structure
Definition: element.cc:658
void PublishMembers()
publish members so these can be looked up from parser
Definition: element.cc:53
std::string beampipeMaterial
beampipe information, new aperture model
Definition: element.h:112
std::string samplerType
element has a sampler of this type (default "none")
Definition: element.h:202
double rmat33
rmatrix elements, only 4x4
Definition: element.h:96
double rmat11
rmatrix elements, only 4x4
Definition: element.h:86
double rmat43
rmatrix elements, only 4x4
Definition: element.h:100
std::list< std::string > layerMaterials
for screen
Definition: element.h:140
std::string userParameters
String for passing user parameters through.
Definition: element.h:47
double scaling
Overall scaling of field strength.
Definition: element.h:50
std::string cavityFieldType
Name for type of field to use in a cavity.
Definition: element.h:225
double windowScreenGap
air gap between window and screen
Definition: element.h:136
double gradient
for rf cavities in V / m
Definition: element.h:74
double degraderOffset
for degrader
Definition: element.h:170
bool isSpecial() const
check if element is of a special type
Definition: element.cc:273
double wireAngle
for wirescanner
Definition: element.h:179
double aper2
beampipe information, new aperture model
Definition: element.h:108
double fintx
fringe field integral at the dipole exit
Definition: element.h:63
double kick4
rmatrix elements, only 4x4
Definition: element.h:85
std::list< Element > * lst
in case the element is a list itself (line)
Definition: element.h:247
double k2
sextupole
Definition: element.h:55
double rmat42
rmatrix elements, only 4x4
Definition: element.h:99
double aper1
beampipe information, new aperture model
Definition: element.h:107
double rmat41
rmatrix elements, only 4x4
Definition: element.h:98
double h2
output pole face curvature for bends
Definition: element.h:68
double awakeMagnetOffsetX
for AWAKE spectrometer
Definition: element.h:149
double zdir
for 3d transform and laser
Definition: element.h:158
double h1
input pole face curvature for bends
Definition: element.h:67
std::string namedVacuumVolumes
For imported geometry - identify vacuum volumes.
Definition: element.h:221
bool stripOuterVolume
For Element. Make it an assembly.
Definition: element.h:215
double screenPSize
for AWAKE spectrometer
Definition: element.h:145
double xdir
for 3d transform and laser
Definition: element.h:156
double rmat34
rmatrix elements, only 4x4
Definition: element.h:97
double psi
for 3d transforms
Definition: element.h:161
double wireOffsetX
for wirescanner
Definition: element.h:176
double rmat31
rmatrix elements, only 4x4
Definition: element.h:94
double wedgeLength
for degrader
Definition: element.h:167
double vhRatio
ratio of vertial to horizontal for some magnets
Definition: element.h:121
double waveLength
for laser wire and 3d transforms
Definition: element.h:160
double rmat22
rmatrix elements, only 4x4
Definition: element.h:91
double fintxK2
second fringe field integral at the dipole exit - for TRANSPORT matching
Definition: element.h:65
std::string userTypeName
User component element type name.
Definition: element.h:46
double wireOffsetY
for wirescanner
Definition: element.h:177
double kick3
rmatrix elements, only 4x4
Definition: element.h:84
double rmat24
rmatrix elements, only 4x4
Definition: element.h:93
double tOffset
time offset used for phase calculation (ns)
Definition: element.h:78
std::list< std::string > biasMaterialList
Definition: element.h:194
double fint
fringe field integral at the dipole entrance
Definition: element.h:62
double xsizeRight
individual collimator jaw half widths
Definition: element.h:127
std::string bias
temporary string for bias setting
Definition: element.h:189
double coilWidthFraction
Fraction of available h space the coil will take up.
Definition: element.h:122
double rmat44
rmatrix elements, only 4x4
Definition: element.h:101
double ks
solenoid
Definition: element.h:52
std::string fieldAll
Field for everything.
Definition: element.h:212
double jawTiltRight
jaw collimator jaw tilts (angle in x-z plane)
Definition: element.h:128
std::string region
region with range cuts
Definition: element.h:209
double wireDiameter
for wirescanner
Definition: element.h:174
int samplerParticleSetID
Definition: element.h:207
double tmount
thickness of the screen mount
Definition: element.h:135
double wireOffsetZ
for wirescanner
Definition: element.h:178
std::list< double > ksl
skew multipole expansion
Definition: element.h:73
int numberWedges
for degrader
Definition: element.h:166
double kick1
rmatrix elements, only 4x4
Definition: element.h:82
std::string getPublishedName(const std::string &name) const
returns 'official' member name for property
Definition: element.cc:264
std::list< double > knl
multipole expansion coefficients
Definition: element.h:72
std::string windowmaterial
for AWAKE spectrometer
Definition: element.h:150
double e2
output pole face rotation for bends
Definition: element.h:61
double phase
phase of rf cavity (rad)
Definition: element.h:77
double ysizeOut
collimator aperture or laser spotsize for laser
Definition: element.h:126
std::string fieldVacuum
Vacuum field.
Definition: element.h:211
bool autoColour
Automagically colour the external geometry.
Definition: element.h:216
double angle
bending angle
Definition: element.h:58
void set_value(std::string property, T value)
Definition: element.h:290
int hStyle
-1 = unset; 0 = false (ie c style); 1 = true, use hstyle
Definition: element.h:120
std::string geometryFile
For Element. File for external geometry.
Definition: element.h:214
std::string vacuumMaterial
beampipe information, new aperture model
Definition: element.h:113
double vkick
fractional delta py for vkicker
Definition: element.h:71
double E
voltage for rf cavities in V that will be assumed over length l
Definition: element.h:75
double coilHeightFraction
Fraction of availalbe v space the coil will take up.
Definition: element.h:123
std::list< int > layerIsSampler
for screen
Definition: element.h:141
bool elementLengthIsArcLength
For Element. Treat the length as arc length, if not chord.
Definition: element.h:218
double screenYSize
Definition: element.h:137
double offsetX
offset X
Definition: element.h:129
double screenEndZ
for AWAKE spectrometer
Definition: element.h:146
double ysize
collimator aperture or laser spotsize for laser
Definition: element.h:125
double rmat23
rmatrix elements, only 4x4
Definition: element.h:92
Element()
constructor
Definition: element.cc:45
std::string colour
Override colour for certain items.
Definition: element.h:231
double rmat13
rmatrix elements, only 4x4
Definition: element.h:88
double tilt
tilt
Definition: element.h:124
double materialThickness
for degrader
Definition: element.h:169
void flush()
flush method
Definition: element.cc:439
double l
length in metres
Definition: element.h:49
double kick
fractional delta p for either h or v kicker
Definition: element.h:69
double rmat14
rmatrix elements, only 4x4
Definition: element.h:89
double beampipeThickness
beampipe information, new aperture model
Definition: element.h:106
std::string dicomDataPath
for CT, file for DICOM construction data
Definition: element.h:227
double minimumKineticEnergy
minimum kinetic energy for user limits - respected on element by element basis
Definition: element.h:199
std::string scintmaterial
for AWAKE spectrometer
Definition: element.h:151
double ydir
for 3d transform and laser
Definition: element.h:157
double undulatorMagnetHeight
for undulator
Definition: element.h:185
void setSamplerInfo(std::string samplerType, std::string samplerName, double samplerRadius, int samplerParticleSetIDIn=-1)
set sampler info
Definition: element.cc:703
std::string cavityModel
Name of geometry model object for rfconstantinz cavities.
Definition: element.h:224
double e1
input pole face rotation for bends
Definition: element.h:60
double k1
quadrupole
Definition: element.h:54
std::string fieldOuter
Outer field.
Definition: element.h:210
double undulatorPeriod
for undulator
Definition: element.h:183
std::string biasVacuum
temporary string for bias setting
Definition: element.h:191
double wireLength
for wirescanner
Definition: element.h:175
std::map< std::string, std::string > alternativeNames
map that translates between alternative parser names for members, could be made static
Definition: element.h:282
double undulatorGap
for undulator
Definition: element.h:184
double poleStartZ
for AWAKE spectrometer
Definition: element.h:147
double fintK2
second fringe field integral at the dipole entrance - for TRANSPORT matching
Definition: element.h:64
bool angleSet
Definition: element.h:242
std::string mountmaterial
for AWAKE spectrometer
Definition: element.h:152
double k4
decapole
Definition: element.h:57
double samplerRadius
Definition: element.h:203
double aper3
beampipe information, new aperture model
Definition: element.h:109
ElementType type
element enum
Definition: element.h:44
std::list< std::string > biasVacuumList
physics biasing list for the vacuum
Definition: element.h:196
double offsetY
offset Y
Definition: element.h:130
std::list< double > layerThicknesses
for screen
Definition: element.h:139
double scalingFieldOuter
Extra arbitrary scaling for outer field - compounded with 'scaling'.
Definition: element.h:51
std::string samplerName
name of sampler (default empty)
Definition: element.h:201
double degraderHeight
for degrader
Definition: element.h:168
double tscint
thickness of scintillating part of screen
Definition: element.h:133
double k3
octupole
Definition: element.h:56
double screenWidth
for AWAKE spectrometer
Definition: element.h:148
double frequency
frequency for rf cavity in Hz
Definition: element.h:76
double kick2
rmatrix elements, only 4x4
Definition: element.h:83
double rmat12
rmatrix elements, only 4x4
Definition: element.h:87
std::string apertureType
beampipe information, new aperture model
Definition: element.h:111
double rmat21
rmatrix elements, only 4x4
Definition: element.h:90
double rmat32
rmatrix elements, only 4x4
Definition: element.h:95
Parameters - Element class with booleans.
Definition: parameters.h:44