Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4NystromRK4.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 // $Id: G4NystromRK4.hh 106565 2017-10-13 09:20:14Z gcosmo $
27 //
28 // class G4NystromRK4
29 //
30 // Class description:
31 //
32 // Integrate the equations of the motion of a particle in a magnetic field
33 // using 4th Runge-Kutta-Nystrom method with errors estimation
34 // (ATL-SOFT-PUB-2009-01)
35 // Current form can be used only for 'pure' magnetic field.
36 // Notes: 1) field must be time-independent.
37 // 2) time is not integrated
38 //
39 // History:
40 // - Created: I.Gavrilenko 15.05.2009 (as G4AtlasRK4)
41 // - Adaptations: J. Apostolakis May-Nov 2009
42 // -------------------------------------------------------------------
43 
44 #ifndef G4NYSTROMRK4_HH
45 #define G4NYSTROMRK4_HH
46 
47 #include "globals.hh"
49 #include "G4Mag_EqRhs.hh"
50 
52 {
53  public:
54  G4NystromRK4(G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0);
55  // Can be used only for Magnetic Fields - and for 6 variables (x,p)
56 
57  ~G4NystromRK4() ;
58 
59  void Stepper(const G4double P [],
60  const G4double dPdS[],
61  G4double step ,
62  G4double Po [],
63  G4double Err []);
64  // Single call for integration result and error
65  // - Provides Error via analytical method
66 
67  virtual void ComputeRightHandSide(const G4double P[],G4double dPdS[]);
68  // Must compute RHS - and does caches result
69 
70  void SetDistanceForConstantField( G4double length );
72 
73  G4int IntegratorOrder() const {return 4;}
74  G4double DistChord() const;
75 
76  private:
77 
78  inline void getField (const G4double P[4]);
79 
80  G4bool CheckCachedMomemtum( const G4double PosMom[6], G4double savedMom );
81  G4bool CheckFieldPosition( const G4double Position[3],
82  const G4double lastPosition[3] );
83 
85  // Private data
87 
88  G4Mag_EqRhs* m_fEq;
89  G4double m_lastField[3];
90  G4double m_fldPosition[4];
91  G4double m_magdistance ;
92  G4double m_magdistance2;
93  G4double m_cof ;
94  G4double m_mom ;
95  G4double m_imom ;
96  G4bool m_cachedMom ;
97  G4double m_iPoint [3];
98  G4double m_mPoint [3];
99  G4double m_fPoint [3];
100 
101 };
102 
104 // Inline methods
107 {
108  m_magdistance= length;
109  m_magdistance2 = length*length;
110 }
111 
113 {
114  return m_magdistance;
115 }
116 
118 // Get value of magnetic field while checking distance from last stored call
120 
121 inline void G4NystromRK4::getField (const G4double P[4])
122 {
123 
124  G4double dx = P[0]-m_fldPosition[0];
125  G4double dy = P[1]-m_fldPosition[1];
126  G4double dz = P[2]-m_fldPosition[2];
127 
128  if((dx*dx+dy*dy+dz*dz) > m_magdistance2)
129  {
130  m_fldPosition[0] = P[0];
131  m_fldPosition[1] = P[1];
132  m_fldPosition[2] = P[2];
133  m_fldPosition[3] = P[3]; // Generally it is P[7] - changed convention !!
134  m_fEq->GetFieldValue(m_fldPosition, m_lastField);
135  }
136 }
137 #endif // G4NYSTROMRK4
void SetDistanceForConstantField(G4double length)
G4int IntegratorOrder() const
Definition: G4NystromRK4.hh:73
virtual void ComputeRightHandSide(const G4double P[], G4double dPdS[])
int G4int
Definition: G4Types.hh:78
static double P[]
G4NystromRK4(G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0)
Definition: G4NystromRK4.cc:41
bool G4bool
Definition: G4Types.hh:79
void GetFieldValue(const G4double Point[4], G4double Field[]) const
G4double GetDistanceForConstantField() const
G4double DistChord() const
double G4double
Definition: G4Types.hh:76
void Stepper(const G4double P[], const G4double dPdS[], G4double step, G4double Po[], G4double Err[])
Definition: G4NystromRK4.cc:73