gfields
Loading...
Searching...
No Matches
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#include "gfieldConventions.h"
19#include "gfield_options.h"
20
21
22// notice: we are always using G4Mag_UsualEqRhs here
23G4FieldManager *GField::create_FieldManager() {
24
25 std::string integration_stepper = gfield_definitions.integration_stepper;
26 double minimum_step = gfield_definitions.minimum_step;
27
28 G4Mag_UsualEqRhs *iEquation = new G4Mag_UsualEqRhs(this);
29
30 if (std::find(SUPPORTED_STEPPERS.begin(), SUPPORTED_STEPPERS.end(), integration_stepper) == SUPPORTED_STEPPERS.end()) {
31 log->info(0, "Integration Stepper ", integration_stepper, " not supported. Using default: ", GFIELD_DEFAULT_INTEGRATION_STEPPER);
32 integration_stepper = GFIELD_DEFAULT_INTEGRATION_STEPPER;
33 }
34
35 G4MagIntegratorStepper *mag_int_stepper = nullptr;
36
37 // any way to do this automatically?
38 if (integration_stepper == "G4DormandPrince745") {
39 mag_int_stepper = new G4DormandPrince745(iEquation);
40 } else if (integration_stepper == "G4ClassicalRK4") {
41 mag_int_stepper = new G4ClassicalRK4(iEquation);
42 } else if (integration_stepper == "G4SimpleRunge") {
43 mag_int_stepper = new G4HelixSimpleRunge(iEquation);
44 } else if (integration_stepper == "G4HelixExplicitEuler") {
45 mag_int_stepper = new G4HelixExplicitEuler(iEquation);
46 } else if (integration_stepper == "G4HelixImplicitEuler") {
47 mag_int_stepper = new G4HelixImplicitEuler(iEquation);
48 } else if (integration_stepper == "G4CashKarpRKF45") {
49 mag_int_stepper = new G4CashKarpRKF45(iEquation);
50 } else if (integration_stepper == "G4RKG3_Stepper") {
51 mag_int_stepper = new G4RKG3_Stepper(iEquation);
52 } else if (integration_stepper == "G4SimpleHeum") {
53 mag_int_stepper = new G4SimpleHeum(iEquation);
54 } else if (integration_stepper == "G4NystromRK4") {
55 mag_int_stepper = new G4NystromRK4(iEquation);
56 } else if (integration_stepper == "G4ImplicitEuler") {
57 mag_int_stepper = new G4ImplicitEuler(iEquation);
58 } else if (integration_stepper == "G4ExplicitEuler") {
59 mag_int_stepper = new G4ExplicitEuler(iEquation);
60 } else {
61 // error, exit
62 log->error(ERR_STEPPER_NOT_FOUND, "Integration Stepper ", integration_stepper, " not found. Exiting.");
63 }
64
65 G4ChordFinder *fChordFinder = new G4ChordFinder(this, minimum_step, mag_int_stepper);
66
67 return new G4FieldManager(this, fChordFinder);
68
69}
GFieldDefinition gfield_definitions
Definition gfield.h:113
G4FieldManager * create_FieldManager()
Creates the G4FieldManager for the field.
Definition gfield.cc:23
#define GFIELD_DEFAULT_INTEGRATION_STEPPER
#define ERR_STEPPER_NOT_FOUND
double minimum_step
Minimum step size for integration.
Definition gfield.h:26
std::string integration_stepper
Type of integration stepper.
Definition gfield.h:25