00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef G4CONSTRK4_HH
00045 #define G4CONSTRK4_HH
00046
00047 #include "G4MagErrorStepper.hh"
00048 #include "G4EquationOfMotion.hh"
00049 #include "G4Mag_EqRhs.hh"
00050
00051 class G4ConstRK4 : public G4MagErrorStepper
00052 {
00053 public:
00054
00055 G4ConstRK4(G4Mag_EqRhs *EquationMotion, G4int numberOfStateVariables=8);
00056 ~G4ConstRK4();
00057
00058 void Stepper( const G4double y[],
00059 const G4double dydx[],
00060 G4double h,
00061 G4double yout[],
00062 G4double yerr[] );
00063 void DumbStepper( const G4double yIn[],
00064 const G4double dydx[],
00065 G4double h,
00066 G4double yOut[] ) ;
00067 G4double DistChord() const;
00068
00069 inline void RightHandSideConst(const G4double y[],
00070 G4double dydx[] ) const;
00071
00072 inline void GetConstField(const G4double y[],G4double Field[]);
00073
00074 public:
00075
00076 G4int IntegratorOrder() const { return 4; }
00077
00078 private:
00079
00080 G4ConstRK4(const G4ConstRK4&);
00081 G4ConstRK4& operator=(const G4ConstRK4&);
00082
00083
00084 private:
00085
00086 G4ThreeVector fInitialPoint, fMidPoint, fFinalPoint;
00087
00088 G4double *dydxm, *dydxt, *yt;
00089 G4double *yInitial, *yMiddle, *dydxMid, *yOneStep;
00090 G4Mag_EqRhs *fEq;
00091 G4double Field[3];
00092 };
00093
00094
00095
00096 inline void G4ConstRK4:: RightHandSideConst(const G4double y[],
00097 G4double dydx[] ) const
00098 {
00099
00100 G4double momentum_mag_square = y[3]*y[3] + y[4]*y[4] + y[5]*y[5];
00101 G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
00102
00103 G4double cof =fEq->FCof()*inv_momentum_magnitude;
00104
00105 dydx[0] = y[3]*inv_momentum_magnitude;
00106 dydx[1] = y[4]*inv_momentum_magnitude;
00107 dydx[2] = y[5]*inv_momentum_magnitude;
00108
00109 dydx[3] = cof*(y[4]*Field[2] - y[5]*Field[1]) ;
00110 dydx[4] = cof*(y[5]*Field[0] - y[3]*Field[2]) ;
00111 dydx[5] = cof*(y[3]*Field[1] - y[4]*Field[0]) ;
00112 }
00113
00114 inline void G4ConstRK4::GetConstField(const G4double y[],G4double B[])
00115 {
00116 G4double PositionAndTime[4];
00117
00118 PositionAndTime[0] = y[0];
00119 PositionAndTime[1] = y[1];
00120 PositionAndTime[2] = y[2];
00121
00122 PositionAndTime[3] = y[7];
00123 fEq -> GetFieldValue(PositionAndTime, B) ;
00124 }
00125
00126 #endif // G4CONSTRK4_HH