gfields
gfield.cc
Go to the documentation of this file.
1 // geant4
2 #include "G4Mag_UsualEqRhs.hh"
3 #include "G4DormandPrince745.hh"
4 #include "G4ClassicalRK4.hh"
5 #include "G4HelixSimpleRunge.hh"
6 #include "G4HelixExplicitEuler.hh"
7 #include "G4HelixImplicitEuler.hh"
8 #include "G4CashKarpRKF45.hh"
9 #include "G4RKG3_Stepper.hh"
10 #include "G4SimpleHeum.hh"
11 #include "G4NystromRK4.hh"
12 #include "G4ImplicitEuler.hh"
13 #include "G4ExplicitEuler.hh"
14 #include "G4ChordFinder.hh"
15 
16 // gfield
17 #include "gfield.h"
18 
19 
20 // notice: we are always using G4Mag_UsualEqRhs here
21 G4FieldManager *GField::create_FieldManager() {
22 
23  string integration_stepper = gfield_definitions.integration_stepper;
24  double minimum_step = gfield_definitions.minimum_step;
25 
26  G4Mag_UsualEqRhs *iEquation = new G4Mag_UsualEqRhs(this);
27 
28  if (std::find(SUPPORTED_STEPPERS.begin(), SUPPORTED_STEPPERS.end(), integration_stepper) == SUPPORTED_STEPPERS.end()) {
29  gFLogMessage("Integration Stepper " + integration_stepper + " not supported. Using default: " + GFIELD_DEFAULT_INTEGRATION_STEPPER);
30  integration_stepper = GFIELD_DEFAULT_INTEGRATION_STEPPER;
31  }
32 
33  G4MagIntegratorStepper *mag_int_stepper = nullptr;
34 
35  // any way to do this automatically?
36  if (integration_stepper == "G4DormandPrince745") {
37  mag_int_stepper = new G4DormandPrince745(iEquation);
38  } else if (integration_stepper == "G4ClassicalRK4") {
39  mag_int_stepper = new G4ClassicalRK4(iEquation);
40  } else if (integration_stepper == "G4SimpleRunge") {
41  mag_int_stepper = new G4HelixSimpleRunge(iEquation);
42  } else if (integration_stepper == "G4HelixExplicitEuler") {
43  mag_int_stepper = new G4HelixExplicitEuler(iEquation);
44  } else if (integration_stepper == "G4HelixImplicitEuler") {
45  mag_int_stepper = new G4HelixImplicitEuler(iEquation);
46  } else if (integration_stepper == "G4CashKarpRKF45") {
47  mag_int_stepper = new G4CashKarpRKF45(iEquation);
48  } else if (integration_stepper == "G4RKG3_Stepper") {
49  mag_int_stepper = new G4RKG3_Stepper(iEquation);
50  } else if (integration_stepper == "G4SimpleHeum") {
51  mag_int_stepper = new G4SimpleHeum(iEquation);
52  } else if (integration_stepper == "G4NystromRK4") {
53  mag_int_stepper = new G4NystromRK4(iEquation);
54  } else if (integration_stepper == "G4ImplicitEuler") {
55  mag_int_stepper = new G4ImplicitEuler(iEquation);
56  } else if (integration_stepper == "G4ExplicitEuler") {
57  mag_int_stepper = new G4ExplicitEuler(iEquation);
58  } else {
59  // error, exit
60  gFLogMessage("Integration Stepper " + integration_stepper + " not supported. Exiting.");
62  }
63 
64  G4ChordFinder *fChordFinder = new G4ChordFinder(this, minimum_step, mag_int_stepper);
65  gFLogMessage("Loaded Integration Stepper: " + integration_stepper);
66 
67  return new G4FieldManager(this, fChordFinder);
68 
69 }
void gFLogMessage(std::string message)
Logs a message with the field context.
Definition: gfield.h:107
GFieldDefinition gfield_definitions
Definition: gfield.h:129
G4FieldManager * create_FieldManager()
Creates the G4FieldManager for the field.
Definition: gfield.cc:21
#define EC__STEPPER_NOT_FOUND
#define GFIELD_DEFAULT_INTEGRATION_STEPPER
double minimum_step
Minimum step size for integration.
Definition: gfield.h:25
std::string integration_stepper
Type of integration stepper.
Definition: gfield.h:24