Geant4-11
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
G4TClassicalRK4< T_Equation, N > Class Template Reference

#include <G4TClassicalRK4.hh>

Inheritance diagram for G4TClassicalRK4< T_Equation, N >:
G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N >, T_Equation, N > G4MagIntegratorStepper

Public Member Functions

G4double DistChord () const override final
 
void DumbStepper (const G4double yIn[], const G4double dydx[], G4double h, G4double yOut[])
 
 G4TClassicalRK4 (const G4TClassicalRK4 &)=delete
 
 G4TClassicalRK4 (T_Equation *EqRhs, G4int numberOfVariables=8)
 
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])
 
G4TClassicalRK4operator= (const G4TClassicalRK4 &)=delete
 
void ResetfNORHSCalls ()
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
void RightHandSide (G4double y[], G4double dydx[])
 
void RightHandSideInl (G4double y[], G4double dydx[])
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
void Stepper (const G4double yInput[], const G4double dydx[], G4double hstep, G4double yOutput[], G4double yError[]) override final
 
virtual ~G4TClassicalRK4 ()
 

Static Public Attributes

static constexpr G4double IntegratorCorrection = 1. / ((1 << 4) - 1)
 

Protected Member Functions

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

Private Attributes

G4double dydxm [N< 8 ? 8 :N]
 
G4double dydxMid [N< 8 ? 8 :N]
 
G4double dydxt [N< 8 ? 8 :N]
 
T_Equation * fEquation_Rhs
 
G4ThreeVector fFinalPoint
 
G4ThreeVector fInitialPoint
 
G4int fIntegrationOrder = -1
 
G4bool fIsFSAL = false
 
G4ThreeVector fMidPoint
 
const G4int fNoIntegrationVariables = 0
 
unsigned long fNoRHSCalls = 0UL
 
const G4int fNoStateVariables = 0
 
G4double yInitial [N< 8 ? 8 :N]
 
G4double yMiddle [N< 8 ? 8 :N]
 
G4double yOneStep [N< 8 ? 8 :N]
 
G4double yt [N< 8 ? 8 :N]
 

Detailed Description

template<class T_Equation, unsigned int N>
class G4TClassicalRK4< T_Equation, N >

Definition at line 42 of file G4TClassicalRK4.hh.

Constructor & Destructor Documentation

◆ G4TClassicalRK4() [1/2]

template<class T_Equation , unsigned int N>
G4TClassicalRK4< T_Equation, N >::G4TClassicalRK4 ( T_Equation *  EqRhs,
G4int  numberOfVariables = 8 
)

Definition at line 85 of file G4TClassicalRK4.hh.

88 EqRhs, numberOfVariables > 8 ? numberOfVariables : 8 )
89 , fEquation_Rhs(EqRhs)
90{
91 // unsigned int noVariables = std::max(numberOfVariables, 8); // For Time .. 7+1
92 if( dynamic_cast<G4EquationOfMotion*>(EqRhs) == nullptr )
93 {
94 G4Exception("G4TClassicalRK4: constructor", "GeomField0001",
95 FatalException, "Equation is not an G4EquationOfMotion.");
96 }
97}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
T_Equation * fEquation_Rhs

References FatalException, and G4Exception().

◆ ~G4TClassicalRK4()

template<class T_Equation , unsigned int N>
virtual G4TClassicalRK4< T_Equation, N >::~G4TClassicalRK4 ( )
inlinevirtual

Definition at line 50 of file G4TClassicalRK4.hh.

50{ ; }

◆ G4TClassicalRK4() [2/2]

template<class T_Equation , unsigned int N>
G4TClassicalRK4< T_Equation, N >::G4TClassicalRK4 ( const G4TClassicalRK4< T_Equation, N > &  )
delete

Member Function Documentation

◆ DistChord()

G4double G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::DistChord
inlinefinaloverridevirtualinherited

Implements G4MagIntegratorStepper.

Definition at line 67 of file G4TMagErrorStepper.hh.

154{
155 // Estimate the maximum distance from the curve to the chord
156 //
157 // We estimate this using the distance of the midpoint to
158 // chord (the line between
159 //
160 // Method below is good only for angle deviations < 2 pi,
161 // This restriction should not a problem for the Runge cutta methods,
162 // which generally cannot integrate accurately for large angle deviations.
163 G4double distLine, distChord;
164
166 {
168 // This is a class method that gives distance of Mid
169 // from the Chord between the Initial and Final points.
170
171 distChord = distLine;
172 }
173 else
174 {
175 distChord = (fMidPoint - fInitialPoint).mag();
176 }
177
178 return distChord;
179}
double G4double
Definition: G4Types.hh:83
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)

◆ DumbStepper()

template<class T_Equation , unsigned int N>
void G4TClassicalRK4< T_Equation, N >::DumbStepper ( const G4double  yIn[],
const G4double  dydx[],
G4double  h,
G4double  yOut[] 
)
inline

Definition at line 101 of file G4TClassicalRK4.hh.

112{
113 G4double hh = h * 0.5, h6 = h / 6.0;
114
115 // Initialise time to t0, needed when it is not updated by the integration.
116 // [ Note: Only for time dependent fields (usually electric)
117 // is it neccessary to integrate the time.]
118 yt[7] = yIn[7];
119 yOut[7] = yIn[7];
120
121 for(unsigned int i = 0; i < N; ++i)
122 {
123 yt[i] = yIn[i] + hh * dydx[i]; // 1st Step K1=h*dydx
124 }
125 this->RightHandSideInl(yt, dydxt); // 2nd Step K2=h*dydxt
126
127 for(unsigned int i = 0; i < N; ++i)
128 {
129 yt[i] = yIn[i] + hh * dydxt[i];
130 }
131 this->RightHandSideInl(yt, dydxm); // 3rd Step K3=h*dydxm
132
133 for(unsigned int i = 0; i < N; ++i)
134 {
135 yt[i] = yIn[i] + h * dydxm[i];
136 dydxm[i] += dydxt[i]; // now dydxm=(K2+K3)/h
137 }
138 this->RightHandSideInl(yt, dydxt); // 4th Step K4=h*dydxt
139
140 for(unsigned int i = 0; i < N; ++i) // Final RK4 output
141 {
142 yOut[i] = yIn[i] + h6 * (dydx[i] + dydxt[i] +
143 2.0 * dydxm[i]); //+K1/6+K4/6+(K2+K3)/3
144 }
145 if(N == 12)
146 {
147 this->NormalisePolarizationVector(yOut);
148 }
149
150} // end of DumbStepper ....................................................
void NormalisePolarizationVector(G4double vec[12])
G4double dydxm[N< 8 ? 8 :N]
G4double dydxt[N< 8 ? 8 :N]
G4double yt[N< 8 ? 8 :N]
void RightHandSideInl(G4double y[], G4double dydx[])

◆ 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()

template<class T_Equation , unsigned int N>
G4int G4TClassicalRK4< T_Equation, N >::IntegratorOrder ( ) const
inlinevirtual

Implements G4MagIntegratorStepper.

Definition at line 68 of file G4TClassicalRK4.hh.

68{ return 4; }

◆ IsFSAL()

G4bool G4MagIntegratorStepper::IsFSAL ( ) const
inlineinherited

◆ NormalisePolarizationVector()

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

◆ NormaliseTangentVector()

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

◆ operator=()

template<class T_Equation , unsigned int N>
G4TClassicalRK4 & G4TClassicalRK4< T_Equation, N >::operator= ( const G4TClassicalRK4< T_Equation, N > &  )
delete

◆ ResetfNORHSCalls()

void G4MagIntegratorStepper::ResetfNORHSCalls ( )
inlineinherited

◆ RightHandSide() [1/3]

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

◆ RightHandSide() [2/3]

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

◆ RightHandSide() [3/3]

void G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::RightHandSide ( G4double  y[],
G4double  dydx[] 
)
inlineinherited

Definition at line 59 of file G4TMagErrorStepper.hh.

60 {
61 fEquation_Rhs->T_Equation::RightHandSide(y, dydx);
62 }

◆ RightHandSideInl()

template<class T_Equation , unsigned int N>
void G4TClassicalRK4< T_Equation, N >::RightHandSideInl ( G4double  y[],
G4double  dydx[] 
)
inline

Definition at line 52 of file G4TClassicalRK4.hh.

54 {
55 fEquation_Rhs->T_Equation::RightHandSide(y, dydx);
56 }

References G4TClassicalRK4< T_Equation, N >::fEquation_Rhs.

◆ SetEquationOfMotion()

void G4MagIntegratorStepper::SetEquationOfMotion ( G4EquationOfMotion newEquation)
inlineinherited

◆ SetFSAL()

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

◆ SetIntegrationOrder()

void G4MagIntegratorStepper::SetIntegrationOrder ( G4int  order)
inlineprotectedinherited

◆ Stepper()

void G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::Stepper ( const G4double  yInput[],
const G4double  dydx[],
G4double  hstep,
G4double  yOutput[],
G4double  yError[] 
)
inlinefinaloverridevirtualinherited

Implements G4MagIntegratorStepper.

Definition at line 64 of file G4TMagErrorStepper.hh.

104{
105 const unsigned int maxvar = GetNumberOfStateVariables();
106
107 // Saving yInput because yInput and yOutput can be aliases for same array
108 for(unsigned int i = 0; i < N; ++i)
109 yInitial[i] = yInput[i];
110 yInitial[7] =
111 yInput[7]; // Copy the time in case ... even if not really needed
112 yMiddle[7] = yInput[7]; // Copy the time from initial value
113 yOneStep[7] = yInput[7]; // As it contributes to final value of yOutput ?
114 // yOutput[7] = yInput[7]; // -> dumb stepper does it too for RK4
115 for(unsigned int i = N; i < maxvar; ++i)
116 yOutput[i] = yInput[i];
117
118 G4double halfStep = hstep * 0.5;
119
120 // Do two half steps
121
122 static_cast<T_Stepper*>(this)->DumbStepper(yInitial, dydx, halfStep,
123 yMiddle);
125 static_cast<T_Stepper*>(this)->DumbStepper(yMiddle, dydxMid, halfStep,
126 yOutput);
127
128 // Store midpoint, chord calculation
129
131
132 // Do a full Step
133 static_cast<T_Stepper*>(this)->DumbStepper(yInitial, dydx, hstep, yOneStep);
134 for(unsigned int i = 0; i < N; ++i)
135 {
136 yError[i] = yOutput[i] - yOneStep[i];
137 yOutput[i] +=
138 yError[i] *
139 T_Stepper::IntegratorCorrection; // Provides accuracy increased
140 // by 1 order via the
141 // Richardson Extrapolation
142 }
143
145 fFinalPoint = G4ThreeVector(yOutput[0], yOutput[1], yOutput[2]);
146
147 return;
148}
CLHEP::Hep3Vector G4ThreeVector
G4int GetNumberOfStateVariables() const

Field Documentation

◆ dydxm

template<class T_Equation , unsigned int N>
G4double G4TClassicalRK4< T_Equation, N >::dydxm[N< 8 ? 8 :N]
private

Definition at line 76 of file G4TClassicalRK4.hh.

◆ dydxMid

G4double G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::dydxMid[N< 8 ? 8 :N]
privateinherited

Definition at line 82 of file G4TMagErrorStepper.hh.

◆ dydxt

template<class T_Equation , unsigned int N>
G4double G4TClassicalRK4< T_Equation, N >::dydxt[N< 8 ? 8 :N]
private

Definition at line 77 of file G4TClassicalRK4.hh.

◆ fEquation_Rhs

template<class T_Equation , unsigned int N>
T_Equation* G4TClassicalRK4< T_Equation, N >::fEquation_Rhs
private

◆ fFinalPoint

G4ThreeVector G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::fFinalPoint
privateinherited

Definition at line 76 of file G4TMagErrorStepper.hh.

◆ fInitialPoint

G4ThreeVector G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::fInitialPoint
privateinherited

Definition at line 76 of file G4TMagErrorStepper.hh.

◆ 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 G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::fMidPoint
privateinherited

Definition at line 76 of file G4TMagErrorStepper.hh.

◆ 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.

◆ IntegratorCorrection

template<class T_Equation , unsigned int N>
constexpr G4double G4TClassicalRK4< T_Equation, N >::IntegratorCorrection = 1. / ((1 << 4) - 1)
staticconstexpr

Definition at line 46 of file G4TClassicalRK4.hh.

◆ yInitial

G4double G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::yInitial[N< 8 ? 8 :N]
privateinherited

Definition at line 80 of file G4TMagErrorStepper.hh.

◆ yMiddle

G4double G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::yMiddle[N< 8 ? 8 :N]
privateinherited

Definition at line 81 of file G4TMagErrorStepper.hh.

◆ yOneStep

G4double G4TMagErrorStepper< G4TClassicalRK4< T_Equation, N > , T_Equation, N >::yOneStep[N< 8 ? 8 :N]
privateinherited

Definition at line 83 of file G4TMagErrorStepper.hh.

◆ yt

template<class T_Equation , unsigned int N>
G4double G4TClassicalRK4< T_Equation, N >::yt[N< 8 ? 8 :N]
private

Definition at line 78 of file G4TClassicalRK4.hh.


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