Geant4  10.02.p03
G4CashKarpRKF45 Class Reference

#include <G4CashKarpRKF45.hh>

Inheritance diagram for G4CashKarpRKF45:
Collaboration diagram for G4CashKarpRKF45:

Public Member Functions

 G4CashKarpRKF45 (G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
 
 ~G4CashKarpRKF45 ()
 
void Stepper (const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
 
G4double DistChord () const
 
G4int IntegratorOrder () const
 
- Public Member Functions inherited from G4MagIntegratorStepper
 G4MagIntegratorStepper (G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12)
 
virtual ~G4MagIntegratorStepper ()
 
virtual void ComputeRightHandSide (const G4double y[], G4double dydx[])
 
void NormaliseTangentVector (G4double vec[6])
 
void NormalisePolarizationVector (G4double vec[12])
 
void RightHandSide (const double y[], double dydx[])
 
G4int GetNumberOfVariables () const
 
G4int GetNumberOfStateVariables () const
 
G4EquationOfMotionGetEquationOfMotion ()
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 

Private Member Functions

void StepWithEst (const G4double yIn[], const G4double dydx[], G4double Step, G4double yOut[], G4double &alpha2, G4double &beta2, const G4double B1[], G4double B2[])
 
 G4CashKarpRKF45 (const G4CashKarpRKF45 &)
 
G4CashKarpRKF45operator= (const G4CashKarpRKF45 &)
 

Private Attributes

G4doubleak2
 
G4doubleak3
 
G4doubleak4
 
G4doubleak5
 
G4doubleak6
 
G4doubleak7
 
G4doubleyTemp
 
G4doubleyIn
 
G4double fLastStepLength
 
G4doublefLastInitialVector
 
G4doublefLastFinalVector
 
G4doublefLastDyDx
 
G4doublefMidVector
 
G4doublefMidError
 
G4CashKarpRKF45fAuxStepper
 

Detailed Description

Definition at line 50 of file G4CashKarpRKF45.hh.

Constructor & Destructor Documentation

◆ G4CashKarpRKF45() [1/2]

G4CashKarpRKF45::G4CashKarpRKF45 ( G4EquationOfMotion EqRhs,
G4int  numberOfVariables = 6,
G4bool  primary = true 
)

Definition at line 47 of file G4CashKarpRKF45.cc.

50  : G4MagIntegratorStepper(EqRhs, noIntegrationVariables),
52 {
53  const G4int numberOfVariables = noIntegrationVariables;
54 
55  ak2 = new G4double[numberOfVariables] ;
56  ak3 = new G4double[numberOfVariables] ;
57  ak4 = new G4double[numberOfVariables] ;
58  ak5 = new G4double[numberOfVariables] ;
59  ak6 = new G4double[numberOfVariables] ;
60  ak7 = 0;
61  yTemp = new G4double[numberOfVariables] ;
62  yIn = new G4double[numberOfVariables] ;
63 
64  fLastInitialVector = new G4double[numberOfVariables] ;
65  fLastFinalVector = new G4double[numberOfVariables] ;
66  fLastDyDx = new G4double[numberOfVariables];
67 
68  fMidVector = new G4double[numberOfVariables];
69  fMidError = new G4double[numberOfVariables];
70  if( primary )
71  {
72  fAuxStepper = new G4CashKarpRKF45(EqRhs, numberOfVariables, !primary);
73  }
74 }
G4CashKarpRKF45(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
G4double fLastStepLength
int G4int
Definition: G4Types.hh:78
G4double * fMidVector
G4double * fLastFinalVector
G4double * fLastDyDx
double G4double
Definition: G4Types.hh:76
G4CashKarpRKF45 * fAuxStepper
G4double * fMidError
G4MagIntegratorStepper(G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12)
G4double * fLastInitialVector
Here is the caller graph for this function:

◆ ~G4CashKarpRKF45()

G4CashKarpRKF45::~G4CashKarpRKF45 ( )

Definition at line 80 of file G4CashKarpRKF45.cc.

81 {
82  delete[] ak2;
83  delete[] ak3;
84  delete[] ak4;
85  delete[] ak5;
86  delete[] ak6;
87  // delete[] ak7;
88  delete[] yTemp;
89  delete[] yIn;
90 
91  delete[] fLastInitialVector;
92  delete[] fLastFinalVector;
93  delete[] fLastDyDx;
94  delete[] fMidVector;
95  delete[] fMidError;
96 
97  delete fAuxStepper;
98 }
G4double * fMidVector
G4double * fLastFinalVector
G4double * fLastDyDx
G4CashKarpRKF45 * fAuxStepper
G4double * fMidError
G4double * fLastInitialVector

◆ G4CashKarpRKF45() [2/2]

G4CashKarpRKF45::G4CashKarpRKF45 ( const G4CashKarpRKF45 )
private

Member Function Documentation

◆ DistChord()

G4double G4CashKarpRKF45::DistChord ( ) const
virtual

Implements G4MagIntegratorStepper.

Definition at line 230 of file G4CashKarpRKF45.cc.

231 {
232  G4double distLine, distChord;
233  G4ThreeVector initialPoint, finalPoint, midPoint;
234 
235  // Store last initial and final points (they will be overwritten in self-Stepper call!)
236  initialPoint = G4ThreeVector( fLastInitialVector[0],
238  finalPoint = G4ThreeVector( fLastFinalVector[0],
240 
241  // Do half a step using StepNoErr
242 
245 
246  midPoint = G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2]);
247 
248  // Use stored values of Initial and Endpoint + new Midpoint to evaluate
249  // distance of Chord
250 
251 
252  if (initialPoint != finalPoint)
253  {
254  distLine = G4LineSection::Distline( midPoint, initialPoint, finalPoint );
255  distChord = distLine;
256  }
257  else
258  {
259  distChord = (midPoint-initialPoint).mag();
260  }
261  return distChord;
262 }
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4double fLastStepLength
G4double * fMidVector
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
G4double * fLastFinalVector
G4double * fLastDyDx
double G4double
Definition: G4Types.hh:76
G4CashKarpRKF45 * fAuxStepper
G4double * fMidError
G4double * fLastInitialVector
Here is the call graph for this function:

◆ IntegratorOrder()

G4int G4CashKarpRKF45::IntegratorOrder ( ) const
inlinevirtual

Implements G4MagIntegratorStepper.

Definition at line 69 of file G4CashKarpRKF45.hh.

69 { return 4; }
Here is the call graph for this function:

◆ operator=()

G4CashKarpRKF45& G4CashKarpRKF45::operator= ( const G4CashKarpRKF45 )
private
Here is the caller graph for this function:

◆ Stepper()

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

Implements G4MagIntegratorStepper.

Definition at line 111 of file G4CashKarpRKF45.cc.

116 {
117  // const G4int nvar = 6 ;
118  // const G4double a2 = 0.2 , a3 = 0.3 , a4 = 0.6 , a5 = 1.0 , a6 = 0.875;
119  G4int i;
120 
121  const G4double b21 = 0.2 ,
122  b31 = 3.0/40.0 , b32 = 9.0/40.0 ,
123  b41 = 0.3 , b42 = -0.9 , b43 = 1.2 ,
124 
125  b51 = -11.0/54.0 , b52 = 2.5 , b53 = -70.0/27.0 ,
126  b54 = 35.0/27.0 ,
127 
128  b61 = 1631.0/55296.0 , b62 = 175.0/512.0 ,
129  b63 = 575.0/13824.0 , b64 = 44275.0/110592.0 ,
130  b65 = 253.0/4096.0 ,
131 
132  c1 = 37.0/378.0 , c3 = 250.0/621.0 , c4 = 125.0/594.0 ,
133  c6 = 512.0/1771.0 ,
134  dc5 = -277.0/14336.0 ;
135 
136  const G4double dc1 = c1 - 2825.0/27648.0 , dc3 = c3 - 18575.0/48384.0 ,
137  dc4 = c4 - 13525.0/55296.0 , dc6 = c6 - 0.25 ;
138 
139  // Initialise time to t0, needed when it is not updated by the integration.
140  // [ Note: Only for time dependent fields (usually electric)
141  // is it neccessary to integrate the time.]
142  yOut[7] = yTemp[7] = yIn[7];
143 
144  const G4int numberOfVariables= this->GetNumberOfVariables();
145  // The number of variables to be integrated over
146 
147  // Saving yInput because yInput and yOut can be aliases for same array
148 
149  for(i=0;i<numberOfVariables;i++)
150  {
151  yIn[i]=yInput[i];
152  }
153  // RightHandSide(yIn, dydx) ; // 1st Step
154 
155  for(i=0;i<numberOfVariables;i++)
156  {
157  yTemp[i] = yIn[i] + b21*Step*dydx[i] ;
158  }
159  RightHandSide(yTemp, ak2) ; // 2nd Step
160 
161  for(i=0;i<numberOfVariables;i++)
162  {
163  yTemp[i] = yIn[i] + Step*(b31*dydx[i] + b32*ak2[i]) ;
164  }
165  RightHandSide(yTemp, ak3) ; // 3rd Step
166 
167  for(i=0;i<numberOfVariables;i++)
168  {
169  yTemp[i] = yIn[i] + Step*(b41*dydx[i] + b42*ak2[i] + b43*ak3[i]) ;
170  }
171  RightHandSide(yTemp, ak4) ; // 4th Step
172 
173  for(i=0;i<numberOfVariables;i++)
174  {
175  yTemp[i] = yIn[i] + Step*(b51*dydx[i] + b52*ak2[i] + b53*ak3[i] +
176  b54*ak4[i]) ;
177  }
178  RightHandSide(yTemp, ak5) ; // 5th Step
179 
180  for(i=0;i<numberOfVariables;i++)
181  {
182  yTemp[i] = yIn[i] + Step*(b61*dydx[i] + b62*ak2[i] + b63*ak3[i] +
183  b64*ak4[i] + b65*ak5[i]) ;
184  }
185  RightHandSide(yTemp, ak6) ; // 6th Step
186 
187  for(i=0;i<numberOfVariables;i++)
188  {
189  // Accumulate increments with proper weights
190 
191  yOut[i] = yIn[i] + Step*(c1*dydx[i] + c3*ak3[i] + c4*ak4[i] + c6*ak6[i]) ;
192 
193  // Estimate error as difference between 4th and
194  // 5th order methods
195 
196  yErr[i] = Step*(dc1*dydx[i] + dc3*ak3[i] + dc4*ak4[i] +
197  dc5*ak5[i] + dc6*ak6[i]) ;
198 
199  // Store Input and Final values, for possible use in calculating chord
200  fLastInitialVector[i] = yIn[i] ;
201  fLastFinalVector[i] = yOut[i];
202  fLastDyDx[i] = dydx[i];
203  }
204  // NormaliseTangentVector( yOut ); // Not wanted
205 
207 
208  return ;
209 }
G4double fLastStepLength
int G4int
Definition: G4Types.hh:78
G4int GetNumberOfVariables() const
static const G4double c3
static const G4double c4
G4double * fLastFinalVector
Definition: Step.hh:41
void RightHandSide(const double y[], double dydx[])
G4double * fLastDyDx
double G4double
Definition: G4Types.hh:76
G4double * fLastInitialVector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StepWithEst()

void G4CashKarpRKF45::StepWithEst ( const G4double  yIn[],
const G4double  dydx[],
G4double  Step,
G4double  yOut[],
G4double alpha2,
G4double beta2,
const G4double  B1[],
G4double  B2[] 
)
private

Definition at line 214 of file G4CashKarpRKF45.cc.

222 {
223  G4Exception("G4CashKarpRKF45::StepWithEst()", "GeomField0001",
224  FatalException, "Method no longer used.");
225  return ;
226 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ak2

G4double* G4CashKarpRKF45::ak2
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ ak3

G4double * G4CashKarpRKF45::ak3
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ ak4

G4double * G4CashKarpRKF45::ak4
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ ak5

G4double * G4CashKarpRKF45::ak5
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ ak6

G4double * G4CashKarpRKF45::ak6
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ ak7

G4double * G4CashKarpRKF45::ak7
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ fAuxStepper

G4CashKarpRKF45* G4CashKarpRKF45::fAuxStepper
private

Definition at line 97 of file G4CashKarpRKF45.hh.

◆ fLastDyDx

G4double * G4CashKarpRKF45::fLastDyDx
private

Definition at line 93 of file G4CashKarpRKF45.hh.

◆ fLastFinalVector

G4double * G4CashKarpRKF45::fLastFinalVector
private

Definition at line 93 of file G4CashKarpRKF45.hh.

◆ fLastInitialVector

G4double* G4CashKarpRKF45::fLastInitialVector
private

Definition at line 93 of file G4CashKarpRKF45.hh.

◆ fLastStepLength

G4double G4CashKarpRKF45::fLastStepLength
private

Definition at line 92 of file G4CashKarpRKF45.hh.

◆ fMidError

G4double * G4CashKarpRKF45::fMidError
private

Definition at line 93 of file G4CashKarpRKF45.hh.

◆ fMidVector

G4double * G4CashKarpRKF45::fMidVector
private

Definition at line 93 of file G4CashKarpRKF45.hh.

◆ yIn

G4double * G4CashKarpRKF45::yIn
private

Definition at line 89 of file G4CashKarpRKF45.hh.

◆ yTemp

G4double * G4CashKarpRKF45::yTemp
private

Definition at line 89 of file G4CashKarpRKF45.hh.


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