Geant4  10.00.p02
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 66356 2012-12-18 09:02:32Z 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 double P[],double 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 
81  // Private data
83 
96 
97 };
98 
100 // Inline methods
103 {
104  m_magdistance= length;
105  m_magdistance2 = length*length;
106 }
107 
109 {
110  return m_magdistance;
111 }
112 
114 // Get value of magnetic field while checking distance from last stored call
116 
117 inline void G4NystromRK4::getField (const G4double P[4])
118 {
119 
120  G4double dx = P[0]-m_fldPosition[0];
121  G4double dy = P[1]-m_fldPosition[1];
122  G4double dz = P[2]-m_fldPosition[2];
123 
124  if((dx*dx+dy*dy+dz*dz) > m_magdistance2)
125  {
126  m_fldPosition[0] = P[0];
127  m_fldPosition[1] = P[1];
128  m_fldPosition[2] = P[2];
129  m_fldPosition[3] = P[3]; // Generally it is P[7] - changed convention !!
130  m_fEq->GetFieldValue(m_fldPosition, m_lastField);
131  }
132 }
133 #endif // G4NYSTROMRK4
G4double m_iPoint[3]
Definition: G4NystromRK4.hh:93
void SetDistanceForConstantField(G4double length)
G4double m_mPoint[3]
Definition: G4NystromRK4.hh:94
G4double m_fPoint[3]
Definition: G4NystromRK4.hh:95
G4bool m_cachedMom
Definition: G4NystromRK4.hh:92
G4int IntegratorOrder() const
Definition: G4NystromRK4.hh:73
G4Mag_EqRhs * m_fEq
Definition: G4NystromRK4.hh:84
G4double m_magdistance
Definition: G4NystromRK4.hh:87
virtual void ComputeRightHandSide(const double P[], double dPdS[])
int G4int
Definition: G4Types.hh:78
G4double m_magdistance2
Definition: G4NystromRK4.hh:88
G4double m_imom
Definition: G4NystromRK4.hh:91
G4NystromRK4(G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0)
Definition: G4NystromRK4.cc:41
bool G4bool
Definition: G4Types.hh:79
G4double m_mom
Definition: G4NystromRK4.hh:90
void GetFieldValue(const G4double Point[4], G4double Field[]) const
G4double GetDistanceForConstantField() const
G4double m_fldPosition[4]
Definition: G4NystromRK4.hh:86
G4double DistChord() const
G4double m_lastField[3]
Definition: G4NystromRK4.hh:85
double G4double
Definition: G4Types.hh:76
G4double m_cof
Definition: G4NystromRK4.hh:89
void getField(const G4double P[4])
void Stepper(const G4double P[], const G4double dPdS[], G4double step, G4double Po[], G4double Err[])
Definition: G4NystromRK4.cc:73