Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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, bool isFSAL=false)
 
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
 
G4int IntegrationOrder ()
 
G4EquationOfMotionGetEquationOfMotion ()
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
unsigned long GetfNoRHSCalls ()
 
void ResetfNORHSCalls ()
 
bool IsFSAL ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4MagIntegratorStepper
void SetIntegrationOrder (int order)
 
void SetFSAL (bool flag=true)
 

Detailed Description

Definition at line 50 of file G4CashKarpRKF45.hh.

Constructor & Destructor Documentation

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

Definition at line 47 of file G4CashKarpRKF45.cc.

50  : G4MagIntegratorStepper(EqRhs, noIntegrationVariables),
51  fLastStepLength(0.), fAuxStepper(0)
52 {
53  const G4int numberOfVariables =
54  std::max( noIntegrationVariables,
55  ( ( (noIntegrationVariables-1)/4 + 1 ) * 4 ) );
56  // For better alignment with cache-line
57 
58  ak2 = new G4double[numberOfVariables] ;
59  ak3 = new G4double[numberOfVariables] ;
60  ak4 = new G4double[numberOfVariables] ;
61  ak5 = new G4double[numberOfVariables] ;
62  ak6 = new G4double[numberOfVariables] ;
63  // ak7 = 0;
64 
65  // Must ensure space extra 'state' variables exists - i.e. yIn[7]
66  const G4int numStateMax = std::max(GetNumberOfStateVariables(), 8);
67  const G4int numStateVars = std::max(noIntegrationVariables,
68  numStateMax );
69  // GetNumberOfStateVariables() );
70 
71  yTemp = new G4double[numStateVars] ;
72  yIn = new G4double[numStateVars] ;
73 
74  fLastInitialVector = new G4double[numStateVars] ;
75  fLastFinalVector = new G4double[numStateVars] ;
76  fLastDyDx = new G4double[numberOfVariables];
77 
78  fMidVector = new G4double[numStateVars];
79  fMidError = new G4double[numStateVars];
80  if( primary )
81  {
82  fAuxStepper = new G4CashKarpRKF45(EqRhs, numberOfVariables, !primary);
83  }
84 }
static const G4double ak2
G4CashKarpRKF45(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
int G4int
Definition: G4Types.hh:78
G4MagIntegratorStepper(G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12, bool isFSAL=false)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4int GetNumberOfStateVariables() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4CashKarpRKF45::~G4CashKarpRKF45 ( )

Definition at line 90 of file G4CashKarpRKF45.cc.

91 {
92  delete[] ak2;
93  delete[] ak3;
94  delete[] ak4;
95  delete[] ak5;
96  delete[] ak6;
97  // delete[] ak7;
98  delete[] yTemp;
99  delete[] yIn;
100 
101  delete[] fLastInitialVector;
102  delete[] fLastFinalVector;
103  delete[] fLastDyDx;
104  delete[] fMidVector;
105  delete[] fMidError;
106 
107  delete fAuxStepper;
108 }
static const G4double ak2

Member Function Documentation

G4double G4CashKarpRKF45::DistChord ( ) const
virtual

Implements G4MagIntegratorStepper.

Definition at line 240 of file G4CashKarpRKF45.cc.

241 {
242  G4double distLine, distChord;
243  G4ThreeVector initialPoint, finalPoint, midPoint;
244 
245  // Store last initial and final points (they will be overwritten in self-Stepper call!)
246  initialPoint = G4ThreeVector( fLastInitialVector[0],
247  fLastInitialVector[1], fLastInitialVector[2]);
248  finalPoint = G4ThreeVector( fLastFinalVector[0],
249  fLastFinalVector[1], fLastFinalVector[2]);
250 
251  // Do half a step using StepNoErr
252 
253  fAuxStepper->Stepper( fLastInitialVector, fLastDyDx, 0.5 * fLastStepLength,
254  fMidVector, fMidError );
255 
256  midPoint = G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2]);
257 
258  // Use stored values of Initial and Endpoint + new Midpoint to evaluate
259  // distance of Chord
260 
261 
262  if (initialPoint != finalPoint)
263  {
264  distLine = G4LineSection::Distline( midPoint, initialPoint, finalPoint );
265  distChord = distLine;
266  }
267  else
268  {
269  distChord = (midPoint-initialPoint).mag();
270  }
271  return distChord;
272 }
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4int G4CashKarpRKF45::IntegratorOrder ( ) const
inlinevirtual

Implements G4MagIntegratorStepper.

Definition at line 69 of file G4CashKarpRKF45.hh.

69 { return 4; }
void G4CashKarpRKF45::Stepper ( const G4double  y[],
const G4double  dydx[],
G4double  h,
G4double  yout[],
G4double  yerr[] 
)
virtual

Implements G4MagIntegratorStepper.

Definition at line 121 of file G4CashKarpRKF45.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:


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