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

#include <G4SimpleRunge.hh>

Inheritance diagram for G4SimpleRunge:
G4MagErrorStepper G4MagIntegratorStepper

Public Member Functions

G4double DistChord () const
 
void DumbStepper (const G4double y[], const G4double dydx[], G4double h, G4double yout[])
 
 G4SimpleRunge (G4EquationOfMotion *EquationRhs, G4int numberOfVariables=6)
 
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])
 
void ResetfNORHSCalls ()
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
void Stepper (const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
 
 ~G4SimpleRunge ()
 

Protected Member Functions

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

Private Attributes

G4doubledydxMid
 
G4doubledydxTemp = nullptr
 
G4EquationOfMotionfEquation_Rhs = nullptr
 
G4ThreeVector fFinalPoint
 
G4ThreeVector fInitialPoint
 
G4int fIntegrationOrder = -1
 
G4bool fIsFSAL = false
 
G4ThreeVector fMidPoint
 
const G4int fNoIntegrationVariables = 0
 
unsigned long fNoRHSCalls = 0UL
 
const G4int fNoStateVariables = 0
 
G4int fNumberOfVariables = 0
 
G4doubleyInitial
 
G4doubleyMiddle
 
G4doubleyOneStep
 
G4doubleyTemp = nullptr
 

Detailed Description

Definition at line 45 of file G4SimpleRunge.hh.

Constructor & Destructor Documentation

◆ G4SimpleRunge()

G4SimpleRunge::G4SimpleRunge ( G4EquationOfMotion EquationRhs,
G4int  numberOfVariables = 6 
)

Definition at line 38 of file G4SimpleRunge.cc.

39 : G4MagErrorStepper(EqRhs, numberOfVariables),
40 fNumberOfVariables(numberOfVariables)
41{
42
43 unsigned int noVariables= std::max(numberOfVariables,
45 // To deal with Time >= 7+1
46 dydxTemp = new G4double[noVariables] ;
47 yTemp = new G4double[noVariables] ;
48}
double G4double
Definition: G4Types.hh:83
G4MagErrorStepper(G4EquationOfMotion *EqRhs, G4int numberOfVariables, G4int numStateVariables=12)
G4int GetNumberOfStateVariables() const
G4double * dydxTemp
G4int fNumberOfVariables
G4double * yTemp
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References dydxTemp, G4MagIntegratorStepper::GetNumberOfStateVariables(), G4INCL::Math::max(), and yTemp.

◆ ~G4SimpleRunge()

G4SimpleRunge::~G4SimpleRunge ( )

Definition at line 54 of file G4SimpleRunge.cc.

55{
56 delete [] dydxTemp;
57 delete [] yTemp;
58}

References dydxTemp, and yTemp.

Member Function Documentation

◆ DistChord()

G4double G4MagErrorStepper::DistChord ( ) const
virtualinherited

Implements G4MagIntegratorStepper.

Definition at line 100 of file G4MagErrorStepper.cc.

101{
102 // Estimate the maximum distance from the curve to the chord
103 //
104 // We estimate this using the distance of the midpoint to
105 // chord (the line between
106 //
107 // Method below is good only for angle deviations < 2 pi,
108 // This restriction should not a problem for the Runge cutta methods,
109 // which generally cannot integrate accurately for large angle deviations.
110
111 G4double distLine, distChord;
112
114 {
116 // This is a class method that gives distance of Mid
117 // from the Chord between the Initial and Final points.
118
119 distChord = distLine;
120 }
121 else
122 {
123 distChord = (fMidPoint-fInitialPoint).mag();
124 }
125
126 return distChord;
127}
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4ThreeVector fMidPoint
G4ThreeVector fFinalPoint
G4ThreeVector fInitialPoint

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

◆ DumbStepper()

void G4SimpleRunge::DumbStepper ( const G4double  y[],
const G4double  dydx[],
G4double  h,
G4double  yout[] 
)
virtual

Implements G4MagErrorStepper.

Definition at line 65 of file G4SimpleRunge.cc.

69{
70 // Initialise time to t0, needed when it is not updated by the integration.
71 //
72 yTemp[7] = yOut[7] = yIn[7];
73
74 for( G4int i = 0; i < fNumberOfVariables; ++i )
75 {
76 yTemp[i] = yIn[i] + 0.5 * h*dydx[i] ;
77 }
78
80
81 for( G4int i = 0; i < fNumberOfVariables; ++i )
82 {
83 yOut[i] = yIn[i] + h * ( dydxTemp[i] );
84 }
85}
int G4int
Definition: G4Types.hh:85
void RightHandSide(const G4double y[], G4double dydx[]) const

References dydxTemp, fNumberOfVariables, G4MagIntegratorStepper::RightHandSide(), and yTemp.

◆ 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 G4SimpleRunge::IntegratorOrder ( ) const
inlinevirtual

Implements G4MagIntegratorStepper.

Definition at line 61 of file G4SimpleRunge.hh.

61{ return 2; }

◆ IsFSAL()

G4bool G4MagIntegratorStepper::IsFSAL ( ) const
inlineinherited

◆ NormalisePolarizationVector()

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

◆ NormaliseTangentVector()

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

◆ 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

◆ SetEquationOfMotion()

void G4MagIntegratorStepper::SetEquationOfMotion ( G4EquationOfMotion newEquation)
inlineinherited

◆ SetFSAL()

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

◆ SetIntegrationOrder()

void G4MagIntegratorStepper::SetIntegrationOrder ( G4int  order)
inlineprotectedinherited

◆ Stepper()

void G4MagErrorStepper::Stepper ( const G4double  y[],
const G4double  dydx[],
G4double  h,
G4double  yout[],
G4double  yerr[] 
)
virtualinherited

Implements G4MagIntegratorStepper.

Definition at line 42 of file G4MagErrorStepper.cc.

47{
48 const G4int nvar = GetNumberOfVariables();
49 const G4int maxvar = GetNumberOfStateVariables();
50
51 // correction for Richardson Extrapolation.
52 //
53 G4double correction = 1. / ( (1 << IntegratorOrder()) -1 );
54
55 // Saving yInput because yInput and yOutput can be aliases for same array
56 //
57 for(G4int i=0; i<nvar; ++i)
58 {
59 yInitial[i]=yInput[i];
60 }
61 yInitial[7] = yInput[7]; // Copy the time in case...even if not really needed
62 yMiddle[7] = yInput[7]; // Copy the time from initial value
63 yOneStep[7] = yInput[7]; // As it contributes to final value of yOutput ?
64 // yOutput[7] = yInput[7]; // -> dumb stepper does it too for RK4
65
66 for(G4int i=nvar; i<maxvar; ++i)
67 {
68 yOutput[i]=yInput[i];
69 }
70 // yError[7] = 0.0;
71
72 G4double halfStep = hstep * 0.5;
73
74 // Do two half steps
75 //
76 DumbStepper (yInitial, dydx, halfStep, yMiddle);
78 DumbStepper (yMiddle, dydxMid, halfStep, yOutput);
79
80 // Store midpoint, chord calculation
81 //
83
84 // Do a full Step
85 //
86 DumbStepper(yInitial, dydx, hstep, yOneStep);
87 for(G4int i=0; i<nvar; ++i)
88 {
89 yError [i] = yOutput[i] - yOneStep[i] ;
90 yOutput[i] += yError[i]*correction ;
91 // Provides accuracy increased by 1 order via Richardson Extrapolation
92 }
93
95 fFinalPoint = G4ThreeVector( yOutput[0], yOutput[1], yOutput[2]);
96
97 return;
98}
CLHEP::Hep3Vector G4ThreeVector
virtual void DumbStepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[])=0
G4int GetNumberOfVariables() const
virtual G4int IntegratorOrder() const =0

References G4MagErrorStepper::DumbStepper(), G4MagErrorStepper::dydxMid, G4MagErrorStepper::fFinalPoint, G4MagErrorStepper::fInitialPoint, G4MagErrorStepper::fMidPoint, G4MagIntegratorStepper::GetNumberOfStateVariables(), G4MagIntegratorStepper::GetNumberOfVariables(), G4MagIntegratorStepper::IntegratorOrder(), G4MagIntegratorStepper::RightHandSide(), G4MagErrorStepper::yInitial, G4MagErrorStepper::yMiddle, and G4MagErrorStepper::yOneStep.

Field Documentation

◆ dydxMid

G4double * G4MagErrorStepper::dydxMid
privateinherited

◆ dydxTemp

G4double* G4SimpleRunge::dydxTemp = nullptr
private

Definition at line 67 of file G4SimpleRunge.hh.

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

◆ fEquation_Rhs

G4EquationOfMotion* G4MagIntegratorStepper::fEquation_Rhs = nullptr
privateinherited

Definition at line 124 of file G4MagIntegratorStepper.hh.

◆ fFinalPoint

G4ThreeVector G4MagErrorStepper::fFinalPoint
privateinherited

◆ fInitialPoint

G4ThreeVector G4MagErrorStepper::fInitialPoint
privateinherited

◆ 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 G4MagErrorStepper::fMidPoint
privateinherited

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

◆ fNumberOfVariables

G4int G4SimpleRunge::fNumberOfVariables = 0
private

Definition at line 65 of file G4SimpleRunge.hh.

Referenced by DumbStepper().

◆ yInitial

G4double* G4MagErrorStepper::yInitial
privateinherited

◆ yMiddle

G4double * G4MagErrorStepper::yMiddle
privateinherited

◆ yOneStep

G4double * G4MagErrorStepper::yOneStep
privateinherited

◆ yTemp

G4double* G4SimpleRunge::yTemp = nullptr
private

Definition at line 68 of file G4SimpleRunge.hh.

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


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