ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4BulirschStoer.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4BulirschStoer.hh
1 // ********************************************************************
2 // * License and Disclaimer *
3 // * *
4 // * The Geant4 software is copyright of the Copyright Holders of *
5 // * the Geant4 Collaboration. It is provided under the terms and *
6 // * conditions of the Geant4 Software License, included in the file *
7 // * LICENSE and available at http://cern.ch/geant4/license . These *
8 // * include a list of copyright holders. *
9 // * *
10 // * Neither the authors of this software system, nor their employing *
11 // * institutes,nor the agencies providing financial support for this *
12 // * work make any representation or warranty, express or implied, *
13 // * regarding this software system or assume any liability for its *
14 // * use. Please see the license in the file LICENSE and URL above *
15 // * for the full disclaimer and the limitation of liability. *
16 // * *
17 // * This code implementation is the result of the scientific and *
18 // * technical work of the GEANT4 collaboration. *
19 // * By using, copying, modifying or distributing the software (or *
20 // * any work based on the software) you agree to acknowledge its *
21 // * use in resulting scientific publications, and indicate your *
22 // * acceptance of all terms of the Geant4 Software license. *
23 // ********************************************************************
24 //
25 // G4BulirschStoer
26 //
27 // Class description:
28 //
29 // The Bulirsch-Stoer is a controlled driver that adjusts both step size
30 // and order of the method. The algorithm uses the modified midpoint and
31 // a polynomial extrapolation computes the solution.
32 
33 // Author: Dmitry Sorokin, Google Summer of Code 2016
34 // Supervision: John Apostolakis, CERN
35 // --------------------------------------------------------------------
36 #ifndef G4BULIRSCH_STOER_HH
37 #define G4BULIRSCH_STOER_HH
38 
39 #include "G4ModifiedMidpoint.hh"
40 
41 #include "G4FieldTrack.hh"
42 
44 {
45  public:
46 
47  enum class step_result
48  {
49  success,
50  fail
51  };
52 
53  G4BulirschStoer( G4EquationOfMotion* equation, G4int nvar,
54  G4double eps_rel, G4double max_dt = DBL_MAX);
55 
56  inline void set_max_dt(G4double max_dt);
57  inline void set_max_relative_error(G4double eps_rel);
58 
59  // Stepper method
60  //
61  step_result try_step(const G4double in[], const G4double dxdt[],
62  G4double& t, G4double out[], G4double& dt);
63 
64  // Reset the internal state of the stepper
65  //
66  void reset();
67 
68  inline void SetEquationOfMotion(G4EquationOfMotion* equation);
70 
71  inline G4int GetNumberOfVariables() const;
72 
73  private:
74 
75  const static G4int m_k_max = 8;
76 
77  void extrapolate(size_t k, G4double xest[]);
78  G4double calc_h_opt(G4double h, G4double error, size_t k) const;
79 
80  G4bool set_k_opt(size_t k, G4double& dt);
83 
84  // Number of vars to be integrated
86 
87  // Relative tolerance
89 
90  // Modified midpoint algorithm
92 
95 
97  // G4double m_t_last;
98 
99  // Max allowed time step
101 
103 
104  // G4double m_xnew[G4FieldTrack::ncompSVEC];
106  // G4double m_dxdt[G4FieldTrack::ncompSVEC];
107 
108  // Stores the successive interval counts
110 
111  // Extrapolation coeffs (Neville’s algorithm)
113 
114  // Costs for interval count
116 
117  // Sequence of states for extrapolation
119 
120  // Optimal step size
122 
123  // Work per unit step
125 };
126 
127 #include "G4BulirschStoer.icc"
128 
129 #endif