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 - 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#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 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{
78 isMatrix = false; //default
79 // use dipolematrix integrator to check if matrix style as it is the
80 // only integrator exclusive to matrix style integrator sets
81 if (dipoleIn == BDSIntegratorType::dipolematrix)
82 {isMatrix = true;}
83}
84
85namespace BDS
86{
87 const BDSIntegratorSet* integratorsBDSIMOne =
88 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
89 BDSIntegratorType::dipolerodrigues, // dipole
90 BDSIntegratorType::dipolematrix, // dipole quadrupole
91 BDSIntegratorType::quadrupole, // quadrupole
92 BDSIntegratorType::sextupole, // sextupole
93 BDSIntegratorType::octupole, // octupole
94 BDSIntegratorType::decapole, // decapole
95 BDSIntegratorType::g4classicalrk4, // thick multipole
96 BDSIntegratorType::g4classicalrk4, // muon spoiler
97 BDSIntegratorType::g4classicalrk4, // rfpillbox
98 BDSIntegratorType::g4classicalrk4, // rfconstantinx
99 BDSIntegratorType::g4classicalrk4, // rfconstantiny
100 BDSIntegratorType::g4classicalrk4, // rfconstantinz
101 BDSIntegratorType::g4classicalrk4, // general
102 BDSIntegratorType::g4classicalrk4, // skew quadrupole
103 BDSIntegratorType::g4classicalrk4, // skew sextupole
104 BDSIntegratorType::g4classicalrk4, // skew octupole
105 BDSIntegratorType::g4classicalrk4, // skew decapole
106 BDSIntegratorType::dipolefringe, // dipole fringe field
107 BDSIntegratorType::multipolethin, // thin multipole
108 BDSIntegratorType::g4rk4minimumstep, // multipole outer
109 BDSIntegratorType::rmatrixthin, // thin rmatrix
110 BDSIntegratorType::paralleltransport,// parallel transport
111 BDSIntegratorType::g4classicalrk4, // undulator
112 BDSIntegratorType::cavityfringe); // cavity fringe
113
114 const BDSIntegratorSet* integratorsBDSIMTwo =
115 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
116 BDSIntegratorType::dipolerodrigues2, // dipole
117 BDSIntegratorType::dipolematrix, // dipole quadrupole
118 BDSIntegratorType::quadrupole, // quadrupole
119 BDSIntegratorType::euler, // sextupole
120 BDSIntegratorType::euler, // octupole
121 BDSIntegratorType::euler, // decapole
122 BDSIntegratorType::g4classicalrk4, // (thick) multipole
123 BDSIntegratorType::g4classicalrk4, // muonspoiler
124 BDSIntegratorType::g4classicalrk4, // rfpillbox
125 BDSIntegratorType::g4classicalrk4, // rfconstantinx
126 BDSIntegratorType::g4classicalrk4, // rfconstantiny
127 BDSIntegratorType::g4classicalrk4, // rfconstantinz
128 BDSIntegratorType::g4classicalrk4, // general
129 BDSIntegratorType::g4classicalrk4, // skew quadrupole
130 BDSIntegratorType::g4classicalrk4, // skew sextupole
131 BDSIntegratorType::g4classicalrk4, // skew octupole
132 BDSIntegratorType::g4classicalrk4, // skew decapole
133 BDSIntegratorType::dipolefringe, // dipole fringe field
134 BDSIntegratorType::multipolethin, // thin multipole
135 BDSIntegratorType::g4rk4minimumstep, // multipole outer
136 BDSIntegratorType::rmatrixthin, // thin rmatrix
137 BDSIntegratorType::paralleltransport,// parallel transport
138 BDSIntegratorType::g4classicalrk4, // undulator
139 BDSIntegratorType::cavityfringe); // cavity fringe
142 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
143 BDSIntegratorType::dipolematrix, // dipole
144 BDSIntegratorType::dipolematrix, // dipole quadrupole
145 BDSIntegratorType::quadrupole, // quadrupole
146 BDSIntegratorType::euler, // sextupole
147 BDSIntegratorType::euler, // octupole
148 BDSIntegratorType::euler, // decapole
149 BDSIntegratorType::g4classicalrk4, // thick multipole
150 BDSIntegratorType::g4classicalrk4, // muon spoiler
151 BDSIntegratorType::g4classicalrk4, // rfpillbox
152 BDSIntegratorType::g4classicalrk4, // rfconstantinx
153 BDSIntegratorType::g4classicalrk4, // rfconstantiny
154 BDSIntegratorType::g4classicalrk4, // rfconstantinz
155 BDSIntegratorType::g4classicalrk4, // general
156 BDSIntegratorType::g4classicalrk4, // skew quadrupole
157 BDSIntegratorType::g4classicalrk4, // skew sextupole
158 BDSIntegratorType::g4classicalrk4, // skew octupole
159 BDSIntegratorType::g4classicalrk4, // skew decapole
160 BDSIntegratorType::dipolefringe, // dipole fringe field
161 BDSIntegratorType::multipolethin, // thin multipole
162 BDSIntegratorType::g4rk4minimumstep, // multipole outer
163 BDSIntegratorType::rmatrixthin, // thin rmatrix
164 BDSIntegratorType::paralleltransport, // parallel transport
165 BDSIntegratorType::g4classicalrk4, // undulator
166 BDSIntegratorType::cavityfringe); // cavity fringe
167 const BDSIntegratorSet* integratorsBDSIMMatrixFringeScaling =
168 new BDSIntegratorSet(BDSIntegratorType::solenoid, // solenoid
169 BDSIntegratorType::dipolematrix, // dipole
170 BDSIntegratorType::dipolematrix, // dipole quadrupole
171 BDSIntegratorType::quadrupole, // quadrupole
172 BDSIntegratorType::euler, // sextupole
173 BDSIntegratorType::euler, // octupole
174 BDSIntegratorType::euler, // decapole
175 BDSIntegratorType::g4classicalrk4, // thick multipole
176 BDSIntegratorType::g4classicalrk4, // muon spoiler
177 BDSIntegratorType::g4classicalrk4, // rfpillbox
178 BDSIntegratorType::g4classicalrk4, // rfconstantinz
179 BDSIntegratorType::g4classicalrk4, // rfconstantiny
180 BDSIntegratorType::g4classicalrk4, // rfconstantinz
181 BDSIntegratorType::g4classicalrk4, // general
182 BDSIntegratorType::g4classicalrk4, // skew quadrupole
183 BDSIntegratorType::g4classicalrk4, // skew sextupole
184 BDSIntegratorType::g4classicalrk4, // skew octupole
185 BDSIntegratorType::g4classicalrk4, // skew decapole
186 BDSIntegratorType::dipolefringescaling, // dipole fringe field
187 BDSIntegratorType::multipolethin, // thin multipole
188 BDSIntegratorType::g4rk4minimumstep, // multipole outer - nystrom doesn't work in g4.10.5
189 BDSIntegratorType::rmatrixthin, // thin rmatrix
190 BDSIntegratorType::paralleltransport, // parallel transport
191 BDSIntegratorType::g4classicalrk4, // undulator
192 BDSIntegratorType::cavityfringe); // cavity fringe
193 const BDSIntegratorSet* integratorsGeant4 =
194 new BDSIntegratorSet(BDSIntegratorType::g4classicalrk4, // solenoid
195 BDSIntegratorType::g4classicalrk4, // dipole
196 BDSIntegratorType::g4classicalrk4, // dipole quadrupole
197 BDSIntegratorType::g4classicalrk4, // quadrupole
198 BDSIntegratorType::g4classicalrk4, // sextupole
199 BDSIntegratorType::g4classicalrk4, // octupole
200 BDSIntegratorType::g4classicalrk4, // decapole
201 BDSIntegratorType::g4classicalrk4, // thick multipole
202 BDSIntegratorType::g4classicalrk4, // muon spoiler
203 BDSIntegratorType::g4classicalrk4, // rfpillbox
204 BDSIntegratorType::g4classicalrk4, // rfconstantinx
205 BDSIntegratorType::g4classicalrk4, // rfconstantiny
206 BDSIntegratorType::g4classicalrk4, // rfconstantinz
207 BDSIntegratorType::g4classicalrk4, // general
208 BDSIntegratorType::g4classicalrk4, // skew quadrupole
209 BDSIntegratorType::g4classicalrk4, // skew sextupole
210 BDSIntegratorType::g4classicalrk4, // skew octupole
211 BDSIntegratorType::g4classicalrk4, // skew decapole
212 BDSIntegratorType::dipolefringe, // dipole fringe field
213 BDSIntegratorType::multipolethin, // thin multipole
214 BDSIntegratorType::g4rk4minimumstep, // multipole outer
215 BDSIntegratorType::rmatrixthin, // thin rmatrix
216 BDSIntegratorType::paralleltransport, // parallel transport
217 BDSIntegratorType::g4classicalrk4, // undulator
218 BDSIntegratorType::cavityfringe); // cavity fringe
219#if G4VERSION_NUMBER > 1039
220 const BDSIntegratorSet* integratorsGeant4DP =
221 new BDSIntegratorSet(BDSIntegratorType::g4dormandprince745, // solenoid
222 BDSIntegratorType::g4dormandprince745, // dipole
223 BDSIntegratorType::g4dormandprince745, // dipole quadrupole
224 BDSIntegratorType::g4dormandprince745, // quadrupole
225 BDSIntegratorType::g4dormandprince745, // sextupole
226 BDSIntegratorType::g4dormandprince745, // octupole
227 BDSIntegratorType::g4dormandprince745, // decapole
228 BDSIntegratorType::g4dormandprince745, // thick multipole
229 BDSIntegratorType::g4dormandprince745, // muon spoiler
230 BDSIntegratorType::g4dormandprince745, // rfpillbox
231 BDSIntegratorType::g4dormandprince745, // rfconstantinx
232 BDSIntegratorType::g4dormandprince745, // rfconstantiny
233 BDSIntegratorType::g4dormandprince745, // rfconstantinz
234 BDSIntegratorType::g4dormandprince745, // general
235 BDSIntegratorType::g4dormandprince745, // skew quadrupole
236 BDSIntegratorType::g4dormandprince745, // skew sextupole
237 BDSIntegratorType::g4dormandprince745, // skew octupole
238 BDSIntegratorType::g4dormandprince745, // skew decapole
239 BDSIntegratorType::dipolefringe, // dipole fringe field
240 BDSIntegratorType::multipolethin, // thin multipole
241 BDSIntegratorType::g4dormandprince745, // multipole outer
242 BDSIntegratorType::rmatrixthin, // thin rmatrix
243 BDSIntegratorType::paralleltransport, // parallel transport
244 BDSIntegratorType::g4dormandprince745, // undulator
245 BDSIntegratorType::cavityfringe); // cavity fringe
246#endif
247}
248
250{
252}
253
255{
256 switch (set.underlying())
257 {
258 case BDSIntegratorSetType::geant4:
259 {return BDS::integratorsGeant4; break;}
260#if G4VERSION_NUMBER > 1039
261 case BDSIntegratorSetType::geant4dp:
262 {return BDS::integratorsGeant4DP; break;}
263#endif
264 case BDSIntegratorSetType::bdsimone:
265 {return BDS::integratorsBDSIMOne; break;}
266 case BDSIntegratorSetType::bdsimtwo:
267 {return BDS::integratorsBDSIMTwo;}
268 case BDSIntegratorSetType::bdsimmatrix:
270 case BDSIntegratorSetType::bdsimmatrixfringescaling:
271 {return BDS::integratorsBDSIMMatrixFringeScaling;}
272 default:
273 {return BDS::integratorsBDSIMOne; break;}
274 }
275}
276
278{
279 switch (field.underlying())
280 {
281 case BDSFieldType::none:
282 {return general; break;}// shouldn't really happen, but for completeness.
283 case BDSFieldType::bmap1d:
284 case BDSFieldType::bmap2d:
285 case BDSFieldType::bmap3d:
286 case BDSFieldType::bmap4d:
287 case BDSFieldType::ebmap1d:
288 case BDSFieldType::ebmap2d:
289 case BDSFieldType::ebmap3d:
290 case BDSFieldType::ebmap4d:
291 case BDSFieldType::emap1d:
292 case BDSFieldType::emap2d:
293 case BDSFieldType::emap3d:
294 case BDSFieldType::emap4d:
295 case BDSFieldType::mokka:
296 {
297 G4cout << __METHOD_NAME__ << "WARNING - this is overriding the specified field maps integrator" << G4endl;
298 return general;
299 break;
300 }
301 case BDSFieldType::solenoid:
302 {return solenoid; break;}
303 case BDSFieldType::dipole:
304 {return dipole; break;}
305 case BDSFieldType::dipolequadrupole:
306 {return dipoleQuadrupole; break;}
307 case BDSFieldType::quadrupole:
308 {return quadrupole; break;}
309 case BDSFieldType::sextupole:
310 {return sextupole; break;}
311 case BDSFieldType::octupole:
312 {return octupole; break;}
313 case BDSFieldType::decapole:
314 {return decapole; break;}
315 case BDSFieldType::multipole:
316 {return multipoleThick; break;}
317 case BDSFieldType::muonspoiler:
318 {return muonSpoiler; break;}
319 case BDSFieldType::skewquadrupole:
320 {return skewQuadrupole; break;}
321 case BDSFieldType::skewsextupole:
322 {return skewSextupole; break;}
323 case BDSFieldType::skewoctupole:
324 {return skewOctupole; break;}
325 case BDSFieldType::skewdecapole:
326 {return skewDecapole; break;}
327 case BDSFieldType::rfpillbox:
328 {return rfpillbox; break;}
329 case BDSFieldType::rfconstantinx:
330 {return rfconstantinx; break;}
331 case BDSFieldType::rfconstantiny:
332 {return rfconstantiny; break;}
333 case BDSFieldType::rfconstantinz:
334 {return rfconstantinz; break;}
335 case BDSFieldType::rmatrix:
336 {return rmatrixThin; break;}
337 case BDSFieldType::paralleltransporter:
338 {return parallelTransporter; break;}
339 case BDSFieldType::cavityfringe:
340 {return cavityFringe; break;}
341 case BDSFieldType::undulator:
342 {return undulator; break;}
343 case BDSFieldType::dipole3d:
344 {return general; break;}
345 case BDSFieldType::multipoleouterdipole:
346 case BDSFieldType::multipoleouterquadrupole:
347 case BDSFieldType::multipoleoutersextupole:
348 case BDSFieldType::multipoleouteroctupole:
349 case BDSFieldType::multipoleouterdecapole:
350 case BDSFieldType::skewmultipoleouterquadrupole:
351 case BDSFieldType::skewmultipoleoutersextupole:
352 case BDSFieldType::skewmultipoleouteroctupole:
353 case BDSFieldType::skewmultipoleouterdecapole:
354 case BDSFieldType::multipoleouterdipole3d:
355 case BDSFieldType::multipoleouterdipolelhc:
356 case BDSFieldType::multipoleouterquadrupolelhc:
357 case BDSFieldType::multipoleoutersextupolelhc:
358 {return multipoleOuter; break;}
359 default:
360 {return general; break;}
361 }
362}
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.