Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HelixMixedStepper.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4HelixMixedStepper
27//
28// Class description:
29//
30// G4HelixMixedStepper split the Method used for Integration in two:
31//
32// If Stepping Angle ( h / R_curve) < pi/3 : use Stepper for small step
33//
34// Else use HelixExplicitEuler Stepper
35//
36// Stepper for the small step is G4ClassicalRK4 by default, but
37// it possible to choose other stepper,like G4CashKarpRK45 or G4RKG3_Stepper,
38// by setting StepperNumber : new HelixMixedStepper(EqRhs,N)
39//
40// N=2 G4SimpleRunge; N=3 G4SimpleHeum;
41// N=4 G4ClassicalRK4;
42// N=6 G4HelixImplicitEuler; N=7 G4HelixSimpleRunge;
43// N=8 G4CashKarpRK45; N=9 G4ExactHelixStepper;
44// N=10 G4RKG3_Stepper; N=13 G4NystromRK4
45// N=23 BogackiShampine23 N=145 TsitourasRK45
46// N=45 BogackiShampine45 N=745 DormandPrince745 (ie DoPri5)
47//
48// For completeness also available are:
49// N=11 G4ExplicitEuler N=12 G4ImplicitEuler; -- Likely poor
50// N=5 G4HelixExplicitEuler (testing only)
51// For recommendations see comments in 'SetupStepper' method.
52//
53// Note: Like other helix steppers, only applicable in pure magnetic field.
54
55// Author: Tatiana Nikitina (CERN), 18.05.2007
56// -------------------------------------------------------------------
57#ifndef G4HELIXMIXEDSTEPPER_HH
58#define G4HELIXMIXEDSTEPPER_HH
59
61
62/**
63 * @brief G4HelixMixedStepper is a concrete class for particle motion in
64 * magnetic field which splits the method used for Integration in two:
65 * if the stepping angle ( h / R_curve) is less than pi/3, use a RK stepper
66 * for small step, else use G4HelixExplicitEuler stepper.
67 * Like other helix steppers, it is only applicable in pure magnetic field.
68 */
69
71{
72 public:
73
74 /**
75 * Constructor for G4ExactHelixStepper.
76 * @param[in] EqRhs Pointer to the standard equation of motion.
77 * @param[in] StepperNumber Identified for selecting the stepper type;
78 * default (-1) is DormandPrince745.
79 * @param[in] Angle_threshold The stepping angle threshold; default (-1)
80 * is (1/3)*pi.
81 */
83 G4int StepperNumber = -1,
84 G4double Angle_threshold = -1.0);
85
86 /**
87 * Default Destructor.
88 */
89 ~G4HelixMixedStepper() override;
90
91 /**
92 * The integration stepper. The stepsize is fixed, with the step size
93 * given by 'hstep'. Integrates ODE starting values yInput[0 to 6].
94 * Outputs yout[] and its estimated error yerr[].
95 * If SteppingAngle = h/R_curve < pi/3, uses default RK stepper else
96 * use Helix fast method.
97 * @param[in] y Starting values array of integration variables.
98 * @param[in] dydx Derivatives array.
99 * @param[in] h The given step size.
100 * @param[out] yout Integration output.
101 * @param[out] yerr The estimated error.
102 */
103 void Stepper( const G4double y[],
104 const G4double dydx[],
105 G4double h,
106 G4double yout[],
107 G4double yerr[] ) override;
108
109 /**
110 * Same as Stepper() function above, but should perform a 'dump' step
111 * without error calculation. Assuming a constant field, the solution is
112 * a helix.
113 * @param[in] y Starting values array of integration variables.
114 * @param[in] Bfld The field vector.
115 * @param[in] h The given step size.
116 * @param[out] yout Integration output.
117 */
118 void DumbStepper( const G4double y[],
119 G4ThreeVector Bfld,
120 G4double h,
121 G4double yout[] ) override;
122
123 /**
124 * Estimates the maximum distance of curved solution and chord.
125 */
126 G4double DistChord() const override;
127
128 /**
129 * Sets the verbosity level.
130 */
131 inline void SetVerbose (G4int newvalue) { fVerbose = newvalue; }
132
133 /**
134 * Setter and getter for the stepping angle threshold.
135 */
136 inline void SetAngleThreshold( G4double val ) { fAngle_threshold = val; }
137 inline G4double GetAngleThreshold() { return fAngle_threshold; }
138
139 /**
140 * Returns the order, 4, of integration.
141 */
142 inline G4int IntegratorOrder() const override { return 4; }
143
144 /**
145 * Returns the stepper type-ID, "kHelixMixedStepper".
146 */
147 inline G4StepperType StepperType() const override { return kHelixMixedStepper; }
148
149 /**
150 * Logger function for the number of calls.
151 */
152 void PrintCalls();
153
154 /**
155 * Sets the chosen stepper and equation of motion.
156 */
158
159 private:
160
161 /** Mixed Integration RK4 for 'small' steps. */
162 G4MagIntegratorStepper* fRK4Stepper = nullptr;
163
164 /** Int ID of Runge-Kutta stepper. */
165 G4int fStepperNumber = -1;
166
167 /** Threshold angle (in radians ); above it, the Helical stepper is used. */
168 G4double fAngle_threshold = -1.0;
169
170 /** Verbosity level. */
171 G4int fVerbose = 0;
172
173 /** Used for statistic, i.e. how many calls to different steppers. */
174 G4int fNumCallsRK4 = 0;
175 G4int fNumCallsHelix = 0;
176};
177
178#endif
G4StepperType
G4StepperType defines the available integrator of particle's equation of motion in Geant4.
@ kHelixMixedStepper
G4HelixMixedStepper.
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4HelixMixedStepper(G4Mag_EqRhs *EqRhs, G4int StepperNumber=-1, G4double Angle_threshold=-1.0)
void SetAngleThreshold(G4double val)
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[]) override
void SetVerbose(G4int newvalue)
G4int IntegratorOrder() const override
void DumbStepper(const G4double y[], G4ThreeVector Bfld, G4double h, G4double yout[]) override
G4StepperType StepperType() const override
G4double DistChord() const override
G4MagIntegratorStepper * SetupStepper(G4Mag_EqRhs *EqRhs, G4int StepperName)
G4MagHelicalStepper(G4Mag_EqRhs *EqRhs)
G4MagIntegratorStepper is an abstract base class for integrator of particle's equation of motion,...
G4Mag_EqRhs is the "standard" equation of motion of a particle in a pure magnetic field.