BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIntegratorSet.cc
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#include "BDSDebug.hh"
20#include "BDSIntegratorSet.hh"
21#include "BDSIntegratorSetType.hh"
22#include "BDSIntegratorType.hh"
23
24#include "globals.hh" // geant4 types / globals
25#include "G4Version.hh"
26
27BDSIntegratorSet::BDSIntegratorSet(BDSIntegratorType solenoidIn,
28 BDSIntegratorType dipoleIn,
29 BDSIntegratorType dipoleQuadrupoleIn,
30 BDSIntegratorType quadrupoleIn,
31 BDSIntegratorType sextupoleIn,
32 BDSIntegratorType octupoleIn,
33 BDSIntegratorType decapoleIn,
34 BDSIntegratorType multipoleThickIn,
35 BDSIntegratorType muonSpoilerIn,
36 BDSIntegratorType rfpillboxIn,
37 BDSIntegratorType rfconstantinxIn,
38 BDSIntegratorType rfconstantinyIn,
39 BDSIntegratorType rfconstantinzIn,
40 BDSIntegratorType generalIn,
41 BDSIntegratorType skewQuadrupoleIn,
42 BDSIntegratorType skewSextupoleIn,
43 BDSIntegratorType skewOctupoleIn,
44 BDSIntegratorType skewDecapoleIn,
45 BDSIntegratorType dipoleFringeIn,
46 BDSIntegratorType multipoleThinIn,
47 BDSIntegratorType multipoleOuterIn,
48 BDSIntegratorType rmatrixThinIn,
49 BDSIntegratorType parallelTransporterIn,
50 BDSIntegratorType undulatorIn,
51 BDSIntegratorType cavityFringeIn,
52 BDSIntegratorType gaborLensIn):
53 solenoid(solenoidIn),
54 dipole(dipoleIn),
55 dipoleQuadrupole(dipoleQuadrupoleIn),
56 quadrupole(quadrupoleIn),
57 sextupole(sextupoleIn),
58 octupole(octupoleIn),
59 decapole(decapoleIn),
60 multipoleThick(multipoleThickIn),
61 muonSpoiler(muonSpoilerIn),
62 rfpillbox(rfpillboxIn),
63 rfconstantinx(rfconstantinxIn),
64 rfconstantiny(rfconstantinyIn),
65 rfconstantinz(rfconstantinzIn),
66 general(generalIn),
67 skewQuadrupole(skewQuadrupoleIn),
68 skewSextupole(skewSextupoleIn),
69 skewOctupole(skewOctupoleIn),
70 skewDecapole(skewDecapoleIn),
71 dipoleFringe(dipoleFringeIn),
72 multipoleThin(multipoleThinIn),
73 multipoleOuter(multipoleOuterIn),
74 rmatrixThin(rmatrixThinIn),
75 parallelTransporter(parallelTransporterIn),
76 undulator(undulatorIn),
77 cavityFringe(cavityFringeIn),
78 gaborLens(gaborLensIn)
79{
80 isMatrix = false; //default
81 // use dipolematrix integrator to check if matrix style as it is the
82 // only integrator exclusive to matrix style integrator sets
83 if (dipoleIn == BDSIntegratorType::dipolematrix)
84 {isMatrix = true;}
85}
86
87namespace BDS
88{
89 const BDSIntegratorSet* integratorsBDSIMOne =
90 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
91 BDSIntegratorType::dipolerodrigues, // dipole
92 BDSIntegratorType::dipolematrix, // dipole quadrupole
93 BDSIntegratorType::quadrupole, // quadrupole
94 BDSIntegratorType::sextupole, // sextupole
95 BDSIntegratorType::octupole, // octupole
96 BDSIntegratorType::decapole, // decapole
97 BDSIntegratorType::g4classicalrk4, // thick multipole
98 BDSIntegratorType::g4classicalrk4, // muon spoiler
99 BDSIntegratorType::g4classicalrk4, // rfpillbox
100 BDSIntegratorType::g4classicalrk4, // rfconstantinx
101 BDSIntegratorType::g4classicalrk4, // rfconstantiny
102 BDSIntegratorType::g4classicalrk4, // rfconstantinz
103 BDSIntegratorType::g4classicalrk4, // general
104 BDSIntegratorType::g4classicalrk4, // skew quadrupole
105 BDSIntegratorType::g4classicalrk4, // skew sextupole
106 BDSIntegratorType::g4classicalrk4, // skew octupole
107 BDSIntegratorType::g4classicalrk4, // skew decapole
108 BDSIntegratorType::dipolefringe, // dipole fringe field
109 BDSIntegratorType::multipolethin, // thin multipole
110 BDSIntegratorType::g4rk4minimumstep, // multipole outer
111 BDSIntegratorType::rmatrixthin, // thin rmatrix
112 BDSIntegratorType::paralleltransport,// parallel transport
113 BDSIntegratorType::g4classicalrk4, // undulator
114 BDSIntegratorType::cavityfringe, // cavity fringe
115 BDSIntegratorType::g4classicalrk4); // gabor lens
116
117 const BDSIntegratorSet* integratorsBDSIMTwo =
118 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
119 BDSIntegratorType::dipolerodrigues2, // dipole
120 BDSIntegratorType::dipolematrix, // dipole quadrupole
121 BDSIntegratorType::quadrupole, // quadrupole
122 BDSIntegratorType::euler, // sextupole
123 BDSIntegratorType::euler, // octupole
124 BDSIntegratorType::euler, // decapole
125 BDSIntegratorType::g4classicalrk4, // (thick) multipole
126 BDSIntegratorType::g4classicalrk4, // muonspoiler
127 BDSIntegratorType::g4classicalrk4, // rfpillbox
128 BDSIntegratorType::g4classicalrk4, // rfconstantinx
129 BDSIntegratorType::g4classicalrk4, // rfconstantiny
130 BDSIntegratorType::g4classicalrk4, // rfconstantinz
131 BDSIntegratorType::g4classicalrk4, // general
132 BDSIntegratorType::g4classicalrk4, // skew quadrupole
133 BDSIntegratorType::g4classicalrk4, // skew sextupole
134 BDSIntegratorType::g4classicalrk4, // skew octupole
135 BDSIntegratorType::g4classicalrk4, // skew decapole
136 BDSIntegratorType::dipolefringe, // dipole fringe field
137 BDSIntegratorType::multipolethin, // thin multipole
138 BDSIntegratorType::g4rk4minimumstep, // multipole outer
139 BDSIntegratorType::rmatrixthin, // thin rmatrix
140 BDSIntegratorType::paralleltransport,// parallel transport
141 BDSIntegratorType::g4classicalrk4, // undulator
142 BDSIntegratorType::cavityfringe, // cavity fringe
143 BDSIntegratorType::g4classicalrk4); // gabor lens
146 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
147 BDSIntegratorType::dipolematrix, // dipole
148 BDSIntegratorType::dipolematrix, // dipole quadrupole
149 BDSIntegratorType::quadrupole, // quadrupole
150 BDSIntegratorType::euler, // sextupole
151 BDSIntegratorType::euler, // octupole
152 BDSIntegratorType::euler, // decapole
153 BDSIntegratorType::g4classicalrk4, // thick multipole
154 BDSIntegratorType::g4classicalrk4, // muon spoiler
155 BDSIntegratorType::g4classicalrk4, // rfpillbox
156 BDSIntegratorType::g4classicalrk4, // rfconstantinx
157 BDSIntegratorType::g4classicalrk4, // rfconstantiny
158 BDSIntegratorType::g4classicalrk4, // rfconstantinz
159 BDSIntegratorType::g4classicalrk4, // general
160 BDSIntegratorType::g4classicalrk4, // skew quadrupole
161 BDSIntegratorType::g4classicalrk4, // skew sextupole
162 BDSIntegratorType::g4classicalrk4, // skew octupole
163 BDSIntegratorType::g4classicalrk4, // skew decapole
164 BDSIntegratorType::dipolefringe, // dipole fringe field
165 BDSIntegratorType::multipolethin, // thin multipole
166 BDSIntegratorType::g4rk4minimumstep, // multipole outer
167 BDSIntegratorType::rmatrixthin, // thin rmatrix
168 BDSIntegratorType::paralleltransport, // parallel transport
169 BDSIntegratorType::g4classicalrk4, // undulator
170 BDSIntegratorType::cavityfringe, // cavity fringe
171 BDSIntegratorType::g4classicalrk4); // gabor lens
172 const BDSIntegratorSet* integratorsBDSIMMatrixFringeScaling =
173 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
174 BDSIntegratorType::dipolematrix, // dipole
175 BDSIntegratorType::dipolematrix, // dipole quadrupole
176 BDSIntegratorType::quadrupole, // quadrupole
177 BDSIntegratorType::euler, // sextupole
178 BDSIntegratorType::euler, // octupole
179 BDSIntegratorType::euler, // decapole
180 BDSIntegratorType::g4classicalrk4, // thick multipole
181 BDSIntegratorType::g4classicalrk4, // muon spoiler
182 BDSIntegratorType::g4classicalrk4, // rfpillbox
183 BDSIntegratorType::g4classicalrk4, // rfconstantinz
184 BDSIntegratorType::g4classicalrk4, // rfconstantiny
185 BDSIntegratorType::g4classicalrk4, // rfconstantinz
186 BDSIntegratorType::g4classicalrk4, // general
187 BDSIntegratorType::g4classicalrk4, // skew quadrupole
188 BDSIntegratorType::g4classicalrk4, // skew sextupole
189 BDSIntegratorType::g4classicalrk4, // skew octupole
190 BDSIntegratorType::g4classicalrk4, // skew decapole
191 BDSIntegratorType::dipolefringescaling, // dipole fringe field
192 BDSIntegratorType::multipolethin, // thin multipole
193 BDSIntegratorType::g4rk4minimumstep, // multipole outer - nystrom doesn't work in g4.10.5
194 BDSIntegratorType::rmatrixthin, // thin rmatrix
195 BDSIntegratorType::paralleltransport, // parallel transport
196 BDSIntegratorType::g4classicalrk4, // undulator
197 BDSIntegratorType::cavityfringe, // cavity fringe
198 BDSIntegratorType::g4classicalrk4); // gabor lens
199 const BDSIntegratorSet* integratorsGeant4 =
200 new BDSIntegratorSet(BDSIntegratorType::g4classicalrk4, // solenoid
201 BDSIntegratorType::g4classicalrk4, // dipole
202 BDSIntegratorType::g4classicalrk4, // dipole quadrupole
203 BDSIntegratorType::g4classicalrk4, // quadrupole
204 BDSIntegratorType::g4classicalrk4, // sextupole
205 BDSIntegratorType::g4classicalrk4, // octupole
206 BDSIntegratorType::g4classicalrk4, // decapole
207 BDSIntegratorType::g4classicalrk4, // thick multipole
208 BDSIntegratorType::g4classicalrk4, // muon spoiler
209 BDSIntegratorType::g4classicalrk4, // rfpillbox
210 BDSIntegratorType::g4classicalrk4, // rfconstantinx
211 BDSIntegratorType::g4classicalrk4, // rfconstantiny
212 BDSIntegratorType::g4classicalrk4, // rfconstantinz
213 BDSIntegratorType::g4classicalrk4, // general
214 BDSIntegratorType::g4classicalrk4, // skew quadrupole
215 BDSIntegratorType::g4classicalrk4, // skew sextupole
216 BDSIntegratorType::g4classicalrk4, // skew octupole
217 BDSIntegratorType::g4classicalrk4, // skew decapole
218 BDSIntegratorType::dipolefringe, // dipole fringe field
219 BDSIntegratorType::multipolethin, // thin multipole
220 BDSIntegratorType::g4rk4minimumstep, // multipole outer
221 BDSIntegratorType::rmatrixthin, // thin rmatrix
222 BDSIntegratorType::paralleltransport, // parallel transport
223 BDSIntegratorType::g4classicalrk4, // undulator
224 BDSIntegratorType::cavityfringe, // cavity fringe
225 BDSIntegratorType::g4classicalrk4); // gabor lens
226#if G4VERSION_NUMBER > 1039
227 const BDSIntegratorSet* integratorsGeant4DP =
228 new BDSIntegratorSet(BDSIntegratorType::g4dormandprince745, // solenoid
229 BDSIntegratorType::g4dormandprince745, // dipole
230 BDSIntegratorType::g4dormandprince745, // dipole quadrupole
231 BDSIntegratorType::g4dormandprince745, // quadrupole
232 BDSIntegratorType::g4dormandprince745, // sextupole
233 BDSIntegratorType::g4dormandprince745, // octupole
234 BDSIntegratorType::g4dormandprince745, // decapole
235 BDSIntegratorType::g4dormandprince745, // thick multipole
236 BDSIntegratorType::g4dormandprince745, // muon spoiler
237 BDSIntegratorType::g4dormandprince745, // rfpillbox
238 BDSIntegratorType::g4dormandprince745, // rfconstantinx
239 BDSIntegratorType::g4dormandprince745, // rfconstantiny
240 BDSIntegratorType::g4dormandprince745, // rfconstantinz
241 BDSIntegratorType::g4dormandprince745, // general
242 BDSIntegratorType::g4dormandprince745, // skew quadrupole
243 BDSIntegratorType::g4dormandprince745, // skew sextupole
244 BDSIntegratorType::g4dormandprince745, // skew octupole
245 BDSIntegratorType::g4dormandprince745, // skew decapole
246 BDSIntegratorType::dipolefringe, // dipole fringe field
247 BDSIntegratorType::multipolethin, // thin multipole
248 BDSIntegratorType::g4dormandprince745, // multipole outer
249 BDSIntegratorType::rmatrixthin, // thin rmatrix
250 BDSIntegratorType::paralleltransport, // parallel transport
251 BDSIntegratorType::g4dormandprince745, // undulator
252 BDSIntegratorType::cavityfringe, // cavity fringe
253 BDSIntegratorType::g4classicalrk4); // gabor lens
254#endif
255}
256
261
263{
264 switch (set.underlying())
265 {
266 case BDSIntegratorSetType::geant4:
267 {return BDS::integratorsGeant4; break;}
268#if G4VERSION_NUMBER > 1039
269 case BDSIntegratorSetType::geant4dp:
270 {return BDS::integratorsGeant4DP; break;}
271#endif
272 case BDSIntegratorSetType::bdsimone:
273 {return BDS::integratorsBDSIMOne; break;}
274 case BDSIntegratorSetType::bdsimtwo:
275 {return BDS::integratorsBDSIMTwo;}
276 case BDSIntegratorSetType::bdsimmatrix:
278 case BDSIntegratorSetType::bdsimmatrixfringescaling:
279 {return BDS::integratorsBDSIMMatrixFringeScaling;}
280 default:
281 {return BDS::integratorsBDSIMOne; break;}
282 }
283}
284
286{
287 switch (field.underlying())
288 {
289 case BDSFieldType::none:
290 {return general; break;}// shouldn't really happen, but for completeness.
291 case BDSFieldType::bmap1d:
292 case BDSFieldType::bmap2d:
293 case BDSFieldType::bmap3d:
294 case BDSFieldType::bmap4d:
295 case BDSFieldType::ebmap1d:
296 case BDSFieldType::ebmap2d:
297 case BDSFieldType::ebmap3d:
298 case BDSFieldType::ebmap4d:
299 case BDSFieldType::emap1d:
300 case BDSFieldType::emap2d:
301 case BDSFieldType::emap3d:
302 case BDSFieldType::emap4d:
303 case BDSFieldType::mokka:
304 {
305 G4cout << __METHOD_NAME__ << "WARNING - this is overriding the specified field maps integrator" << G4endl;
306 return general;
307 break;
308 }
309 case BDSFieldType::solenoid:
310 {return solenoid; break;}
311 case BDSFieldType::dipole:
312 {return dipole; break;}
313 case BDSFieldType::dipolequadrupole:
314 {return dipoleQuadrupole; break;}
315 case BDSFieldType::quadrupole:
316 {return quadrupole; break;}
317 case BDSFieldType::sextupole:
318 {return sextupole; break;}
319 case BDSFieldType::octupole:
320 {return octupole; break;}
321 case BDSFieldType::decapole:
322 {return decapole; break;}
323 case BDSFieldType::multipole:
324 {return multipoleThick; break;}
325 case BDSFieldType::muonspoiler:
326 {return muonSpoiler; break;}
327 case BDSFieldType::skewquadrupole:
328 {return skewQuadrupole; break;}
329 case BDSFieldType::skewsextupole:
330 {return skewSextupole; break;}
331 case BDSFieldType::skewoctupole:
332 {return skewOctupole; break;}
333 case BDSFieldType::skewdecapole:
334 {return skewDecapole; break;}
335 case BDSFieldType::rfpillbox:
336 {return rfpillbox; break;}
337 case BDSFieldType::rfconstantinx:
338 {return rfconstantinx; break;}
339 case BDSFieldType::rfconstantiny:
340 {return rfconstantiny; break;}
341 case BDSFieldType::rfconstantinz:
342 {return rfconstantinz; break;}
343 case BDSFieldType::rmatrix:
344 {return rmatrixThin; break;}
345 case BDSFieldType::paralleltransporter:
346 {return parallelTransporter; break;}
347 case BDSFieldType::cavityfringe:
348 {return cavityFringe; break;}
349 case BDSFieldType::gaborlens:
350 {return gaborLens; break;}
351 case BDSFieldType::undulator:
352 {return undulator; break;}
353 case BDSFieldType::dipole3d:
354 {return general; break;}
355 case BDSFieldType::multipoleouterdipole:
356 case BDSFieldType::multipoleouterquadrupole:
357 case BDSFieldType::multipoleoutersextupole:
358 case BDSFieldType::multipoleouteroctupole:
359 case BDSFieldType::multipoleouterdecapole:
360 case BDSFieldType::skewmultipoleouterquadrupole:
361 case BDSFieldType::skewmultipoleoutersextupole:
362 case BDSFieldType::skewmultipoleouteroctupole:
363 case BDSFieldType::skewmultipoleouterdecapole:
364 case BDSFieldType::multipoleouterdipole3d:
365 case BDSFieldType::multipoleouterdipolelhc:
366 case BDSFieldType::multipoleouterquadrupolelhc:
367 case BDSFieldType::multipoleoutersextupolelhc:
368 {return multipoleOuter; break;}
369 default:
370 {return general; break;}
371 }
372}
Which integrator to use for each type of magnet / field object.
BDSIntegratorType Integrator(const BDSFieldType field) const
Get appropriate integrator based on the field type.
type underlying() const
return underlying value (can be used in switch statement)
Return either G4Tubs or G4CutTubs depending on flat face.
const BDSIntegratorSet * IntegratorSet(G4String set)
Return the appropriate set of integrators to use for each magnet type.
BDSIntegratorSetType DetermineIntegratorSetType(G4String integratorSet)
Function that gives corresponding enum value for string (case-insensitive)
const BDSIntegratorSet * integratorsBDSIMMatrix
Mad-x style tracking.