Geant4-11
Public Member Functions | Protected Member Functions | Private Attributes
G4ConstRK4 Class Reference

#include <G4ConstRK4.hh>

Inheritance diagram for G4ConstRK4:
G4MagErrorStepper G4MagIntegratorStepper

Public Member Functions

G4double DistChord () const
 
void DumbStepper (const G4double yIn[], const G4double dydx[], G4double h, G4double yOut[])
 
 G4ConstRK4 (const G4ConstRK4 &)=delete
 
 G4ConstRK4 (G4Mag_EqRhs *EquationMotion, G4int numberOfStateVariables=8)
 
void GetConstField (const G4double y[], G4double Field[])
 
G4EquationOfMotionGetEquationOfMotion ()
 
const G4EquationOfMotionGetEquationOfMotion () const
 
unsigned long GetfNoRHSCalls ()
 
G4int GetNumberOfStateVariables () const
 
G4int GetNumberOfVariables () const
 
G4int IntegrationOrder ()
 
G4int IntegratorOrder () const
 
G4bool IsFSAL () const
 
void NormalisePolarizationVector (G4double vec[12])
 
void NormaliseTangentVector (G4double vec[6])
 
G4ConstRK4operator= (const G4ConstRK4 &)=delete
 
void ResetfNORHSCalls ()
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
void RightHandSideConst (const G4double y[], G4double dydx[]) const
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
void Stepper (const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
 
 ~G4ConstRK4 ()
 

Protected Member Functions

void SetFSAL (G4bool flag=true)
 
void SetIntegrationOrder (G4int order)
 

Private Attributes

G4doubledydxm
 
G4doubledydxMid
 
G4doubledydxt
 
G4Mag_EqRhsfEq = nullptr
 
G4EquationOfMotionfEquation_Rhs = nullptr
 
G4ThreeVector fFinalPoint
 
G4double Field [3]
 
G4ThreeVector fInitialPoint
 
G4int fIntegrationOrder = -1
 
G4bool fIsFSAL = false
 
G4ThreeVector fMidPoint
 
const G4int fNoIntegrationVariables = 0
 
unsigned long fNoRHSCalls = 0UL
 
const G4int fNoStateVariables = 0
 
G4doubleyInitial
 
G4doubleyMiddle
 
G4doubleyOneStep
 
G4doubleyt
 

Detailed Description

Definition at line 45 of file G4ConstRK4.hh.

Constructor & Destructor Documentation

◆ G4ConstRK4() [1/2]

G4ConstRK4::G4ConstRK4 ( G4Mag_EqRhs EquationMotion,
G4int  numberOfStateVariables = 8 
)

Definition at line 40 of file G4ConstRK4.cc.

41 : G4MagErrorStepper(EqRhs, 6, numStateVariables)
42{
43 // const G4int numberOfVariables= 6;
44 if( numStateVariables < 8 )
45 {
46 std::ostringstream message;
47 message << "The number of State variables at least 8 " << G4endl
48 << "Instead it is - numStateVariables= " << numStateVariables;
49 G4Exception("G4ConstRK4::G4ConstRK4()", "GeomField0002",
50 FatalException, message, "Use another Stepper!");
51 }
52
53 fEq = EqRhs;
54 yMiddle = new G4double[8];
55 dydxMid = new G4double[8];
56 yInitial = new G4double[8];
57 yOneStep = new G4double[8];
58
59 dydxm = new G4double[8];
60 dydxt = new G4double[8];
61 yt = new G4double[8];
62 Field[0]=0.; Field[1]=0.; Field[2]=0.;
63}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4double * dydxMid
Definition: G4ConstRK4.hh:81
G4Mag_EqRhs * fEq
Definition: G4ConstRK4.hh:82
G4double * dydxm
Definition: G4ConstRK4.hh:80
G4double * yt
Definition: G4ConstRK4.hh:80
G4double * yMiddle
Definition: G4ConstRK4.hh:81
G4double Field[3]
Definition: G4ConstRK4.hh:83
G4double * dydxt
Definition: G4ConstRK4.hh:80
G4double * yOneStep
Definition: G4ConstRK4.hh:81
G4double * yInitial
Definition: G4ConstRK4.hh:81
G4MagErrorStepper(G4EquationOfMotion *EqRhs, G4int numberOfVariables, G4int numStateVariables=12)

References dydxm, dydxMid, dydxt, FatalException, fEq, Field, G4endl, G4Exception(), yInitial, yMiddle, yOneStep, and yt.

◆ ~G4ConstRK4()

G4ConstRK4::~G4ConstRK4 ( )

Definition at line 69 of file G4ConstRK4.cc.

70{
71 delete [] yMiddle;
72 delete [] dydxMid;
73 delete [] yInitial;
74 delete [] yOneStep;
75 delete [] dydxm;
76 delete [] dydxt;
77 delete [] yt;
78}

References dydxm, dydxMid, dydxt, yInitial, yMiddle, yOneStep, and yt.

◆ G4ConstRK4() [2/2]

G4ConstRK4::G4ConstRK4 ( const G4ConstRK4 )
delete

Member Function Documentation

◆ DistChord()

G4double G4ConstRK4::DistChord ( ) const
virtual

Implements G4MagIntegratorStepper.

Definition at line 211 of file G4ConstRK4.cc.

212{
213 G4double distLine, distChord;
214
216 {
218 // This is a class method that gives distance of Mid
219 // from the Chord between the Initial and Final points
220 distChord = distLine;
221 }
222 else
223 {
224 distChord = (fMidPoint-fInitialPoint).mag();
225 }
226 return distChord;
227}
G4ThreeVector fInitialPoint
Definition: G4ConstRK4.hh:78
G4ThreeVector fMidPoint
Definition: G4ConstRK4.hh:78
G4ThreeVector fFinalPoint
Definition: G4ConstRK4.hh:78
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)

References G4LineSection::Distline(), fFinalPoint, fInitialPoint, and fMidPoint.

◆ DumbStepper()

void G4ConstRK4::DumbStepper ( const G4double  yIn[],
const G4double  dydx[],
G4double  h,
G4double  yOut[] 
)
virtual

Implements G4MagErrorStepper.

Definition at line 90 of file G4ConstRK4.cc.

94{
95 G4double hh = h*0.5 , h6 = h/6.0 ;
96
97 // 1st Step K1=h*dydx
98 yt[5] = yIn[5] + hh*dydx[5] ;
99 yt[4] = yIn[4] + hh*dydx[4] ;
100 yt[3] = yIn[3] + hh*dydx[3] ;
101 yt[2] = yIn[2] + hh*dydx[2] ;
102 yt[1] = yIn[1] + hh*dydx[1] ;
103 yt[0] = yIn[0] + hh*dydx[0] ;
105
106 // 2nd Step K2=h*dydxt
107 yt[5] = yIn[5] + hh*dydxt[5] ;
108 yt[4] = yIn[4] + hh*dydxt[4] ;
109 yt[3] = yIn[3] + hh*dydxt[3] ;
110 yt[2] = yIn[2] + hh*dydxt[2] ;
111 yt[1] = yIn[1] + hh*dydxt[1] ;
112 yt[0] = yIn[0] + hh*dydxt[0] ;
114
115 // 3rd Step K3=h*dydxm
116 // now dydxm=(K2+K3)/h
117 yt[5] = yIn[5] + h*dydxm[5] ;
118 dydxm[5] += dydxt[5] ;
119 yt[4] = yIn[4] + h*dydxm[4] ;
120 dydxm[4] += dydxt[4] ;
121 yt[3] = yIn[3] + h*dydxm[3] ;
122 dydxm[3] += dydxt[3] ;
123 yt[2] = yIn[2] + h*dydxm[2] ;
124 dydxm[2] += dydxt[2] ;
125 yt[1] = yIn[1] + h*dydxm[1] ;
126 dydxm[1] += dydxt[1] ;
127 yt[0] = yIn[0] + h*dydxm[0] ;
128 dydxm[0] += dydxt[0] ;
130
131 // 4th Step K4=h*dydxt
132 yOut[5] = yIn[5]+h6*(dydx[5]+dydxt[5]+2.0*dydxm[5]);
133 yOut[4] = yIn[4]+h6*(dydx[4]+dydxt[4]+2.0*dydxm[4]);
134 yOut[3] = yIn[3]+h6*(dydx[3]+dydxt[3]+2.0*dydxm[3]);
135 yOut[2] = yIn[2]+h6*(dydx[2]+dydxt[2]+2.0*dydxm[2]);
136 yOut[1] = yIn[1]+h6*(dydx[1]+dydxt[1]+2.0*dydxm[1]);
137 yOut[0] = yIn[0]+h6*(dydx[0]+dydxt[0]+2.0*dydxm[0]);
138
139} // end of DumbStepper ....................................................
void RightHandSideConst(const G4double y[], G4double dydx[]) const
Definition: G4ConstRK4.hh:88

References dydxm, dydxt, RightHandSideConst(), and yt.

Referenced by Stepper().

◆ GetConstField()

void G4ConstRK4::GetConstField ( const G4double  y[],
G4double  Field[] 
)
inline

Definition at line 106 of file G4ConstRK4.hh.

107{
108 G4double PositionAndTime[4];
109
110 PositionAndTime[0] = y[0];
111 PositionAndTime[1] = y[1];
112 PositionAndTime[2] = y[2];
113 // Global Time
114 PositionAndTime[3] = y[7];
115 fEq -> GetFieldValue(PositionAndTime, B);
116}
G4double B(G4double temperature)

References B(), and fEq.

Referenced by Stepper().

◆ GetEquationOfMotion() [1/2]

G4EquationOfMotion * G4MagIntegratorStepper::GetEquationOfMotion ( )
inlineinherited

◆ GetEquationOfMotion() [2/2]

const G4EquationOfMotion * G4MagIntegratorStepper::GetEquationOfMotion ( ) const
inlineinherited

◆ GetfNoRHSCalls()

unsigned long G4MagIntegratorStepper::GetfNoRHSCalls ( )
inlineinherited

◆ GetNumberOfStateVariables()

G4int G4MagIntegratorStepper::GetNumberOfStateVariables ( ) const
inlineinherited

◆ GetNumberOfVariables()

G4int G4MagIntegratorStepper::GetNumberOfVariables ( ) const
inlineinherited

◆ IntegrationOrder()

G4int G4MagIntegratorStepper::IntegrationOrder ( )
inlineinherited

◆ IntegratorOrder()

G4int G4ConstRK4::IntegratorOrder ( ) const
inlinevirtual

Implements G4MagIntegratorStepper.

Definition at line 74 of file G4ConstRK4.hh.

74{ return 4; }

Referenced by Stepper().

◆ IsFSAL()

G4bool G4MagIntegratorStepper::IsFSAL ( ) const
inlineinherited

◆ NormalisePolarizationVector()

void G4MagIntegratorStepper::NormalisePolarizationVector ( G4double  vec[12])
inlineinherited

◆ NormaliseTangentVector()

void G4MagIntegratorStepper::NormaliseTangentVector ( G4double  vec[6])
inlineinherited

◆ operator=()

G4ConstRK4 & G4ConstRK4::operator= ( const G4ConstRK4 )
delete

◆ ResetfNORHSCalls()

void G4MagIntegratorStepper::ResetfNORHSCalls ( )
inlineinherited

◆ RightHandSide() [1/2]

void G4MagIntegratorStepper::RightHandSide ( const G4double  y[],
G4double  dydx[] 
) const
inlineinherited

◆ RightHandSide() [2/2]

void G4MagIntegratorStepper::RightHandSide ( const G4double  y[],
G4double  dydx[],
G4double  field[] 
) const
inlineinherited

◆ RightHandSideConst()

void G4ConstRK4::RightHandSideConst ( const G4double  y[],
G4double  dydx[] 
) const
inline

Definition at line 88 of file G4ConstRK4.hh.

90{
91
92 G4double momentum_mag_square = y[3]*y[3] + y[4]*y[4] + y[5]*y[5];
93 G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
94
95 G4double cof = fEq->FCof()*inv_momentum_magnitude;
96
97 dydx[0] = y[3]*inv_momentum_magnitude; // (d/ds)x = Vx/V
98 dydx[1] = y[4]*inv_momentum_magnitude; // (d/ds)y = Vy/V
99 dydx[2] = y[5]*inv_momentum_magnitude; // (d/ds)z = Vz/V
100
101 dydx[3] = cof*(y[4]*Field[2] - y[5]*Field[1]) ; // Ax = a*(Vy*Bz - Vz*By)
102 dydx[4] = cof*(y[5]*Field[0] - y[3]*Field[2]) ; // Ay = a*(Vz*Bx - Vx*Bz)
103 dydx[5] = cof*(y[3]*Field[1] - y[4]*Field[0]) ; // Az = a*(Vx*By - Vy*Bx)
104}
G4double FCof() const
Definition: G4Mag_EqRhs.hh:62

References G4Mag_EqRhs::FCof(), fEq, and Field.

Referenced by DumbStepper(), and Stepper().

◆ SetEquationOfMotion()

void G4MagIntegratorStepper::SetEquationOfMotion ( G4EquationOfMotion newEquation)
inlineinherited

◆ SetFSAL()

void G4MagIntegratorStepper::SetFSAL ( G4bool  flag = true)
inlineprotectedinherited

◆ SetIntegrationOrder()

void G4MagIntegratorStepper::SetIntegrationOrder ( G4int  order)
inlineprotectedinherited

◆ Stepper()

void G4ConstRK4::Stepper ( const G4double  y[],
const G4double  dydx[],
G4double  h,
G4double  yout[],
G4double  yerr[] 
)
virtual

Implements G4MagIntegratorStepper.

Definition at line 146 of file G4ConstRK4.cc.

151{
152 const G4int nvar = 6; // number of variables integrated
153 const G4int maxvar = GetNumberOfStateVariables();
154
155 // Correction for Richardson extrapolation
156 G4double correction = 1. / ( (1 << IntegratorOrder()) -1 );
157
158 G4int i;
159
160 // Saving yInput because yInput and yOutput can be aliases for same array
161 for (i=0; i<maxvar; ++i) { yInitial[i]= yInput[i]; }
162
163 // Must copy the part of the state *not* integrated to the output
164 for (i=nvar; i<maxvar; ++i) { yOutput[i]= yInput[i]; }
165
166 // yInitial[7]= yInput[7]; // The time is typically needed
167 yMiddle[7] = yInput[7]; // Copy the time from initial value
168 yOneStep[7] = yInput[7]; // As it contributes to final value of yOutput ?
169 // yOutput[7] = yInput[7]; // -> dumb stepper does it too for RK4
170 yError[7] = 0.0;
171
172 G4double halfStep = hstep * 0.5;
173
174 // Do two half steps
175 //
177 DumbStepper (yInitial, dydx, halfStep, yMiddle);
179 DumbStepper (yMiddle, dydxMid, halfStep, yOutput);
180
181 // Store midpoint, chord calculation
182 //
184
185 // Do a full Step
186 //
187 DumbStepper(yInitial, dydx, hstep, yOneStep);
188 for(i=0; i<nvar; ++i)
189 {
190 yError [i] = yOutput[i] - yOneStep[i] ;
191 yOutput[i] += yError[i]*correction ;
192 // Provides accuracy increased by 1 order via the
193 // Richardson extrapolation
194 }
195
197 fFinalPoint = G4ThreeVector( yOutput[0], yOutput[1], yOutput[2]);
198
199 return;
200}
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition: G4Types.hh:85
void DumbStepper(const G4double yIn[], const G4double dydx[], G4double h, G4double yOut[])
Definition: G4ConstRK4.cc:90
G4int IntegratorOrder() const
Definition: G4ConstRK4.hh:74
void GetConstField(const G4double y[], G4double Field[])
Definition: G4ConstRK4.hh:106
G4int GetNumberOfStateVariables() const

References DumbStepper(), dydxMid, fFinalPoint, Field, fInitialPoint, fMidPoint, GetConstField(), G4MagIntegratorStepper::GetNumberOfStateVariables(), IntegratorOrder(), RightHandSideConst(), yInitial, yMiddle, and yOneStep.

Field Documentation

◆ dydxm

G4double* G4ConstRK4::dydxm
private

Definition at line 80 of file G4ConstRK4.hh.

Referenced by DumbStepper(), G4ConstRK4(), and ~G4ConstRK4().

◆ dydxMid

G4double * G4ConstRK4::dydxMid
private

Definition at line 81 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), Stepper(), and ~G4ConstRK4().

◆ dydxt

G4double * G4ConstRK4::dydxt
private

Definition at line 80 of file G4ConstRK4.hh.

Referenced by DumbStepper(), G4ConstRK4(), and ~G4ConstRK4().

◆ fEq

G4Mag_EqRhs* G4ConstRK4::fEq = nullptr
private

Definition at line 82 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), GetConstField(), and RightHandSideConst().

◆ fEquation_Rhs

G4EquationOfMotion* G4MagIntegratorStepper::fEquation_Rhs = nullptr
privateinherited

Definition at line 124 of file G4MagIntegratorStepper.hh.

◆ fFinalPoint

G4ThreeVector G4ConstRK4::fFinalPoint
private

Definition at line 78 of file G4ConstRK4.hh.

Referenced by DistChord(), and Stepper().

◆ Field

G4double G4ConstRK4::Field[3]
private

Definition at line 83 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), RightHandSideConst(), and Stepper().

◆ fInitialPoint

G4ThreeVector G4ConstRK4::fInitialPoint
private

Definition at line 78 of file G4ConstRK4.hh.

Referenced by DistChord(), and Stepper().

◆ fIntegrationOrder

G4int G4MagIntegratorStepper::fIntegrationOrder = -1
privateinherited

Definition at line 134 of file G4MagIntegratorStepper.hh.

◆ fIsFSAL

G4bool G4MagIntegratorStepper::fIsFSAL = false
privateinherited

Definition at line 136 of file G4MagIntegratorStepper.hh.

◆ fMidPoint

G4ThreeVector G4ConstRK4::fMidPoint
private

Definition at line 78 of file G4ConstRK4.hh.

Referenced by DistChord(), and Stepper().

◆ fNoIntegrationVariables

const G4int G4MagIntegratorStepper::fNoIntegrationVariables = 0
privateinherited

Definition at line 125 of file G4MagIntegratorStepper.hh.

◆ fNoRHSCalls

unsigned long G4MagIntegratorStepper::fNoRHSCalls = 0UL
mutableprivateinherited

Definition at line 128 of file G4MagIntegratorStepper.hh.

◆ fNoStateVariables

const G4int G4MagIntegratorStepper::fNoStateVariables = 0
privateinherited

Definition at line 126 of file G4MagIntegratorStepper.hh.

◆ yInitial

G4double* G4ConstRK4::yInitial
private

Definition at line 81 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), Stepper(), and ~G4ConstRK4().

◆ yMiddle

G4double * G4ConstRK4::yMiddle
private

Definition at line 81 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), Stepper(), and ~G4ConstRK4().

◆ yOneStep

G4double * G4ConstRK4::yOneStep
private

Definition at line 81 of file G4ConstRK4.hh.

Referenced by G4ConstRK4(), Stepper(), and ~G4ConstRK4().

◆ yt

G4double * G4ConstRK4::yt
private

Definition at line 80 of file G4ConstRK4.hh.

Referenced by DumbStepper(), G4ConstRK4(), and ~G4ConstRK4().


The documentation for this class was generated from the following files: