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

#include <G4TCashKarpRKF45.hh>

Inheritance diagram for G4TCashKarpRKF45< T_Equation, N >:
G4MagIntegratorStepper

Public Member Functions

G4double DistChord () const override
 
 G4TCashKarpRKF45 (T_Equation *EqRhs, G4bool primary=true)
 
G4EquationOfMotionGetEquationOfMotion ()
 
const G4EquationOfMotionGetEquationOfMotion () const
 
unsigned long GetfNoRHSCalls ()
 
G4int GetNumberOfStateVariables () const
 
G4int GetNumberOfVariables () const
 
G4int IntegrationOrder ()
 
G4int IntegratorOrder () const override
 
G4bool IsFSAL () const
 
void NormalisePolarizationVector (G4double vec[12])
 
void NormaliseTangentVector (G4double vec[6])
 
void ResetfNORHSCalls ()
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
void RightHandSideInl (const G4double y[], G4double dydx[])
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
virtual void Stepper (const G4double yInput[], const G4double dydx[], G4double hstep, G4double yOutput[], G4double yError[]) override final
 
void StepWithError (const G4double yInput[], const G4double dydx[], G4double Step, G4double yOut[], G4double yErr[])
 
virtual ~G4TCashKarpRKF45 ()
 

Protected Member Functions

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

Private Member Functions

 G4TCashKarpRKF45 (const G4TCashKarpRKF45 &)
 
G4TCashKarpRKF45operator= (const G4TCashKarpRKF45 &)
 

Private Attributes

G4double ak2 [N]
 
G4double ak3 [N]
 
G4double ak4 [N]
 
G4double ak5 [N]
 
G4double ak6 [N]
 
G4double ak7 [N]
 
G4TCashKarpRKF45fAuxStepper = nullptr
 
T_Equation * fEquation_Rhs
 
G4int fIntegrationOrder = -1
 
G4bool fIsFSAL = false
 
G4doublefLastDyDx
 
G4doublefLastFinalVector
 
G4doublefLastInitialVector
 
G4double fLastStepLength = 0.0
 
G4doublefMidError
 
G4doublefMidVector
 
const G4int fNoIntegrationVariables = 0
 
unsigned long fNoRHSCalls = 0UL
 
const G4int fNoStateVariables = 0
 
G4double yIn [N]
 
G4double yTemp [N]
 

Detailed Description

template<class T_Equation, unsigned int N = 6>
class G4TCashKarpRKF45< T_Equation, N >

Definition at line 63 of file G4TCashKarpRKF45.hh.

Constructor & Destructor Documentation

◆ G4TCashKarpRKF45() [1/2]

template<class T_Equation , unsigned int N>
G4TCashKarpRKF45< T_Equation, N >::G4TCashKarpRKF45 ( T_Equation *  EqRhs,
G4bool  primary = true 
)

Definition at line 123 of file G4TCashKarpRKF45.hh.

125 : G4MagIntegratorStepper(dynamic_cast<G4EquationOfMotion*>(EqRhs), N )
126 , fEquation_Rhs(EqRhs)
127{
128 if( dynamic_cast<G4EquationOfMotion*>(EqRhs) == nullptr )
129 {
130 G4Exception("G4TCashKarpRKF45: constructor", "GeomField0001",
131 FatalException, "Equation is not an G4EquationOfMotion.");
132 }
133
135 fLastFinalVector = new G4double[N];
136 fLastDyDx = new G4double[N];
137
138 fMidVector = new G4double[N];
139 fMidError = new G4double[N];
140
141 if(primary)
142 {
143 fAuxStepper = new G4TCashKarpRKF45<T_Equation, N> (EqRhs, !primary);
144 }
145}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
G4MagIntegratorStepper(G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12, G4bool isFSAL=false)
G4double * fLastFinalVector
G4double * fLastInitialVector
G4TCashKarpRKF45 * fAuxStepper
T_Equation * fEquation_Rhs

References FatalException, G4TCashKarpRKF45< T_Equation, N >::fAuxStepper, G4TCashKarpRKF45< T_Equation, N >::fLastDyDx, G4TCashKarpRKF45< T_Equation, N >::fLastFinalVector, G4TCashKarpRKF45< T_Equation, N >::fLastInitialVector, G4TCashKarpRKF45< T_Equation, N >::fMidError, G4TCashKarpRKF45< T_Equation, N >::fMidVector, and G4Exception().

◆ ~G4TCashKarpRKF45()

template<class T_Equation , unsigned int N>
G4TCashKarpRKF45< T_Equation, N >::~G4TCashKarpRKF45
virtual

Definition at line 148 of file G4TCashKarpRKF45.hh.

149{
150 delete[] fLastInitialVector;
151 delete[] fLastFinalVector;
152 delete[] fLastDyDx;
153 delete[] fMidVector;
154 delete[] fMidError;
155
156 delete fAuxStepper;
157}

◆ G4TCashKarpRKF45() [2/2]

template<class T_Equation , unsigned int N = 6>
G4TCashKarpRKF45< T_Equation, N >::G4TCashKarpRKF45 ( const G4TCashKarpRKF45< T_Equation, N > &  )
private

Member Function Documentation

◆ DistChord()

template<class T_Equation , unsigned int N>
G4double G4TCashKarpRKF45< T_Equation, N >::DistChord
inlineoverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 270 of file G4TCashKarpRKF45.hh.

271{
272 G4double distLine, distChord;
273 G4ThreeVector initialPoint, finalPoint, midPoint;
274
275 // Store last initial and final points (they will be overwritten in
276 // self-Stepper call!)
281
282 // Do half a step using StepNoErr
283
284 fAuxStepper->G4TCashKarpRKF45::Stepper(fLastInitialVector, fLastDyDx,
286 fMidError);
287
288 midPoint = G4ThreeVector(fMidVector[0], fMidVector[1], fMidVector[2]);
289
290 // Use stored values of Initial and Endpoint + new Midpoint to evaluate
291 // distance of Chord
292
293 if(initialPoint != finalPoint)
294 {
295 distLine = G4LineSection::Distline(midPoint, initialPoint, finalPoint);
296 distChord = distLine;
297 }
298 else
299 {
300 distChord = (midPoint - initialPoint).mag();
301 }
302 return distChord;
303}
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)

References G4LineSection::Distline().

◆ 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 = 6>
G4int G4TCashKarpRKF45< T_Equation, N >::IntegratorOrder ( ) const
inlineoverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 94 of file G4TCashKarpRKF45.hh.

94{ 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 = 6>
G4TCashKarpRKF45 & G4TCashKarpRKF45< T_Equation, N >::operator= ( const G4TCashKarpRKF45< T_Equation, N > &  )
private

◆ 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

◆ RightHandSideInl()

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

Definition at line 86 of file G4TCashKarpRKF45.hh.

88 {
89 fEquation_Rhs->T_Equation::RightHandSide(y, dydx);
90 }

References G4TCashKarpRKF45< 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()

template<class T_Equation , unsigned int N>
void G4TCashKarpRKF45< T_Equation, N >::Stepper ( const G4double  yInput[],
const G4double  dydx[],
G4double  hstep,
G4double  yOutput[],
G4double  yError[] 
)
inlinefinaloverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 307 of file G4TCashKarpRKF45.hh.

312{
313 assert( yOutput != yInput );
314 assert( yError != yInput );
315
316 StepWithError( yInput, dydx, Step, yOutput, yError);
317}
void StepWithError(const G4double yInput[], const G4double dydx[], G4double Step, G4double yOut[], G4double yErr[])

◆ StepWithError()

template<class T_Equation , unsigned int N = 6>
void G4TCashKarpRKF45< T_Equation, N >::StepWithError ( const G4double  yInput[],
const G4double  dydx[],
G4double  Step,
G4double  yOut[],
G4double  yErr[] 
)
inline

Definition at line 171 of file G4TCashKarpRKF45.hh.

176{
177 // const G4double a2 = 0.2 , a3 = 0.3 , a4 = 0.6 , a5 = 1.0 , a6 = 0.875;
178
179 const G4double b21 = 0.2, b31 = 3.0 / 40.0, b32 = 9.0 / 40.0, b41 = 0.3,
180 b42 = -0.9, b43 = 1.2,
181
182 b51 = -11.0 / 54.0, b52 = 2.5, b53 = -70.0 / 27.0,
183 b54 = 35.0 / 27.0,
184
185 b61 = 1631.0 / 55296.0, b62 = 175.0 / 512.0,
186 b63 = 575.0 / 13824.0, b64 = 44275.0 / 110592.0,
187 b65 = 253.0 / 4096.0,
188
189 c1 = 37.0 / 378.0, c3 = 250.0 / 621.0, c4 = 125.0 / 594.0,
190 c6 = 512.0 / 1771.0, dc5 = -277.0 / 14336.0;
191
192 const G4double dc1 = c1 - 2825.0 / 27648.0, dc3 = c3 - 18575.0 / 48384.0,
193 dc4 = c4 - 13525.0 / 55296.0, dc6 = c6 - 0.25;
194
195 // Initialise time to t0, needed when it is not updated by the integration.
196 // [ Note: Only for time dependent fields (usually electric)
197 // is it neccessary to integrate the time.]
198 // yOut[7] = yTemp[7] = yIn[7];
199
200 // Saving yInput because yInput and yOut can be aliases for same array
201 for(unsigned int i = 0; i < N; ++i)
202 {
203 yIn[i] = yInput[i];
204 }
205 // RightHandSideInl(yIn, dydx) ; // 1st Step
206
207 for(unsigned int i = 0; i < N; ++i)
208 {
209 yTemp[i] = yIn[i] + b21 * Step * dydx[i];
210 }
211 this->RightHandSideInl(yTemp, ak2); // 2nd Step
212
213 for(unsigned int i = 0; i < N; ++i)
214 {
215 yTemp[i] = yIn[i] + Step * (b31 * dydx[i] + b32 * ak2[i]);
216 }
217 this->RightHandSideInl(yTemp, ak3); // 3rd Step
218
219 for(unsigned int i = 0; i < N; ++i)
220 {
221 yTemp[i] = yIn[i] + Step * (b41 * dydx[i] + b42 * ak2[i] + b43 * ak3[i]);
222 }
223 this->RightHandSideInl(yTemp, ak4); // 4th Step
224
225 for(unsigned int i = 0; i < N; ++i)
226 {
227 yTemp[i] = yIn[i] + Step * (b51 * dydx[i] + b52 * ak2[i] + b53 * ak3[i] +
228 b54 * ak4[i]);
229 }
230 this->RightHandSideInl(yTemp, ak5); // 5th Step
231
232 for(unsigned int i = 0; i < N; ++i)
233 {
234 yTemp[i] = yIn[i] + Step * (b61 * dydx[i] + b62 * ak2[i] + b63 * ak3[i] +
235 b64 * ak4[i] + b65 * ak5[i]);
236 }
237 this->RightHandSideInl(yTemp, ak6); // 6th Step
238
239 for(unsigned int i = 0; i < N; ++i)
240 {
241 // Accumulate increments with proper weights
242
243 yOut[i] = yIn[i] +
244 Step * (c1 * dydx[i] + c3 * ak3[i] + c4 * ak4[i] + c6 * ak6[i]);
245 }
246 for(unsigned int i = 0; i < N; ++i)
247 {
248 // Estimate error as difference between 4th and
249 // 5th order methods
250
251 yErr[i] = Step * (dc1 * dydx[i] + dc3 * ak3[i] + dc4 * ak4[i] +
252 dc5 * ak5[i] + dc6 * ak6[i]);
253 }
254 for(unsigned int i = 0; i < N; ++i)
255 {
256 // Store Input and Final values, for possible use in calculating chord
257 fLastInitialVector[i] = yIn[i];
258 fLastFinalVector[i] = yOut[i];
259 fLastDyDx[i] = dydx[i];
260 }
261 // NormaliseTangentVector( yOut ); // Not wanted
262
263 fLastStepLength = Step;
264
265 return;
266}
void RightHandSideInl(const G4double y[], G4double dydx[])

References ak2.

Field Documentation

◆ ak2

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak2[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ ak3

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak3[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ ak4

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak4[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ ak5

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak5[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ ak6

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak6[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ ak7

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::ak7[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ fAuxStepper

template<class T_Equation , unsigned int N = 6>
G4TCashKarpRKF45* G4TCashKarpRKF45< T_Equation, N >::fAuxStepper = nullptr
private

◆ fEquation_Rhs

template<class T_Equation , unsigned int N = 6>
T_Equation* G4TCashKarpRKF45< T_Equation, N >::fEquation_Rhs
private

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

◆ fLastDyDx

template<class T_Equation , unsigned int N = 6>
G4double* G4TCashKarpRKF45< T_Equation, N >::fLastDyDx
private

◆ fLastFinalVector

template<class T_Equation , unsigned int N = 6>
G4double* G4TCashKarpRKF45< T_Equation, N >::fLastFinalVector
private

◆ fLastInitialVector

template<class T_Equation , unsigned int N = 6>
G4double* G4TCashKarpRKF45< T_Equation, N >::fLastInitialVector
private

◆ fLastStepLength

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::fLastStepLength = 0.0
private

Definition at line 105 of file G4TCashKarpRKF45.hh.

◆ fMidError

template<class T_Equation , unsigned int N = 6>
G4double* G4TCashKarpRKF45< T_Equation, N >::fMidError
private

◆ fMidVector

template<class T_Equation , unsigned int N = 6>
G4double* G4TCashKarpRKF45< T_Equation, N >::fMidVector
private

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

◆ yIn

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::yIn[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.

◆ yTemp

template<class T_Equation , unsigned int N = 6>
G4double G4TCashKarpRKF45< T_Equation, N >::yTemp[N]
private

Definition at line 102 of file G4TCashKarpRKF45.hh.


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