ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RKIntegrationDriver.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RKIntegrationDriver.hh
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 // Created: D.Sorokin, 2017
34 // --------------------------------------------------------------------
35 #ifndef G4RKINTEGRATIONDRIVER_HH
36 #define G4RKINTEGRATIONDRIVER_HH
37 
38 #include "G4VIntegrationDriver.hh"
39 
40 template <class T>
42 {
43  public:
44 
46 
49 
50  virtual void GetDerivatives(const G4FieldTrack& track,
51  G4double dydx[]) const override;
52 
53  virtual void GetDerivatives(const G4FieldTrack& track,
54  G4double dydx[],
55  G4double field[]) const override;
56 
57  virtual G4double ComputeNewStepSize(G4double errMaxNorm, // normalised error
58  G4double hstepCurrent) override;
59  // Taking the last step's normalised error, calculate
60  // a step size for the next step.
61  // Do not limit the next step's size within a factor of the current one.
62 
63  virtual G4EquationOfMotion* GetEquationOfMotion() override;
64  virtual void SetEquationOfMotion(G4EquationOfMotion* equation) override;
65 
66  virtual const T* GetStepper() const override;
67  virtual T* GetStepper() override;
68 
69  // Accessors.
70  G4double GetSafety() const;
71  G4double GetPshrnk() const;
72  G4double GetPgrow() const;
73 
74  virtual void RenewStepperAndAdjust(G4MagIntegratorStepper* stepper) override;
75 
76  void ReSetParameters(G4double safety = 0.9);
77  void SetSafety(G4double valS);
78  // i) sets the exponents (pgrow & pshrnk),
79  // using the current Stepper's order,
80  // ii) sets the safety
81 
82  G4int GetMaxNoSteps() const;
83  void SetMaxNoSteps(G4int val);
84  // Modify and Get the Maximum number of Steps that can be
85  // taken for the integration of a single segment -
86  // (ie a single call to AccurateAdvance).
87 
89  void SetSmallestFraction(G4double val);
90 
91  protected:
92 
94  G4double GrowStepSize(G4double h, G4double error) const;
95 
96  G4double ShrinkStepSize2(G4double h, G4double error2) const;
97  G4double GrowStepSize2(G4double h, G4double error2) const;
98 
100 
101  private:
102 
103  inline void RenewStepperAndAdjustImpl(T* stepper);
104 
106 
108  // The (default) maximum number of steps is Base
109  // divided by the order of Stepper
110 
111  // Parameters used to grow and shrink trial stepsize.
112  //
114  G4double pshrnk; // exponent for shrinking
115  G4double pgrow; // exponent for growth
116 
117  // muximum error values for shrinking / growing (optimisation).
118  //
121 
122  T* pIntStepper = nullptr;
123 };
124 
125 #include "G4RKIntegrationDriver.icc"
126 
127 #endif