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 - 2024.
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 <exception>
23#include <iomanip>
24#include <iostream>
25#include <list>
26#include <map>
27#include <sstream>
28#include <string>
29
30#include "published.h"
31
32namespace GMAD
33{
34 enum class ElementType;
35
36 struct Parameters;
37
44 struct Element: public Published<Element>
45 {
47 std::string name;
48 std::string userTypeName;
49 std::string userParameters;
50
51 double l;
52 double scaling;
54 double ks;
55 // double k0; // for dipole field B or angle is used
56 double k1;
57 double k2;
58 double k3;
59 double k4;
60 double angle;
61 double B;
62 double e1;
63 double e2;
64 double fint;
65 double fintx;
66 double fintK2;
67 double fintxK2;
68 double hgap;
69 double h1;
70 double h2;
71 double kick;
72 double hkick;
73 double vkick;
74 std::list<double> knl;
75 std::list<double> ksl;
76 double gradient;
77 double E;
78 double frequency;
79 double phase;
80 double tOffset;
81 std::string fieldModulator;
82 double kg;
83
85 double kick1;
86 double kick2;
87 double kick3;
88 double kick4;
89 double rmat11;
90 double rmat12;
91 double rmat13;
92 double rmat14;
93 double rmat21;
94 double rmat22;
95 double rmat23;
96 double rmat24;
97 double rmat31;
98 double rmat32;
99 double rmat33;
100 double rmat34;
101 double rmat41;
102 double rmat42;
103 double rmat43;
104 double rmat44;
106
107
110 double aper1;
111 double aper2;
112 double aper3;
113 double aper4;
114 std::string apertureType;
115 std::string beampipeMaterial;
116 std::string vacuumMaterial;
118
119 // magnet geometry
120 std::string magnetGeometryType;
121 double horizontalWidth; // formerly outerDiameter
122 bool yokeOnInside;
123 int hStyle;
124 double vhRatio;
127 double tilt;
128 double xsize, ysize;
129 double xsizeOut, ysizeOut;
130 double xsizeLeft, xsizeRight;
131 double jawTiltLeft, jawTiltRight;
132 double offsetX;
133 double offsetY;
134
135 // PWFA
136 double xsize2, ysize2;
137 double offsetX2, offsetY2;
138 double tilt2;
139 std::string outerShape;
140
141 // screen parameters
142 double tscint;
143 double twindow;
144 double tmount;
146 double screenXSize, screenYSize;
148 std::list<double> layerThicknesses;
149 std::list<std::string> layerMaterials;
150 std::list<int> layerIsSampler;
152
154 double screenPSize;
159 std::string windowmaterial;
160 std::string scintmaterial;
161 std::string mountmaterial;
163
165 double xdir;
166 double ydir;
167 double zdir;
169 double waveLength;
170 double phi, theta, psi;
171 double axisX, axisY, axisZ;
172 bool axisAngle;
173
181
183 std::string laserBeam;
190
193 double wireLength;
194 double wireOffsetX;
195 double wireOffsetY;
196 double wireOffsetZ;
197 double wireAngle;
199
205
214
215
218 std::string tipMaterial;
220
222 std::string bias;
223 std::string biasMaterial;
224 std::string biasVacuum;
225 std::string biasMaterialLV;
228 std::list<std::string> biasMaterialList;
230 std::list<std::string> biasVacuumList;
232 std::list<std::string> biasMaterialLVList;
233
236
237 std::string samplerName;
238 std::string samplerType;
244
245 std::string region;
246 std::string fieldOuter;
247 std::string fieldVacuum;
248 std::string fieldAll;
249
250 std::string geometryFile;
253
255
256 std::string material;
257 std::string namedVacuumVolumes;
258 bool markAsCollimator;
259 std::string spec;
260 std::string cavityModel;
261 std::string cavityFieldType;
262
263 std::string dicomDataPath;
264 std::string dicomDataFile;
265
267 std::string colour;
268
269 std::string crystalLeft;
270 std::string crystalRight;
271 std::string crystalBoth;
272 double crystalAngleYAxisLeft;
273 double crystalAngleYAxisRight;
274
276 std::string coolingDefinition;
277
282
283 bool scalingFieldOuterSet;
284
286 std::list<Element>* lst;
287
289 void print(int ident=0) const;
290
292 void flush();
293
295 bool isSpecial() const;
298 double property_lookup(std::string property_name) const;
299
301 void setSamplerInfo(std::string samplerType,
302 std::string samplerName,
303 double samplerRadius,
304 int samplerParticleSetIDIn = -1);
305
307 void set(const Parameters& params);
308 void set(const Parameters& params,std::string nameIn, ElementType typeIn);
311 template <typename T>
312 void set_value(std::string property, T value, bool exceptionSafe = false);
313
315 Element();
316
317 private:
319 void PublishMembers();
321 std::map<std::string,std::string> alternativeNames;
322
323 protected:
325 std::string getPublishedName(const std::string& name) const;
326 };
327
328 template <typename T>
329 void Element::set_value(std::string property, T value, bool exceptionSafe)
330 {
331#ifdef BDSDEBUG
332 std::cout << "element> Setting value " << std::setw(25) << std::left << property << value << std::endl;
333#endif
334 // member method can throw runtime_error, catch and exit gracefully
335 try
336 {Published<Element>::set(this, property, value);}
337 catch(const std::runtime_error&)
338 {
339 std::stringstream ss;
340 ss << "Error: element> unknown property \"" << property
341 << "\" with value \"" << value << "\" in definition \"" << this->name << "\"";
342 if (!exceptionSafe)
343 {throw std::invalid_argument(ss.str());}
344 else
345 {std::cerr << ss.str() << std::endl;}
346 }
347 }
348}
349
350#endif
Class that provides introspection to its members.
Definition published.h:49
void set(C *instance, const std::string &name, double value)
Definition published.h:101
Parser namespace for GMAD language. Combination of Geant4 and MAD.
ElementType
types of elements
Definition elementtype.h:28
Element class.
Definition element.h:45
double property_lookup(std::string property_name) const
Definition element.cc:720
double hkick
fractional delta px for hkicker
Definition element.h:72
std::string dicomDataFile
for CT, file for DICOM construction data
Definition element.h:264
std::string spec
Arbitrary specification to pass to beamline builder.
Definition element.h:259
void print(int ident=0) const
print method
Definition element.cc:316
std::string biasMaterial
temporary string for bias setting
Definition element.h:223
double twindow
thickness of window
Definition element.h:143
double B
magnetic field
Definition element.h:61
double aper4
beampipe information, new aperture model
Definition element.h:113
double hgap
half distance of pole separation for purposes of fringe fields - 'half gap'
Definition element.h:68
void set(const Parameters &params)
set method from Parameters structure
Definition element.cc:748
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:115
std::string samplerType
element has a sampler of this type (default "none")
Definition element.h:238
double ysize2
size of the beam mask second aperture
Definition element.h:136
double laserOffsetTheta
for laserwire
Definition element.h:184
double rmat33
rmatrix elements, only 4x4
Definition element.h:99
double rmat11
rmatrix elements, only 4x4
Definition element.h:89
double rmat43
rmatrix elements, only 4x4
Definition element.h:103
double laserOffsetPhi
for laserwire
Definition element.h:185
std::list< std::string > layerMaterials
for screen
Definition element.h:149
std::string userParameters
String for passing user parameters through.
Definition element.h:49
double scaling
Overall scaling of field strength.
Definition element.h:52
std::string cavityFieldType
Name for type of field to use in a cavity.
Definition element.h:261
double windowScreenGap
air gap between window and screen
Definition element.h:145
std::string tipMaterial
tip material
Definition element.h:218
double gradient
for rf cavities in V / m
Definition element.h:76
double degraderOffset
for degrader
Definition element.h:179
bool isSpecial() const
check if element is of a special type
Definition element.cc:308
double aper2
beampipe information, new aperture model
Definition element.h:111
double anodeLength
for gabor lens
Definition element.h:207
double fintx
fringe field integral at the dipole exit
Definition element.h:65
double kick4
rmatrix elements, only 4x4
Definition element.h:88
std::list< Element > * lst
in case the element is a list itself (line)
Definition element.h:286
double k2
sextupole
Definition element.h:57
double rmat42
rmatrix elements, only 4x4
Definition element.h:102
double aper1
beampipe information, new aperture model
Definition element.h:110
double rmat41
rmatrix elements, only 4x4
Definition element.h:101
double h2
output pole face curvature for bends
Definition element.h:70
std::string outerShape
'rectangular' or 'circular'. used in gascap and bmcol
Definition element.h:139
double laserOffsetY
for laserwire
Definition element.h:187
double awakeMagnetOffsetX
for AWAKE spectrometer
Definition element.h:158
double zdir
for 3d transform and laser
Definition element.h:167
double h1
input pole face curvature for bends
Definition element.h:69
std::string namedVacuumVolumes
For imported geometry - identify vacuum volumes.
Definition element.h:257
std::string biasMaterialLV
temporary string for bias setting
Definition element.h:225
double anodeThickness
for gabor lens
Definition element.h:209
bool stripOuterVolume
For Element. Make it an assembly.
Definition element.h:251
double screenPSize
for AWAKE spectrometer
Definition element.h:154
double xdir
for 3d transform and laser
Definition element.h:165
double rmat34
rmatrix elements, only 4x4
Definition element.h:100
double psi
for 3d transforms
Definition element.h:170
double rmat31
rmatrix elements, only 4x4
Definition element.h:97
double wedgeLength
for degrader
Definition element.h:176
double vhRatio
ratio of vertial to horizontal for some magnets
Definition element.h:124
double waveLength
for laser wire and 3d transforms
Definition element.h:169
double rmat22
rmatrix elements, only 4x4
Definition element.h:94
double fintxK2
second fringe field integral at the dipole exit - for TRANSPORT matching
Definition element.h:67
std::string userTypeName
User component element type name.
Definition element.h:48
double offsetY2
offset of the beam mask second aperture
Definition element.h:137
double kick3
rmatrix elements, only 4x4
Definition element.h:87
double rmat24
rmatrix elements, only 4x4
Definition element.h:96
double tOffset
time offset used for phase calculation (ns)
Definition element.h:80
std::list< std::string > biasMaterialList
Definition element.h:228
double fint
fringe field integral at the dipole entrance
Definition element.h:64
double xsizeRight
individual collimator jaw half widths
Definition element.h:130
std::string bias
temporary string for bias setting
Definition element.h:222
double coilWidthFraction
Fraction of available h space the coil will take up.
Definition element.h:125
double rmat44
rmatrix elements, only 4x4
Definition element.h:104
double ks
solenoid
Definition element.h:54
std::string fieldAll
Field for everything.
Definition element.h:248
double electrodeRadius
for gabor lens
Definition element.h:211
double jawTiltRight
jaw collimator jaw tilts (angle in x-z plane)
Definition element.h:131
std::string region
region with range cuts
Definition element.h:245
double wireDiameter
@[ for wirescanner
Definition element.h:192
int samplerParticleSetID
Definition element.h:243
double tmount
thickness of the screen mount
Definition element.h:144
std::list< double > ksl
skew multipole expansion
Definition element.h:75
int numberWedges
for degrader
Definition element.h:175
double kick1
rmatrix elements, only 4x4
Definition element.h:85
std::list< std::string > biasMaterialLVList
physics biasing list for specific LVs
Definition element.h:232
std::string getPublishedName(const std::string &name) const
returns 'official' member name for property
Definition element.cc:299
std::list< double > knl
multipole expansion coefficients
Definition element.h:74
std::string windowmaterial
for AWAKE spectrometer
Definition element.h:159
double e2
output pole face rotation for bends
Definition element.h:63
double phase
phase of rf cavity (rad)
Definition element.h:79
double ysizeOut
collimator aperture or laser spotsize for laser
Definition element.h:129
std::string fieldVacuum
Vacuum field.
Definition element.h:247
bool autoColour
Automagically colour the external geometry.
Definition element.h:252
double angle
bending angle
Definition element.h:60
double electrodeThickness
for gabor lens
Definition element.h:212
int hStyle
-1 = unset; 0 = false (ie c style); 1 = true, use hstyle
Definition element.h:123
std::string geometryFile
For Element. File for external geometry.
Definition element.h:250
std::string vacuumMaterial
beampipe information, new aperture model
Definition element.h:116
double vkick
fractional delta py for vkicker
Definition element.h:73
double laserOffsetZ
for laserwire
Definition element.h:188
double E
voltage for rf cavities in V that will be assumed over length l
Definition element.h:77
double coilHeightFraction
Fraction of availalbe v space the coil will take up.
Definition element.h:126
std::list< int > layerIsSampler
for screen
Definition element.h:150
double laserOffsetX
for laserwire
Definition element.h:186
bool elementLengthIsArcLength
For Element. Treat the length as arc length, if not chord.
Definition element.h:254
double screenYSize
Definition element.h:146
double offsetX
offset X
Definition element.h:132
double screenEndZ
for AWAKE spectrometer
Definition element.h:155
double ysize
collimator aperture or laser spotsize for laser
Definition element.h:128
std::string coolingDefinition
For muon cooler.
Definition element.h:276
double rmat23
rmatrix elements, only 4x4
Definition element.h:95
Element()
constructor
Definition element.cc:45
std::string colour
Override colour for certain items.
Definition element.h:267
double rmat13
rmatrix elements, only 4x4
Definition element.h:91
double anodeRadius
for gabor lens
Definition element.h:208
double tilt
tilt
Definition element.h:127
double materialThickness
for degrader
Definition element.h:178
void flush()
flush method
Definition element.cc:499
double l
length in metres
Definition element.h:51
double kick
fractional delta p for either h or v kicker
Definition element.h:71
double rmat14
rmatrix elements, only 4x4
Definition element.h:92
double beampipeThickness
beampipe information, new aperture model
Definition element.h:109
std::string dicomDataPath
for CT, file for DICOM construction data
Definition element.h:263
double minimumKineticEnergy
minimum kinetic energy for user limits - respected on element by element basis
Definition element.h:235
std::string scintmaterial
for AWAKE spectrometer
Definition element.h:160
double ydir
for 3d transform and laser
Definition element.h:166
double undulatorMagnetHeight
for undulator
Definition element.h:203
void setSamplerInfo(std::string samplerType, std::string samplerName, double samplerRadius, int samplerParticleSetIDIn=-1)
set sampler info
Definition element.cc:800
double tipThickness
for jaw collimator with tip
Definition element.h:217
std::string cavityModel
Name of geometry model object for rfconstantinz cavities.
Definition element.h:260
double e1
input pole face rotation for bends
Definition element.h:62
double k1
quadrupole
Definition element.h:56
std::string fieldOuter
Outer field.
Definition element.h:246
std::string laserBeam
for laserwire
Definition element.h:183
double undulatorPeriod
for undulator
Definition element.h:201
std::string biasVacuum
temporary string for bias setting
Definition element.h:224
double electrodeLength
for gabor lens
Definition element.h:210
std::map< std::string, std::string > alternativeNames
map that translates between alternative parser names for members, could be made static
Definition element.h:321
double tilt2
tilt of the beam mask second aperture
Definition element.h:138
void set_value(std::string property, T value, bool exceptionSafe=false)
Definition element.h:329
double undulatorGap
for undulator
Definition element.h:202
double poleStartZ
for AWAKE spectrometer
Definition element.h:156
double fintK2
second fringe field integral at the dipole entrance - for TRANSPORT matching
Definition element.h:66
bool angleSet
Definition element.h:281
std::string mountmaterial
for AWAKE spectrometer
Definition element.h:161
double k4
decapole
Definition element.h:59
double samplerRadius
Definition element.h:239
double aper3
beampipe information, new aperture model
Definition element.h:112
ElementType type
element enum
Definition element.h:46
std::list< std::string > biasVacuumList
physics biasing list for the vacuum
Definition element.h:230
double offsetY
offset Y
Definition element.h:133
std::list< double > layerThicknesses
for screen
Definition element.h:148
double scalingFieldOuter
Extra arbitrary scaling for outer field - compounded with 'scaling'.
Definition element.h:53
double kg
gabor lens
Definition element.h:82
std::string samplerName
name of sampler (default empty)
Definition element.h:237
double degraderHeight
for degrader
Definition element.h:177
double tscint
thickness of scintillating part of screen
Definition element.h:142
double k3
octupole
Definition element.h:58
double screenWidth
for AWAKE spectrometer
Definition element.h:157
double frequency
frequency for rf cavity in Hz
Definition element.h:78
double kick2
rmatrix elements, only 4x4
Definition element.h:86
double rmat12
rmatrix elements, only 4x4
Definition element.h:90
std::string apertureType
beampipe information, new aperture model
Definition element.h:114
double rmat21
rmatrix elements, only 4x4
Definition element.h:93
double rmat32
rmatrix elements, only 4x4
Definition element.h:98
Parameters - Element class with booleans.
Definition parameters.h:44