Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VIntegrationDriver.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// G4VIntegrationDriver
27//
28// Class description:
29//
30// Abstract base class for 'driver' classes which are responsible for
31// undertaking integration of an state given an equation of motion and
32// within acceptable error bound(s).
33//
34// Different integration methods are meant to be provided via this
35// common interface, and can span the original type (explicit Runge Kutta
36// methods), enhanced RK methods and alternatives such as the
37// Bulirsch-Stoer and multi-step methods.
38//
39// The drivers' key mission is to insure that the error is below set values.
40
41// Author: Dmitry Sorokin (CERN, Google Summer of Code 2017), 20.10.2017
42// Supervision: John Apostolakis (CERN)
43// --------------------------------------------------------------------
44#ifndef G4VINTEGRATION_DRIVER_HH
45#define G4VINTEGRATION_DRIVER_HH
46
47#include "G4Types.hh"
48#include "G4FieldTrack.hh"
49#include "G4EquationOfMotion.hh"
50
52
54{
55 public:
56
57 /**
58 * Default Destructor.
59 */
60 virtual ~G4VIntegrationDriver() = default;
61
62 /**
63 * Computes the step to take, based on chord limits.
64 * @param[in,out] track The current track in field.
65 * @param[in] hstep Proposed step length.
66 * @param[in] eps Requested accuracy, y_err/hstep.
67 * @param[in] chordDistance Maximum sagitta distance.
68 * @returns The length of step taken.
69 */
71 G4double hstep,
72 G4double eps,
73 G4double chordDistance) = 0;
74
75 /**
76 * Advances integration accurately by relative accuracy better than 'eps'.
77 * On output the track is replaced by the value at the end of interval.
78 * @param[in,out] track The current track in field.
79 * @param[in] hstep Proposed step length.
80 * @param[in] eps Requested accuracy, y_err/hstep.
81 * @param[in] hinitial Initial minimum integration step.
82 * @returns true if integration succeeds.
83 */
85 G4double hstep,
86 G4double eps, // Requested y_err/hstep
87 G4double hinitial = 0 ) = 0;
88
89 /**
90 * Setter and getter for the equation of motion.
91 */
92 virtual void SetEquationOfMotion(G4EquationOfMotion* equation) = 0;
94
95 /**
96 * Method for compatibility -- relevant only for G4MagIntegratorDriver.
97 */
98 virtual void RenewStepperAndAdjust(G4MagIntegratorStepper* pItsStepper);
99
100 /**
101 * Setter and getter for verbosity.
102 */
103 virtual void SetVerboseLevel(G4int level) = 0;
104 virtual G4int GetVerboseLevel() const = 0;
105
106 /**
107 * Dispatch interface method for computing step.
108 */
109 virtual void OnComputeStep(const G4FieldTrack* /*track*/ = nullptr) = 0;
110
111 /**
112 * Dispatch interface method for initialisation/reset of driver.
113 */
114 virtual void OnStartTracking() = 0;
115
116 /**
117 * Whether the driver implements re-integration:
118 * Does this driver *Recalculate* when AccurateAdvance() is called ?
119 */
120 virtual G4bool DoesReIntegrate() const = 0;
121
122 /**
123 * Writes out to stream the parameters/state of the driver.
124 */
125 virtual void StreamInfo( std::ostream& os ) const = 0;
126
127 /**
128 * Streaming operator.
129 */
130 friend std::ostream& operator<<( std::ostream& os, const G4VIntegrationDriver& id);
131
132 // ------------------------------------------------------------------------
133
134 //[[deprecated("will be removed")]]
135 virtual G4bool QuickAdvance(G4FieldTrack& /*track*/, // INOUT
136 const G4double /*dydx*/[],
137 G4double /*hstep*/,
138 G4double& /*dchord_step*/,
139 G4double& /*dyerr*/) { return false; }
140
141 //[[deprecated("will be removed")]]
142 virtual void GetDerivatives(const G4FieldTrack& track,
143 G4double dydx[]) const = 0;
144
145 //[[deprecated("will be removed")]]
146 virtual void GetDerivatives(const G4FieldTrack& track,
147 G4double dydx[],
148 G4double field[]) const = 0;
149
150 //[[deprecated("use GetEquationOfMotion() instead of GetStepper()->GetEquationOfMotion()")]]
151 virtual const G4MagIntegratorStepper* GetStepper() const = 0;
153
154 //[[deprecated("will be removed")]]
155 virtual G4double ComputeNewStepSize(G4double errMaxNorm, // normalised error
156 G4double hstepCurrent) = 0;
157 // Taking the last step's normalised error, calculate
158 // a step size for the next step.
159 // - Can limit the next step's size within a factor of the current one.
160
161 protected:
162
163 static constexpr G4double max_stepping_increase = 5;
164 static constexpr G4double max_stepping_decrease = 0.1;
165};
166
167#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4EquationOfMotion is the abstract base class for the right hand size of the equation of motion of a ...
G4FieldTrack defines a data structure bringing together a magnetic track's state (position,...
G4MagIntegratorStepper is an abstract base class for integrator of particle's equation of motion,...
virtual ~G4VIntegrationDriver()=default
virtual G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance)=0
virtual void RenewStepperAndAdjust(G4MagIntegratorStepper *pItsStepper)
static constexpr G4double max_stepping_decrease
virtual G4int GetVerboseLevel() const =0
virtual const G4MagIntegratorStepper * GetStepper() const =0
virtual G4EquationOfMotion * GetEquationOfMotion()=0
virtual G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent)=0
virtual G4bool DoesReIntegrate() const =0
virtual void SetVerboseLevel(G4int level)=0
virtual G4MagIntegratorStepper * GetStepper()=0
virtual void StreamInfo(std::ostream &os) const =0
virtual G4bool QuickAdvance(G4FieldTrack &, const G4double[], G4double, G4double &, G4double &)
virtual void SetEquationOfMotion(G4EquationOfMotion *equation)=0
virtual void GetDerivatives(const G4FieldTrack &track, G4double dydx[]) const =0
static constexpr G4double max_stepping_increase
virtual void OnComputeStep(const G4FieldTrack *=nullptr)=0
virtual void GetDerivatives(const G4FieldTrack &track, G4double dydx[], G4double field[]) const =0
virtual G4bool AccurateAdvance(G4FieldTrack &track, G4double hstep, G4double eps, G4double hinitial=0)=0
virtual void OnStartTracking()=0
friend std::ostream & operator<<(std::ostream &os, const G4VIntegrationDriver &id)