93 : fDefaultDeltaChord(0.25 * mm)
94{
95
96
97 constexpr G4int nVar6 = 6;
98
99 fDeltaChord = fDefaultDeltaChord;
100
101 G4cout <<
" G4ChordFinder: stepperDriverId: " << stepperDriverId <<
G4endl;
102
108
110 {
112 G4cout <<
" G4ChordFinder: QSS 3 is currently replaced by QSS 2 driver." <<
G4endl;
113 }
114
116
117 using TemplatedStepperType =
119 const char* TemplatedStepperName =
120 "G4TDormandPrince745 (templated Dormand-Prince45, aka DoPri5): 5th/4th Order 7-stage embedded";
121
122 using RegularStepperType =
124
125
126
127
128
129 const char* RegularStepperName =
130 "G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded";
131
132
133
135
136 const char* NewFSALStepperName =
137 "G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
138
139#ifdef G4DEBUG_FIELD
140 static G4bool verboseDebug =
true;
141 if( verboseDebug )
142 {
143 G4cout <<
"G4ChordFinder 2nd Constructor called. " <<
G4endl;
145 <<
" - min step = " << stepMinimum <<
G4endl
146 << " - stepper ptr provided : "
147 << ( pItsStepper==
nullptr ?
" no " :
" yes " ) <<
G4endl;
148 if( pItsStepper==nullptr )
149 G4cout <<
" - stepper/driver Id = " << stepperDriverId <<
" i.e. "
150 << " useFSAL = " << useFSALstepper
151 << " , useTemplated = " << useTemplatedStepper
152 << " , useRegular = " << useRegularStepper
153 << " , useFSAL = " << useFSALstepper
155 }
156#endif
157
158
159
161 fEquation = pEquation;
162
163
164
165
166
167 G4bool errorInStepperCreation =
false;
168
169 std::ostringstream message;
170
171 if( pItsStepper != nullptr )
172 {
174 {
175 G4cout <<
" G4ChordFinder: Creating G4IntegrationDriver<G4MagIntegratorStepper> with "
176 << " stepMinimum = " << stepMinimum
177 <<
" numVar= " << pItsStepper->GetNumberOfVariables() <<
G4endl;
178 }
179
180
181 if(pItsStepper->isQSS())
182 {
183
186 "Cannot provide QSS stepper in constructor. User c-tor with Driver instead.");
187 }
188 else
189 {
191 pItsStepper, pItsStepper->GetNumberOfVariables() );
192
193
194
195 }
196
197
198
199
200
201 }
202 else if ( useTemplatedStepper )
203 {
205 {
206 G4cout <<
" G4ChordFinder: Creating Templated Stepper of type> "
207 << TemplatedStepperName <<
G4endl;
208 }
209
210 auto templatedStepper = new TemplatedStepperType(pEquation);
211
212
213
214
215 fRegularStepperOwned = templatedStepper;
216 if( templatedStepper == nullptr )
217 {
218 message <<
"Templated Stepper instantiation FAILED." <<
G4endl;
219 message << "G4ChordFinder: Attempted to instantiate "
220 << TemplatedStepperName <<
" type stepper " <<
G4endl;
221 errorInStepperCreation = true;
222 }
223 else
224 {
226 stepMinimum, templatedStepper, nVar6 );
228 {
229 G4cout <<
" G4ChordFinder: Using G4IntegrationDriver. " <<
G4endl;
230 }
231 }
232
233 }
234 else if ( useRegularStepper )
235 {
236 auto regularStepper = new RegularStepperType(pEquation);
237
238 fRegularStepperOwned = regularStepper;
239
241 {
242 G4cout <<
" G4ChordFinder: Creating Driver for regular stepper.";
243 }
244
245 if( regularStepper == nullptr )
246 {
247 message <<
"Regular Stepper instantiation FAILED." <<
G4endl;
248 message << "G4ChordFinder: Attempted to instantiate "
249 << RegularStepperName <<
" type stepper " <<
G4endl;
250 errorInStepperCreation = true;
251 }
252 else
253 {
255 if( dp5 != nullptr )
256 {
258 stepMinimum, dp5, nVar6 );
260 {
261 G4cout <<
" Using InterpolationDriver<DoPri5> " <<
G4endl;
262 }
263 }
264 else
265 {
267 stepMinimum, regularStepper, nVar6 );
269 {
270 G4cout <<
" Using IntegrationDriver<DoPri5> " <<
G4endl;
271 }
272 }
273 }
274 }
275 else if ( useBfieldDriver )
276 {
278
279
280 fRegularStepperOwned = regularStepper;
281
282 {
285
286 fLongStepper = std::make_unique<G4HelixHeum>(pEquation);
287
289 std::make_unique<SmallStepDriver>(stepMinimum,
290 regularStepper, regularStepper->GetNumberOfVariables()),
291 std::make_unique<LargeStepDriver>(stepMinimum,
292 fLongStepper.get(), regularStepper->GetNumberOfVariables()) );
293
294 if( fIntgrDriver == nullptr)
295 {
296 message << "Using G4BFieldIntegrationDriver with "
297 << RegularStepperName <<
" type stepper " <<
G4endl;
298 message <<
"Driver instantiation FAILED." <<
G4endl;
301 }
302 }
303 }
304 else if( useG4QSSDriver )
305 {
307 {
310 {
312 }
314 }
315 else
316 {
319 {
321 }
323 }
325 {
326 G4cout <<
"-- G4ChordFinder: Using QSS Driver." <<
G4endl;
327 }
328 }
329 else
330 {
331 auto fsalStepper= new NewFsalStepperType(pEquation);
332
333 fNewFSALStepperOwned = fsalStepper;
334
335 if( fsalStepper == nullptr )
336 {
337 message <<
"Stepper instantiation FAILED." <<
G4endl;
338 message << "Attempted to instantiate "
339 << NewFSALStepperName <<
" type stepper " <<
G4endl;
342 errorInStepperCreation = true;
343 }
344 else
345 {
346 fIntgrDriver = new
348 fsalStepper->GetNumberOfVariables() );
349
350
351 if( fIntgrDriver == nullptr )
352 {
353 message << "Using G4FSALIntegrationDriver with stepper type: "
354 << NewFSALStepperName <<
G4endl;
355 message <<
"Integration Driver instantiation FAILED." <<
G4endl;
358 }
359 }
360 }
361
362
363
364
365
366
367
368
369
370
371
372 if( errorInStepperCreation || (fIntgrDriver == nullptr ))
373 {
374 std::ostringstream errmsg;
375
376 if( errorInStepperCreation )
377 {
378 errmsg <<
"ERROR> Failure to create Stepper object." <<
G4endl
379 <<
" --------------------------------" <<
G4endl;
380 }
381 if (fIntgrDriver == nullptr )
382 {
383 errmsg << "ERROR> Failure to create Integration-Driver object."
385 << " -------------------------------------------"
387 }
388 const std::string BoolName[2]= { "False", "True" };
389 errmsg <<
" Configuration: (constructor arguments) " <<
G4endl
390 <<
" provided Stepper = " << pItsStepper <<
G4endl
391 << " stepper/driver Id = " << stepperDriverId << " i.e. "
392 << " useTemplated = " << BoolName[useTemplatedStepper]
393 << " useRegular = " << BoolName[useRegularStepper]
394 << " useFSAL = " << BoolName[useFSALstepper]
395 << " using combo BField Driver = " <<
396 BoolName[ ! (useFSALstepper||useTemplatedStepper
397 || useRegularStepper ) ]
399 errmsg << message.str();
400 errmsg << "Aborting.";
401 G4Exception(
"G4ChordFinder::G4ChordFinder() - constructor 2",
403 }
404
405 assert( ( pItsStepper != nullptr )
406 || ( fRegularStepperOwned != nullptr )
407 || ( fNewFSALStepperOwned != nullptr )
408 || useG4QSSDriver
409 );
410 assert( fIntgrDriver != nullptr );
411}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4QSStepper< G4QSS3 > * CreateQss3Stepper(G4Mag_EqRhs *Equation)
static G4VIntegrationDriver * CreateDriver(G4MagIntegratorStepper *pStepper, G4double)
static G4QSStepper< G4QSS2 > * CreateQss2Stepper(G4Mag_EqRhs *Equation)