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