48 G4int noIntegrationVariables,
54 const G4int numberOfVariables = noIntegrationVariables;
59 ak2 =
new G4double[numberOfVariables];
60 ak3 =
new G4double[numberOfVariables];
61 ak4 =
new G4double[numberOfVariables];
62 ak5 =
new G4double[numberOfVariables];
63 ak6 =
new G4double[numberOfVariables];
64 ak7 =
new G4double[numberOfVariables];
65 ak8 =
new G4double[numberOfVariables];
66 ak9 =
new G4double[numberOfVariables];
68 const G4int numStateVars =
std::max(noIntegrationVariables, 8);
72 fLastInitialVector =
new G4double[numStateVars] ;
73 fLastFinalVector =
new G4double[numStateVars] ;
75 fLastDyDx =
new G4double[numStateVars];
77 fMidVector =
new G4double[numStateVars];
78 fMidError =
new G4double[numStateVars];
103 delete[] fLastInitialVector;
104 delete[] fLastFinalVector;
147 b43 = 1053.0/1372.0 ,
149 b51 = 3243.0/5500.0 ,
151 b53 = 50949.0/71500.0 ,
152 b54 = 4998.0/17875.0 ,
154 b61 = -26492.0/37125.0 ,
156 b63 = 2808.0/23375.0 ,
157 b64 = -24206.0/37125.0 ,
160 b71 = 5561.0/2376.0 ,
162 b73 = -24117.0/31603.0 ,
163 b74 = 899983.0/200772.0 ,
164 b75 = -5225.0/1836.0 ,
165 b76 = 3925.0/4056.0 ,
167 b81 = 465467.0/266112.0 ,
168 b82 = -2945.0/1232.0 ,
169 b83 = -5610201.0/14158144.0 ,
170 b84 = 10513573.0/3212352.0 ,
171 b85 = -424325.0/205632.0 ,
172 b86 = 376225.0/454272.0 ,
177 c3 = 98415.0/321776.0 ,
178 c4 = 16807.0/146016.0 ,
186 b93 = 98415.0/321776.0 ,
187 b94 = 16807.0/146016.0 ,
188 b95 = 1375.0/7344.0 ,
189 b96 = 1375.0/5408.0 ,
193 dc1 = c1 - 821.0/10800.0 ,
195 dc3 = c3 - 19683.0/71825,
196 dc4 = c4 - 175273.0/912600.0 ,
197 dc5 = c5 - 395.0/3672.0 ,
198 dc6 = c6 - 785.0/2704.0 ,
199 dc7 = c7 - 3.0/50.0 ,
274 yOut[7] = yTemp[7] = yIn[7];
277 for(i=0;i<numberOfVariables;i++)
287 for(i=0;i<numberOfVariables;i++)
289 yTemp[i] = yIn[i] + b21*Step*dydx[i] ;
293 for(i=0;i<numberOfVariables;i++)
295 yTemp[i] = yIn[i] + Step*(b31*dydx[i] + b32*ak2[i]) ;
299 for(i=0;i<numberOfVariables;i++)
301 yTemp[i] = yIn[i] + Step*(b41*dydx[i] + b42*ak2[i] + b43*ak3[i]) ;
305 for(i=0;i<numberOfVariables;i++)
307 yTemp[i] = yIn[i] + Step*(b51*dydx[i] + b52*ak2[i] + b53*ak3[i] +
312 for(i=0;i<numberOfVariables;i++)
314 yTemp[i] = yIn[i] + Step*(b61*dydx[i] + b62*ak2[i] + b63*ak3[i] +
315 b64*ak4[i] + b65*ak5[i]) ;
319 for(i=0;i<numberOfVariables;i++)
321 yTemp[i] = yIn[i] + Step*(b71*dydx[i] + b72*ak2[i] + b73*ak3[i] +
322 b74*ak4[i] + b75*ak5[i] + b76*ak6[i]);
326 for(i=0;i<numberOfVariables;i++)
328 yTemp[i] = yIn[i] + Step*(b81*dydx[i] + b82*ak2[i] + b83*ak3[i] +
329 b84*ak4[i] + b85*ak5[i] + b86*ak6[i] +
334 for(i=0;i<numberOfVariables;i++)
336 yOut[i] = yIn[i] + Step*(b91*dydx[i] + b92*ak2[i] + b93*ak3[i] +
337 b94*ak4[i] + b95*ak5[i] + b96*ak6[i] +
338 b97*ak7[i] + b98*ak8[i] );
343 for(i=0;i<numberOfVariables;i++)
349 yErr[i] = Step*( dc1*dydx[i] + dc2*ak2[i] + dc3*ak3[i] + dc4*ak4[i]
350 + dc5*ak5[i] + dc6*ak6[i] + dc7*ak7[i] + dc8*ak8[i]
357 fLastInitialVector[i] = yIn[i] ;
358 fLastFinalVector[i] = yOut[i];
359 fLastDyDx[i] = dydx[i];
363 fLastStepLength = Step;
379 fLastInitialVector[1], fLastInitialVector[2]);
381 fLastFinalVector[1], fLastFinalVector[2]);
385 fAuxStepper->
Stepper( fLastInitialVector, fLastDyDx, 0.5 * fLastStepLength,
386 fMidVector, fMidError );
388 midPoint =
G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2]);
394 if (initialPoint != finalPoint)
397 distChord = distLine;
401 distChord = (midPoint-initialPoint).mag();
423 b_101 = 33797.0/460800.0 ,
426 b_104 = 27757.0/70785.0 ,
427 b_105 = 7923501.0/26329600.0 ,
428 b_106 = -927.0/3760.0 ,
429 b_107 = -3314760575.0/23165835264.0 ,
430 b_108 = 2479.0/23040.0 ,
433 ak10_low =
new G4double[numberOfVariables];
435 for(
int i=0;i<numberOfVariables;i++)
441 for(
int i=0;i<numberOfVariables;i++)
443 yTemp[i] = yIn[i] + Step*(b_101*dydx[i] + b_102*ak2[i] + b_103*ak3[i] +
444 b_104*ak4[i] + b_105*ak5[i] + b_106*ak6[i] +
445 b_107*ak7[i] + b_108*ak8[i] + b_109*ak9[i]);
459 bf1, bf4, bf5, bf6, bf7, bf8, bf9, bf10;
464 for(
int i=0;i<numberOfVariables;i++)
475 bf1 = (66480.0*tau_4 - 206243.0*tau_3 + 237786.0*tau_2 - 124793.0*tau + 28800.0)/28800.0 ,
476 bf4 = -16.0*tau*(45312.0*tau_3 - 125933.0*tau_2 + 119706.0*tau -40973.0)/70785.0 ,
477 bf5 = -2187.0*tau*(19440.0*tau_3 - 45743.0*tau_2 + 34786.0*tau - 9293.0)/1645600.0 ,
478 bf6 = tau*(12864.0*tau_3 - 30653.0*tau_2 + 23786.0*tau - 6533.0)/705.0 ,
479 bf7 = -5764801.0*tau*(16464.0*tau_3 - 32797.0*tau_2 + 17574.0*tau - 1927.0)/7239323520.0 ,
480 bf8 = 37.0*tau*(336.0*tau_3 - 661.0*tau_2 + 342.0*tau -31.0)/1440.0 ,
481 bf9 = tau*(tau-1.0)*(16.0*tau_2 - 15.0*tau +3.0)/4.0 ,
482 bf10 = 8.0*tau*(tau - 1.0)*(tau - 1.0)*(2.0*tau - 1.0) ;
484 for(
int i=0; i<numberOfVariables; i++){
485 yOut[i] = yIn[i] + Step*tau*( bf1*dydx[i] + bf4*ak4[i] + bf5*ak5[i] +
486 bf6*ak6[i] + bf7*ak7[i] + bf8*ak8[i] +
487 bf9*ak9[i] + bf10*ak10_low[i] ) ;
517 b101 = 33797.0/460800.0 ,
520 b104 = 27757.0/70785.0 ,
521 b105 = 7923501.0/26329600.0 ,
522 b106 = -927.0/3760.0 ,
523 b107 = -3314760575.0/23165835264.0 ,
524 b108 = 2479.0/23040.0 ,
527 b111 = 5843.0/76800.0 ,
530 b114 = 464.0/2673.0 ,
531 b115 = 353997.0/1196800.0 ,
532 b116 = -15068.0/57105.0 ,
533 b117 = -282475249.0/3644974080.0 ,
534 b118 = 8678831.0/156245760.0 ,
535 b119 = 116113.0/11718432.0 ,
536 b1110 = -25.0/243.0 ,
538 b121 = 15088049.0/199065600.0 ,
542 b125 = 92222037.0/268083200.0 ,
543 b126 = -433420501.0/1528586640.0 ,
544 b127 = -11549242677007.0/83630285291520.0 ,
545 b128 = 2725085557.0/26167173120.0 ,
546 b129 = 235429367.0/16354483200.0 ,
547 b1210 = -90924917.0/1040739840.0 ,
548 b1211 = -271149.0/21414400.0 ;
554 for(
int i=0;i<numberOfVariables;i++)
565 ak10 =
new G4double[numberOfVariables];
567 ak11 =
new G4double[numberOfVariables];
569 ak12 =
new G4double[numberOfVariables];
573 for(
int i=0;i<numberOfVariables;i++)
575 yTemp[i] = yIn[i] + Step*(b101*dydx[i] + b102*ak2[i] + b103*ak3[i] +
576 b104*ak4[i] + b105*ak5[i] + b106*ak6[i] +
577 b107*ak7[i] + b108*ak8[i] + b109*ak9[i]);
581 for(
int i=0;i<numberOfVariables;i++)
583 yTemp[i] = yIn[i] + Step*(b111*dydx[i] + b112*ak2[i] + b113*ak3[i] +
584 b114*ak4[i] + b115*ak5[i] + b116*ak6[i] +
585 b117*ak7[i] + b118*ak8[i] + b119*ak9[i] +
590 for(
int i=0;i<numberOfVariables;i++)
592 yTemp[i] = yIn[i] + Step*(b121*dydx[i] + b122*ak2[i] + b123*ak3[i] +
593 b124*ak4[i] + b125*ak5[i] + b126*ak6[i] +
594 b127*ak7[i] + b128*ak8[i] + b129*ak9[i] +
595 b1210*ak10[i] + b1211*ak11[i]);
618 bi[1][1] = -18487.0/2880.0 ,
619 bi[1][2] = 139189.0/7200.0 ,
620 bi[1][3] = -53923.0/1800.0 ,
621 bi[1][4] = 13811.0/600,
622 bi[1][5] = -2071.0/300,
645 bi[4][1] = -30208.0/14157.0 ,
646 bi[4][2] = 1147904.0/70785.0 ,
647 bi[4][3] = -241664.0/5445.0 ,
648 bi[4][4] = 241664.0/4719.0 ,
649 bi[4][5] = -483328.0/23595.0 ,
654 bi[5][1] = -177147.0/32912.0 ,
655 bi[5][2] = 3365793.0/82280.0 ,
656 bi[5][3] = -2302911.0/20570.0 ,
657 bi[5][4] = 531441.0/4114.0 ,
658 bi[5][5] = -531441.0/10285.0 ,
663 bi[6][1] = 536.0/141.0 ,
664 bi[6][2] = -20368.0/705.0 ,
665 bi[6][3] = 55744.0/705.0 ,
666 bi[6][4] = -4288.0/47.0 ,
667 bi[6][5] = 8576.0/235,
672 bi[7][1] = -1977326743.0/723932352.0 ,
673 bi[7][2] = 37569208117.0/1809830880.0 ,
674 bi[7][3] = -1977326743.0/34804440.0 ,
675 bi[7][4] = 1977326743.0/30163848.0 ,
676 bi[7][5] = -1977326743.0/75409620.0 ,
681 bi[8][1] = 259.0/144.0 ,
682 bi[8][2] = -4921.0/360.0 ,
683 bi[8][3] = 3367.0/90.0 ,
684 bi[8][4] = -259.0/6.0 ,
685 bi[8][5] = 259.0/15.0 ,
690 bi[9][1] = 62.0/105.0 ,
691 bi[9][2] = -2381.0/525.0 ,
692 bi[9][3] = 949.0/75.0 ,
693 bi[9][4] = -2636.0/175.0 ,
694 bi[9][5] = 1112.0/175.0 ,
699 bi[10][1] = 43.0/3.0 ,
700 bi[10][2] = -1534.0/15.0 ,
701 bi[10][3] = 3767.0/15.0 ,
702 bi[10][4] = -1264.0/5.0 ,
703 bi[10][5] = 448.0/5.0 ,
708 bi[11][1] = 63.0/5.0 ,
709 bi[11][2] = -1494.0/25.0 ,
710 bi[11][3] = 2907.0/25.0 ,
711 bi[11][4] = -2592.0/25.0 ,
712 bi[11][5] = 864.0/25.0 ,
717 bi[12][1] = -576.0/35.0 ,
718 bi[12][2] = 19584.0/175.0 ,
719 bi[12][3] = -6336.0/25.0 ,
720 bi[12][4] = 41472.0/175.0 ,
721 bi[12][5] = -13824.0/175.0 ;
725 for(
G4int i = 0; i< numberOfVariables; i++)
731 for(
int i=1; i<=12; i++){
734 for(
int j=0; j<=5; j++){
735 b[i] += bi[i][j]*tau;
743 for(
int i=0; i<numberOfVariables; i++){
744 yOut[i] = yIn[i] + Step*tau0*(b[1]*dydx[i] + b[2]*ak2[i] + b[3]*ak3[i] +
745 b[4]*ak4[i] + b[5]*ak5[i] + b[6]*ak6[i] +
746 b[7]*ak7[i] + b[8]*ak8[i] + b[9]*ak9[i] +
747 b[10]*ak10[i] + b[11]*ak11[i] + b[12]*ak12[i]);
G4double DistChord() const
void Interpolate_high(const G4double yInput[], const G4double dydx[], const G4double Step, G4double yOut[], G4double tau)
void SetupInterpolate_high(const G4double yInput[], const G4double dydx[], const G4double Step)
void Interpolate_low(const G4double yInput[], const G4double dydx[], const G4double Step, G4double yOut[], G4double tau)
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4DormandPrinceRK56(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
G4int GetNumberOfVariables() const
void SetupInterpolate_low(const G4double yInput[], const G4double dydx[], const G4double Step)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void RightHandSide(const double y[], double dydx[])