72 G4int noIntegrationVariables,
77 const G4int numberOfVariables =
79 ( ( (noIntegrationVariables-1)/4 + 1 ) * 4 ) );
85 ak2 =
new G4double[numberOfVariables];
86 ak3 =
new G4double[numberOfVariables];
87 ak4 =
new G4double[numberOfVariables];
88 ak5 =
new G4double[numberOfVariables];
89 ak6 =
new G4double[numberOfVariables];
90 ak7 =
new G4double[numberOfVariables];
92 ak8 =
new G4double[numberOfVariables];
93 ak9 =
new G4double[numberOfVariables];
96 const G4int numStateVars =
103 fLastInitialVector =
new G4double[numStateVars] ;
104 fLastFinalVector =
new G4double[numStateVars] ;
108 fMidVector =
new G4double[numStateVars];
109 fMidError =
new G4double[numStateVars];
111 yTemp =
new G4double[numberOfVariables] ;
112 yIn =
new G4double[numberOfVariables] ;
114 fLastInitialVector =
new G4double[numberOfVariables] ;
115 fLastFinalVector =
new G4double[numberOfVariables] ;
116 fInitialDyDx =
new G4double[numberOfVariables];
118 fMidVector =
new G4double[numberOfVariables];
119 fMidError =
new G4double[numberOfVariables];
144 delete[] fLastInitialVector;
145 delete[] fLastFinalVector;
146 delete[] fInitialDyDx;
192 b31 = 3.0/40.0, b32 = 9.0/40.0 ,
194 b41 = 44.0/45.0, b42 = -56.0/15.0, b43 = 32.0/9.0,
196 b51 = 19372.0/6561.0, b52 = -25360.0/2187.0, b53 = 64448.0/6561.0,
199 b61 = 9017.0/3168.0 , b62 = -355.0/33.0,
200 b63 = 46732.0/5247.0 , b64 = 49.0/176.0 ,
201 b65 = -5103.0/18656.0 ,
203 b71 = 35.0/384.0, b72 = 0.,
204 b73 = 500.0/1113.0, b74 = 125.0/192.0,
205 b75 = -2187.0/6784.0, b76 = 11.0/84.0,
219 dc1 = -( b71 - 5179.0/57600.0),
221 dc3 = -( b73 - 7571.0/16695.0),
222 dc4 = -( b74 - 393.0/640.0),
223 dc5 = -( b75 + 92097.0/339200.0),
224 dc6 = -( b76 - 187.0/2100.0),
225 dc7 = -( - 1.0/40.0 );
230 yOut[7] = yTemp[7] = yInput[7];
233 for(i=0;i<numberOfVariables;i++)
241 for(i=0;i<numberOfVariables;i++)
243 yTemp[i] = yIn[i] + b21*Step*DyDx[i] ;
247 for(i=0;i<numberOfVariables;i++)
249 yTemp[i] = yIn[i] + Step*(b31*DyDx[i] + b32*ak2[i]) ;
253 for(i=0;i<numberOfVariables;i++)
255 yTemp[i] = yIn[i] + Step*(b41*DyDx[i] + b42*ak2[i] + b43*ak3[i]) ;
259 for(i=0;i<numberOfVariables;i++)
261 yTemp[i] = yIn[i] + Step*(b51*DyDx[i] + b52*ak2[i] + b53*ak3[i] +
266 for(i=0;i<numberOfVariables;i++)
268 yTemp[i] = yIn[i] + Step*(b61*DyDx[i] + b62*ak2[i] + b63*ak3[i] +
269 b64*ak4[i] + b65*ak5[i]) ;
273 for(i=0;i<numberOfVariables;i++)
275 yOut[i] = yIn[i] + Step*(b71*DyDx[i] + b72*ak2[i] + b73*ak3[i] +
276 b74*ak4[i] + b75*ak5[i] + b76*ak6[i] );
280 for(i=0;i<numberOfVariables;i++)
282 yErr[i] = Step*(dc1*DyDx[i] + dc2*ak2[i] + dc3*ak3[i] + dc4*ak4[i] +
283 dc5*ak5[i] + dc6*ak6[i] + dc7*ak7[i] ) + 1.5e-18 ;
286 fLastInitialVector[i] = yIn[i] ;
287 fLastFinalVector[i] = yOut[i];
288 fInitialDyDx[i] = DyDx[i];
291 fLastStepLength = Step;
303 initialPoint =
G4ThreeVector( yStart[0], yStart[1], yStart[2]);
309 if (initialPoint != finalPoint)
312 distChord = distLine;
316 distChord = (midPoint-initialPoint).mag();
325 *fAuxStepper = *
this;
330 fAuxStepper->
Interpolate( 0.5, fAuxStepper->fMidVector);
332 return DistLine( fLastInitialVector, fAuxStepper->fMidVector, fLastFinalVector);
339 hf1 = 5783653.0/57600000.0 ,
341 hf3 = 466123.0/1192500.0 ,
342 hf4 = -41347.0/1920000.0 ,
343 hf5 = 16122321.0/339200000.0 ,
344 hf6 = -7117.0/20000.0,
345 hf7 = 183.0/10000.0 ;
347 for(
int i=0; i<3; i++){
348 fMidVector[i] = fLastInitialVector[i] + fLastStepLength*(
349 hf1*fInitialDyDx[i] + hf2*ak2[i] + hf3*ak3[i] + hf4*ak4[i] +
350 hf5*ak5[i] + hf6*ak6[i] + hf7*ak7[i] );
356 return DistLine( fLastInitialVector, fMidVector, fLastFinalVector);
363 fAuxStepper->
Stepper( fLastInitialVector, fInitialDyDx, 0.5 * fLastStepLength,
364 fAuxStepper->fMidVector, fAuxStepper->fMidError) ;
365 return DistLine( fLastInitialVector, fAuxStepper->fMidVector, fLastFinalVector);
387 G4double bf1, bf2, bf3, bf4, bf5, bf6, bf7;
399 tau_4 = tau_2 * tau_2;
401 bf1 = (157015080.0*tau_4 - 13107642775.0*tau_3+ 34969693132.0*tau_2- 32272833064.0*tau
402 + 11282082432.0)/11282082432.0,
404 bf3 = - 100.0*tau*(15701508.0*tau_3 - 914128567.0*tau_2 + 2074956840.0*tau
405 - 1323431896.0)/32700410799.0,
406 bf4 = 25.0*tau*(94209048.0*tau_3- 1518414297.0*tau_2+ 2460397220.0*tau - 889289856.0)/5641041216.0 ,
407 bf5 = -2187.0*tau*(52338360.0*tau_3 - 451824525.0*tau_2 + 687873124.0*tau - 259006536.0)/199316789632.0 ,
408 bf6 = 11.0*tau*(106151040.0*tau_3- 661884105.0*tau_2 + 946554244.0*tau - 361440756.0)/2467955532.0 ,
409 bf7 = tau*(1.0 - tau)*(8293050.0*tau_2 - 82437520.0*tau + 44764047.0)/ 29380423.0 ;
412 for(
int i=0; i<numberOfVariables; i++){
413 yOut[i] = yIn[i] + Step*tau*(bf1*dydx[i] + bf2*ak2[i] + bf3*ak3[i] + bf4*ak4[i]
414 + bf5*ak5[i] + bf6*ak6[i] + bf7*ak7[i] ) ;
433 b81 = 6245.0/62208.0 ,
435 b83 = 8875.0/103032.0 ,
436 b84 = -125.0/1728.0 ,
437 b85 = 801.0/13568.0 ,
438 b86 = -13519.0/368064.0 ,
439 b87 = 11105.0/368064.0 ,
441 b91 = 632855.0/4478976.0 ,
443 b93 = 4146875.0/6491016.0 ,
444 b94 = 5490625.0/14183424.0 ,
445 b95 = -15975.0/108544.0 ,
446 b96 = 8295925.0/220286304.0 ,
447 b97 = -1779595.0/62938944.0 ,
448 b98 = -805.0/4104.0 ;
451 const G4double *dydx = fInitialDyDx;
452 const G4double Step = fLastStepLength;
459 for(
int i=0;i<numberOfVariables;i++)
461 yTemp[i] = yIn[i] + Step*(b81*dydx[i] + b82*ak2[i] + b83*ak3[i] +
462 b84*ak4[i] + b85*ak5[i] + b86*ak6[i] +
467 for(
int i=0;i<numberOfVariables;i++)
469 yTemp[i] = yIn[i] + Step*(b91*dydx[i] + b92*ak2[i] + b93*ak3[i] +
470 b94*ak4[i] + b95*ak5[i] + b96*ak6[i] +
471 b97*ak7[i] + b98*ak8[i] );
486 const G4double *dydx = fInitialDyDx;
494 bi[1][1] = -38039.0/7040.0 ,
495 bi[1][2] = 125923.0/10560.0 ,
496 bi[1][3] = -19683.0/1760.0 ,
497 bi[1][4] = 3303.0/880.0 ,
510 bi[3][1] = -12500.0/4081.0 ,
511 bi[3][2] = 205000.0/12243.0 ,
512 bi[3][3] = -90000.0/4081.0 ,
513 bi[3][4] = 36000.0/4081.0 ,
518 bi[4][1] = -3125.0/704.0 ,
519 bi[4][2] = 25625.0/1056.0 ,
520 bi[4][3] = -5625.0/176.0 ,
521 bi[4][4] = 1125.0/88.0 ,
526 bi[5][1] = 164025.0/74624.0 ,
527 bi[5][2] = -448335.0/37312.0 ,
528 bi[5][3] = 295245.0/18656.0 ,
529 bi[5][4] = -59049.0/9328.0 ,
534 bi[6][1] = -25.0/28.0 ,
535 bi[6][2] = 205.0/42.0 ,
536 bi[6][3] = -45.0/7.0 ,
537 bi[6][4] = 18.0/7.0 ,
542 bi[7][1] = -2.0/11.0 ,
543 bi[7][2] = 73.0/55.0 ,
544 bi[7][3] = -171.0/55.0 ,
545 bi[7][4] = 108.0/55.0 ,
550 bi[8][1] = 189.0/22.0 ,
551 bi[8][2] = -1593.0/55.0 ,
552 bi[8][3] = 3537.0/110.0 ,
553 bi[8][4] = -648.0/55.0 ,
558 bi[9][1] = 351.0/110.0 ,
559 bi[9][2] = -999.0/55.0 ,
560 bi[9][3] = 2943.0/110.0 ,
561 bi[9][4] = -648.0/55.0 ;
568 for(
int iStage=1; iStage<=9; iStage++){
572 for(
int j=0; j<=4; j++){
574 for(
int iStage=1; iStage<=9; iStage++){
575 b[iStage] += bi[iStage][j]*tauPower;
582 for(
int i=1; i<=9; i++){
585 for(
int j=0; j<=4; j++){
586 b[i] += bi[i][j]*tau;
592 G4double stepLen = fLastStepLength * tau;
593 for(
int i=0; i<numberOfVariables; i++){
594 yOut[i] = yIn[i] + stepLen *(b[1]*dydx[i] + b[2]*ak2[i] + b[3]*ak3[i] +
595 b[4]*ak4[i] + b[5]*ak5[i] + b[6]*ak6[i] +
596 b[7]*ak7[i] + b[8]*ak8[i] + b[9]*ak9[i] );
611 for(
int i =0; i< noVars; i++)
613 this->ak2[i] = right.ak2[i];
614 this->ak3[i] = right.ak3[i];
615 this->ak4[i] = right.ak4[i];
616 this->ak5[i] = right.ak5[i];
617 this->ak6[i] = right.ak6[i];
618 this->ak7[i] = right.ak7[i];
619 this->ak8[i] = right.ak8[i];
620 this->ak9[i] = right.ak9[i];
622 this->fInitialDyDx[i] = right.fInitialDyDx[i];
623 this->fLastInitialVector[i] = right.fLastInitialVector[i];
624 this->fMidVector[i] = right.fMidVector[i];
625 this->fMidError[i] = right.fMidError[i];
628 this->fLastStepLength = right.fLastStepLength;
G4DormandPrince745(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
void Interpolate(G4double tau, G4double yOut[])
void SetupInterpolation_low()
G4double DistLine(G4double yStart[], G4double yMid[], G4double yEnd[]) const
G4int GetNumberOfVariables() const
void SetupInterpolation()
void Interpolate_high(G4double yOut[], G4double tau)
G4double DistChord3() const
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4int GetNumberOfStateVariables() const
void RightHandSide(const double y[], double dydx[])
G4double DistChord2() const
G4double DistChord() const
void Interpolate_low(G4double yOut[], G4double tau)
void SetupInterpolation_high()