72 G4bool G4BogackiShampine45::fPreparedConstants=
false;
73 G4double G4BogackiShampine45::bi[12][7];
77 G4int noIntegrationVariables,
81 fPreparedInterpolation(false)
84 const G4int numberOfVariables = noIntegrationVariables;
89 ak2 =
new G4double[numberOfVariables];
90 ak3 =
new G4double[numberOfVariables];
91 ak4 =
new G4double[numberOfVariables];
92 ak5 =
new G4double[numberOfVariables];
93 ak6 =
new G4double[numberOfVariables];
94 ak7 =
new G4double[numberOfVariables];
95 ak8 =
new G4double[numberOfVariables];
96 ak9 =
new G4double[numberOfVariables];
97 ak10 =
new G4double[numberOfVariables];
98 ak11 =
new G4double[numberOfVariables];
100 for (
int i = 0; i < 6; i++) {
112 fLastInitialVector =
new G4double[numStateVars] ;
113 fLastFinalVector =
new G4double[numStateVars] ;
114 fLastDyDx =
new G4double[numberOfVariables];
116 fMidVector =
new G4double[numberOfVariables];
117 fMidError =
new G4double[numberOfVariables];
119 if( ! fPreparedConstants )
143 for (
int i = 0; i < 6; i++) {
150 delete[] fLastInitialVector;
151 delete[] fLastFinalVector;
168 for(
G4int i=0; i < numberOfVariables; i++ ){
169 dyDxLast[i] = ak9[i];
189 b31 = 2.0/27.0 , b32 = 4.0/27.0,
191 b41 = 183.0/1372.0 , b42 = -162.0/343.0, b43 = 1053.0/1372.0,
193 b51 = 68.0/297.0, b52 = -4.0/11.0,
194 b53 = 42.0/143.0, b54 = 1960.0/3861.0,
196 b61 = 597.0/22528.0, b62 = 81.0/352.0,
197 b63 = 63099.0/585728.0, b64 = 58653.0/366080.0,
198 b65 = 4617.0/20480.0,
200 b71 = 174197.0/959244.0, b72 = -30942.0/79937.0,
201 b73 = 8152137.0/19744439.0, b74 = 666106.0/1039181.0,
202 b75 = -29421.0/29068.0, b76 = 482048.0/414219.0,
204 b81 = 587.0/8064.0, b82 = 0.0,
205 b83 = 4440339.0/15491840.0, b84 = 24353.0/124800.0,
206 b85 = 387.0/44800.0, b86 = 2152.0/5985.0,
207 b87 = 7267.0/94080.0;
223 dc1 = b81 - 2479.0 / 34992.0 ,
225 dc3 = b83 - 123.0 / 416.0 ,
226 dc4 = b84 - 612941.0 / 3411720.0,
227 dc5 = b85 - 43.0 / 1440.0,
228 dc6 = b86 - 2272.0 / 6561.0,
229 dc7 = b87 - 79937.0 / 1113912.0,
230 dc8 = - 3293.0 / 556956.0;
235 yOut[7] = yTemp[7] = yIn[7];
238 for(i=0;i<numberOfVariables;i++)
246 for(i=0;i<numberOfVariables;i++)
248 yTemp[i] = yIn[i] + b21*Step*DyDx[i] ;
252 for(i=0;i<numberOfVariables;i++)
254 yTemp[i] = yIn[i] + Step*(b31*DyDx[i] + b32*ak2[i]) ;
258 for(i=0;i<numberOfVariables;i++)
260 yTemp[i] = yIn[i] + Step*(b41*DyDx[i] + b42*ak2[i] + b43*ak3[i]) ;
264 for(i=0;i<numberOfVariables;i++)
266 yTemp[i] = yIn[i] + Step*(b51*DyDx[i] + b52*ak2[i] + b53*ak3[i] +
271 for(i=0;i<numberOfVariables;i++)
273 yTemp[i] = yIn[i] + Step*(b61*DyDx[i] + b62*ak2[i] + b63*ak3[i] +
274 b64*ak4[i] + b65*ak5[i]) ;
278 for(i=0;i<numberOfVariables;i++)
280 yTemp[i] = yIn[i] + Step*(b71*DyDx[i] + b72*ak2[i] + b73*ak3[i] +
281 b74*ak4[i] + b75*ak5[i] + b76*ak6[i]);
285 for(i=0;i<numberOfVariables;i++)
287 yOut[i] = yIn[i] + Step*(b81*DyDx[i] + b82*ak2[i] + b83*ak3[i] +
288 b84*ak4[i] + b85*ak5[i] + b86*ak6[i] +
293 for(i=0;i<numberOfVariables;i++)
295 yErr[i] = Step*(dc1*DyDx[i] + dc2*ak2[i] + dc3*ak3[i] + dc4*ak4[i] +
296 dc5*ak5[i] + dc6*ak6[i] + dc7*ak7[i] + dc8*ak8[i]) ;
299 fLastInitialVector[i] = yIn[i] ;
300 fLastFinalVector[i] = yOut[i];
301 fLastDyDx[i] = DyDx[i];
304 fLastStepLength = Step;
305 fPreparedInterpolation=
false;
321 fLastInitialVector[1], fLastInitialVector[2]);
323 fLastFinalVector[1], fLastFinalVector[2]);
327 fAuxStepper->
Stepper( fLastInitialVector, fLastDyDx, 0.5 * fLastStepLength,
328 fMidVector, fMidError);
333 if( ! fPreparedInterpolation ) {
344 midPoint =
G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2]);
349 if (initialPoint != finalPoint)
352 distChord = distLine;
356 distChord = (midPoint-initialPoint).mag();
368 a93 = 10256301.0/35409920.0 ,
369 a94 = 2307361.0/17971200.0 ,
370 a95 = -387.0/102400.0 ,
372 a97 = -7267.0/215040.0 ,
375 a101 = -837888343715.0/13176988637184.0 ,
376 a102 = 30409415.0/52955362.0 ,
377 a103 = -48321525963.0/759168069632.0 ,
378 a104 = 8530738453321.0/197654829557760.0 ,
379 a105 = 1361640523001.0/1626788720640.0 ,
380 a106 = -13143060689.0/38604458898.0 ,
381 a107 = 18700221969.0/379584034816.0 ,
382 a108 = -5831595.0/847285792.0 ,
383 a109 = -5183640.0/26477681.0 ,
385 a111 = 98719073263.0/1551965184000.0 ,
386 a112 = 1307.0/123552.0 ,
387 a113 = 4632066559387.0/70181753241600.0 ,
388 a114 = 7828594302389.0/382182512025600.0 ,
389 a115 = 40763687.0/11070259200.0 ,
390 a116 = 34872732407.0/224610586200.0 ,
391 a117 = -2561897.0/30105600.0 ,
394 a1110 = -1403317093.0/11371610250.0 ;
400 const G4double Step = fLastStepLength;
405 for(
int i=0; i<numberOfVariables; i++){
406 yTemp[i] = yIn[i] + Step*(a91*dydx[i] + a92*ak2[i] + a93*ak3[i] +
407 a94*ak4[i] + a95*ak5[i] + a96*ak6[i] +
408 a97*ak7[i] + a98*ak8[i] );
413 for(
int i=0; i<numberOfVariables; i++){
414 yTemp[i] = yIn[i] + Step*(a101*dydx[i] + a102*ak2[i] + a103*ak3[i] +
415 a104*ak4[i] + a105*ak5[i] + a106*ak6[i] +
416 a107*ak7[i] + a108*ak8[i] + a109*ak9[i] );
421 for(
int i=0; i<numberOfVariables; i++){
422 yTemp[i] = yIn[i] + Step*(a111*dydx[i] + a112*ak2[i] + a113*ak3[i] +
423 a114*ak4[i] + a115*ak5[i] + a116*ak6[i] +
424 a117*ak7[i] + a118*ak8[i] + a119*ak9[i] +
430 int nwant = numberOfVariables;
436 for (
int l = 0; l < nwant; l++) {
438 p[5][l] = bi[5][6]*ak5[l] +
439 ((bi[10][6]*ak10[l] + bi[8][6]*ak8[l]) +
440 (bi[7][6]*ak7[l] + bi[6][6]*ak6[l])) +
441 ((bi[4][6]*ak4[l] + bi[9][6]*ak9[l]) +
442 (bi[3][6]*ak3[l] + bi[11][6]*ak11[l]) +
445 p[4][l] = (bi[10][5]*ak10[l] + bi[9][5]*ak9[l]) +
446 ((bi[7][5]*ak7[l] + bi[6][5]*ak6[l]) +
447 bi[5][5]*ak5[l]) + ((bi[4][5]*ak4[l] +
448 bi[8][5]*ak8[l]) + (bi[3][5]*ak3[l] +
449 bi[11][5]*ak11[l]) + bi[1][5]*dydx[l]);
451 p[3][l] = ((bi[4][4]*ak4[l] + bi[8][4]*ak8[l]) +
452 (bi[7][4]*ak7[l] + bi[6][4]*ak6[l]) +
453 bi[5][4]*ak5[l]) + ((bi[10][4]*ak10[l] +
454 bi[9][4]*ak9[l]) + (bi[3][4]*ak3[l] +
455 bi[11][4]*ak11[l]) + bi[1][4]*dydx[l]);
457 p[2][l] = bi[5][3]*ak5[l] + bi[6][3]*ak6[l] +
458 ((bi[3][3]*ak3[l] + bi[9][3]*ak9[l]) +
459 (bi[10][3]*ak10[l]+ bi[8][3]*ak8[l]) + bi[1][3]*dydx[l]) +
460 ((bi[4][3]*ak4[l] + bi[11][3]*ak11[l]) + bi[7][3]*ak7[l]);
462 p[1][l] = bi[5][2]*ak5[l] + ((bi[6][2]*ak6[l] +
463 bi[8][2]*ak8[l]) + bi[1][2]*dydx[l]) +
464 ((bi[3][2]*ak3[l] + bi[9][2]*ak9[l]) +
465 bi[10][2]*ak10[l])+ ((bi[4][2]*ak4[l] +
466 bi[11][2]*ak2[l]) + bi[7][2]*ak7[l]);
471 for (
int i = 0; i < 6; i++) {
472 for (
int l = 0; l < nwant; l++) {
477 fPreparedInterpolation=
true;
482 for(
int i=1; i<= 11; i++)
485 for(
int i=1; i<=6; i++)
488 bi[1][6] = -12134338393.0 / 1050809760.0 ,
489 bi[1][5] = -1620741229.0 / 50038560.0 ,
490 bi[1][4] = -2048058893.0 / 59875200.0 ,
491 bi[1][3] = -87098480009.0 / 5254048800.0 ,
492 bi[1][2] = -11513270273.0 / 3502699200.0 ,
494 bi[3][6] = -33197340367.0 / 1218433216.0 ,
495 bi[3][5] = -539868024987.0 / 6092166080.0 ,
496 bi[3][4] = -39991188681.0 / 374902528.0 ,
497 bi[3][3] = -69509738227.0 / 1218433216.0 ,
498 bi[3][2] = -29327744613.0 / 2436866432.0 ,
500 bi[4][6] = -284800997201.0 / 19905339168.0 ,
501 bi[4][5] = -7896875450471.0 / 165877826400.0 ,
502 bi[4][4] = -333945812879.0 / 5671036800.0 ,
503 bi[4][3] = -16209923456237.0 / 497633479200.0 ,
504 bi[4][2] = -2382590741699.0 / 331755652800.0 ,
506 bi[5][6] = -540919.0 / 741312.0 ,
507 bi[5][5] = -103626067.0 / 43243200.0 ,
508 bi[5][4] = -633779.0 / 211200.0 ,
509 bi[5][3] = -32406787.0 / 18532800.0 ,
510 bi[5][2] = -36591193.0 / 86486400.0 ,
512 bi[6][6] = 7157998304.0 / 374350977.0 ,
513 bi[6][5] = 30405842464.0 / 623918295.0 ,
514 bi[6][4] = 183022264.0 / 5332635.0 ,
515 bi[6][3] = -3357024032.0 / 1871754885.0 ,
516 bi[6][2] = -611586736.0 / 89131185.0 ,
518 bi[7][6] = -138073.0 / 9408.0 ,
519 bi[7][5] = -719433.0 / 15680.0 ,
520 bi[7][4] = -1620541.0 / 31360.0 ,
521 bi[7][3] = -385151.0 / 15680.0 ,
522 bi[7][2] = -65403.0 / 15680.0 ,
524 bi[8][6] = 1245.0 / 64.0 ,
525 bi[8][5] = 3991.0 / 64.0 ,
526 bi[8][4] = 4715.0 / 64.0 ,
527 bi[8][3] = 2501.0 / 64.0 ,
528 bi[8][2] = 149.0 / 16.0 ,
531 bi[9][6] = 55.0 / 3.0 ,
534 bi[9][3] = 199.0 / 3.0 ,
537 bi[10][6] = -1774004627.0 / 75810735.0 ,
538 bi[10][5] = -1774004627.0 / 25270245.0 ,
539 bi[10][4] = -26477681.0 / 359975.0 ,
540 bi[10][3] = -11411880511.0 / 379053675.0 ,
541 bi[10][2] = -423642896.0 / 126351225.0 ,
548 fPreparedConstants=
true;
554 G4int numberOfVariables = this->GetNumberOfVariables();
555 assert( fPreparedConstants);
557 G4Exception(
"G4BogackiShampine45::InterpolateHigh()",
"GeomField0001",
562 const G4double Step = fLastStepLength;
566 G4int nwant = numberOfVariables;
567 const G4int norder= 6;
570 for (l = 0; l < nwant; l++) {
571 yOut[l] =
p[norder-1][l] * tau;
573 for (k = norder - 2; k >= 1; k--) {
574 for (l = 0; l < nwant; l++) {
575 yOut[l] = ( yOut[l] +
p[k][l] ) * tau;
578 for (l = 0; l < nwant; l++) {
579 yOut[l] = ( yOut[l] + Step * ak8[l] ) * tau + yIn[l];
589 for(
int iStage=1; iStage<=11; iStage++){
592 for(
int j=6; j>=1; j--){
593 b[iStage] += bi[iStage][j] * tau;
598 for(
int i=0; i<numberOfVariables; i++){
599 yOut[i] = yIn[i] + Step*(b[1] * dydx[i] + b[2] *
ak2[i] + b[3] * ak3[i] +
600 b[4] * ak4[i] + b[5] * ak5[i] + b[6] * ak6[i] +
601 b[7] * ak7[i] + b[8] * ak8[i] + b[9] * ak9[i] +
602 b[10] * ak10[i] + b[11] * ak11[i] );
G4BogackiShampine45(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
void InterpolateHigh(G4double tau, G4double yOut[]) const
void SetupInterpolationHigh()
CLHEP::Hep3Vector G4ThreeVector
static const G4double ak2
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[])
G4int GetNumberOfVariables() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4int GetNumberOfStateVariables() const
void GetLastDydx(G4double dyDxLast[])
void RightHandSide(const double y[], double dydx[])
G4double DistChord() const