Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RKIntegrationDriver.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// G4RKIntegrationDriver
27//
28// Class description:
29//
30// Driver class which controls the integration error of a
31// Runge-Kutta stepper
32
33// Author: Dmitry Sorokin (CERN, Google Summer of Code 2017), 20.10.2017
34// --------------------------------------------------------------------
35#ifndef G4RKINTEGRATIONDRIVER_HH
36#define G4RKINTEGRATIONDRIVER_HH
37
39
40/**
41 * @brief G4RKIntegrationDriver is a templated driver class which controls the
42 * integration error of a Runge-Kutta stepper.
43 */
44
45template <class T>
47{
48 public:
49
50 /**
51 * Constructor for G4RKIntegrationDriver.
52 * @param[in] stepper Pointer to the stepper algorithm.
53 */
55
56 /**
57 * Copy constructor and assignment operator not allowed.
58 */
61
62 /**
63 * Accessors for derivatives.
64 */
65 void GetDerivatives(const G4FieldTrack& track,
66 G4double dydx[]) const override;
67 void GetDerivatives(const G4FieldTrack& track,
68 G4double dydx[],
69 G4double field[]) const override;
70
71 /**
72 * Taking the last step's normalised error, it calculates a step size for
73 * the next step; it limits the next step's size within a factor of the
74 * current one.
75 */
76 G4double ComputeNewStepSize(G4double errMaxNorm, // normalised error
77 G4double hstepCurrent) final;
78
79 /**
80 * Getter and setter for the equation of motion.
81 */
83 void SetEquationOfMotion(G4EquationOfMotion* equation) override;
84
85 /**
86 * Accessors for the stepper.
87 */
88 const T* GetStepper() const override;
89 T* GetStepper() override;
90
91 /**
92 * Writes out to stream the parameters/state of the driver.
93 */
94 void StreamInfo( std::ostream& os ) const override;
95
96 /**
97 * Accessors.
98 */
102
104
105 void ReSetParameters(G4double safety = 0.9);
106 void SetSafety(G4double valS);
107 // i) sets the exponents (pgrow & pshrnk),
108 // using the current Stepper's order,
109 // ii) sets the safety
110
113 // Modify and Get the Maximum number of Steps that can be
114 // taken for the integration of a single segment -
115 // (ie a single call to AccurateAdvance).
116
119
120 protected:
121
122 /**
123 * Utility methods to control step size.
124 */
130
131 private:
132
133 /**
134 * Sets the stepper according to the provided one.
135 */
136 inline void RenewStepperAndAdjustImpl(T* stepper);
137
138 private:
139
140 G4int fMaxNoSteps;
141
142 /** The (default) max number of steps is Base divided by the order of Stepper. */
143 G4int fMaxStepBase;
144
145 /** Parameters used to grow and shrink trial stepsize. */
146 G4double safety;
147 G4double pshrnk; // exponent for shrinking
148 G4double pgrow; // exponent for growth
149
150 /** Maximum error values for shrinking / growing (optimisation). */
151 G4double errorConstraintShrink;
152 G4double errorConstraintGrow;
153
154 T* pIntStepper = nullptr;
155};
156
157#include "G4RKIntegrationDriver.icc"
158
159#endif
double G4double
Definition G4Types.hh:83
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,...
G4double GetSmallestFraction() const
G4RKIntegrationDriver(const G4RKIntegrationDriver &)=delete
void SetEquationOfMotion(G4EquationOfMotion *equation) override
void SetSafety(G4double valS)
const T * GetStepper() const override
void ReSetParameters(G4double safety=0.9)
T * GetStepper() override
G4double GetPgrow() const
G4RKIntegrationDriver(T *stepper)
void SetMaxNoSteps(G4int val)
void GetDerivatives(const G4FieldTrack &track, G4double dydx[], G4double field[]) const override
G4double GetPshrnk() const
G4int GetMaxNoSteps() const
G4double GrowStepSize(G4double h, G4double error) const
G4double GrowStepSize2(G4double h, G4double error2) const
void SetSmallestFraction(G4double val)
G4double ShrinkStepSize(G4double h, G4double error) const
G4double ShrinkStepSize2(G4double h, G4double error2) const
void RenewStepperAndAdjust(G4MagIntegratorStepper *stepper) override
G4double GetSafety() const
G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent) final
void StreamInfo(std::ostream &os) const override
G4EquationOfMotion * GetEquationOfMotion() override
G4RKIntegrationDriver & operator=(const G4RKIntegrationDriver &)=delete
void GetDerivatives(const G4FieldTrack &track, G4double dydx[]) const override