52 G4int noIntegrationVariables,
56 const G4int numberOfVariables = noIntegrationVariables;
62 ak2 =
new G4double[numberOfVariables];
63 ak3 =
new G4double[numberOfVariables];
64 ak4 =
new G4double[numberOfVariables];
65 ak5 =
new G4double[numberOfVariables];
66 ak6 =
new G4double[numberOfVariables];
67 ak7 =
new G4double[numberOfVariables];
71 ak8 =
new G4double[numberOfVariables];
72 ak9 =
new G4double[numberOfVariables];
74 yTemp =
new G4double[numberOfVariables] ;
75 yIn =
new G4double[numberOfVariables] ;
77 pseudoDydx_for_DistChord =
new G4double[numberOfVariables];
79 fInitialDyDx =
new G4double[numberOfVariables];
80 fLastInitialVector =
new G4double[numberOfVariables] ;
81 fLastFinalVector =
new G4double[numberOfVariables] ;
82 fLastDyDx =
new G4double[numberOfVariables];
84 fMidVector =
new G4double[numberOfVariables];
85 fMidError =
new G4double[numberOfVariables];
99 delete [] ak2; ak2 =
nullptr;
100 delete [] ak3; ak3 =
nullptr;
101 delete [] ak4; ak4 =
nullptr;
102 delete [] ak5; ak5 =
nullptr;
103 delete [] ak6; ak6 =
nullptr;
104 delete [] ak7; ak7 =
nullptr;
105 delete [] ak8; ak8 =
nullptr;
106 delete [] ak9; ak9 =
nullptr;
108 delete [] yTemp; yTemp =
nullptr;
109 delete [] yIn; yIn =
nullptr;
111 delete [] pseudoDydx_for_DistChord; pseudoDydx_for_DistChord =
nullptr;
112 delete [] fInitialDyDx; fInitialDyDx =
nullptr;
114 delete [] fLastInitialVector; fLastInitialVector =
nullptr;
115 delete [] fLastFinalVector; fLastFinalVector =
nullptr;
116 delete [] fLastDyDx; fLastDyDx =
nullptr;
117 delete [] fMidVector; fMidVector =
nullptr;
118 delete [] fMidError; fMidError =
nullptr;
120 delete fAuxStepper; fAuxStepper =
nullptr;
140 b31 = 3.0/40.0, b32 = 9.0/40.0 ,
142 b41 = 44.0/45.0, b42 = -56.0/15.0, b43 = 32.0/9.0,
144 b51 = 19372.0/6561.0, b52 = -25360.0/2187.0,
145 b53 = 64448.0/6561.0, b54 = -212.0/729.0 ,
147 b61 = 9017.0/3168.0 , b62 = -355.0/33.0,
148 b63 = 46732.0/5247.0 , b64 = 49.0/176.0 ,
149 b65 = -5103.0/18656.0 ,
151 b71 = 35.0/384.0, b72 = 0.,
152 b73 = 500.0/1113.0, b74 = 125.0/192.0,
153 b75 = -2187.0/6784.0, b76 = 11.0/84.0,
160 dc1 = b71 - 5179.0/57600.0,
162 dc3 = b73 - 7571.0/16695.0,
163 dc4 = b74 - 393.0/640.0,
164 dc5 = b75 + 92097.0/339200.0,
165 dc6 = b76 - 187.0/2100.0,
173 for(i=0; i<numberOfVariables; ++i)
176 fInitialDyDx[i] = dydx[i];
180 yOut[7] = yTemp[7] = yInput[7];
183 for(i=0; i<numberOfVariables; ++i)
185 yTemp[i] = yIn[i] + b21*Step*fInitialDyDx[i] ;
189 for(i=0; i<numberOfVariables; ++i)
191 yTemp[i] = yIn[i] + Step*(b31*fInitialDyDx[i] + b32*ak2[i]) ;
195 for(i=0; i<numberOfVariables; ++i)
197 yTemp[i] = yIn[i] + Step*(b41*fInitialDyDx[i]
198 + b42*ak2[i] + b43*ak3[i]) ;
202 for(i=0; i<numberOfVariables; ++i)
204 yTemp[i] = yIn[i] + Step*(b51*fInitialDyDx[i]
205 + b52*ak2[i] + b53*ak3[i] + b54*ak4[i]) ;
209 for(i=0; i<numberOfVariables; ++i)
211 yTemp[i] = yIn[i] + Step*(b61*fInitialDyDx[i] + b62*ak2[i]
212 + b63*ak3[i] + b64*ak4[i] + b65*ak5[i]) ;
216 for(i=0; i<numberOfVariables; ++i)
218 yOut[i] = yIn[i] + Step*(b71*fInitialDyDx[i] + b72*ak2[i] + b73*ak3[i]
219 + b74*ak4[i] + b75*ak5[i] + b76*ak6[i]);
223 for(i=0; i<numberOfVariables; ++i)
226 yErr[i] = Step*(dc1*fInitialDyDx[i] + dc2*ak2[i] + dc3*ak3[i]
227 + dc4*ak4[i] + dc5*ak5[i] + dc6*ak6[i] + dc7*ak7[i] ) ;
231 fLastInitialVector[i] = yIn[i] ;
232 fLastFinalVector[i] = yOut[i];
233 fLastDyDx[i] = fInitialDyDx[i];
234 nextDydx[i] = ak7[i];
236 fLastStepLength = Step;
252 fLastInitialVector[1], fLastInitialVector[2]);
254 fLastFinalVector[1], fLastFinalVector[2]);
258 fAuxStepper->
Stepper( fLastInitialVector, fLastDyDx, 0.5 * fLastStepLength,
259 fMidVector, fMidError, pseudoDydx_for_DistChord );
261 midPoint =
G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2] );
266 if (initialPoint != finalPoint)
269 distChord = distLine;
273 distChord = (midPoint-initialPoint).mag();
286 G4double bf1, bf2, bf3, bf4, bf5, bf6, bf7;
292 for(
G4int i=0;i<numberOfVariables; ++i)
301 bf1 = (157015080.0*tau_4 - 13107642775.0*tau_3
302 + 34969693132.0*tau_2- 32272833064.0*tau + 11282082432.0)
305 bf3 = - 100.0*tau*(15701508.0*tau_3 - 914128567.0*tau_2
306 + 2074956840.0*tau - 1323431896.0) / 32700410799.0;
307 bf4 = 25.0*tau*(94209048.0*tau_3- 1518414297.0*tau_2
308 + 2460397220.0*tau - 889289856.0)
310 bf5 = -2187.0*tau*(52338360.0*tau_3 - 451824525.0*tau_2
311 + 687873124.0*tau - 259006536.0)
313 bf6 = 11.0*tau*(106151040.0*tau_3- 661884105.0*tau_2
314 + 946554244.0*tau - 361440756.0)
316 bf7 = tau*(1.0 - tau)*(8293050.0*tau_2 - 82437520.0*tau + 44764047.0)
319 for(
G4int i=0; i<numberOfVariables; ++i)
321 yOut[i] = yIn[i] + Step*tau*(bf1*dydx[i] + bf2*ak2[i] + bf3*ak3[i]
322 + bf4*ak4[i] + bf5*ak5[i] + bf6*ak6[i]
337 b83 = 8875.0/103032.0 ,
338 b84 = -125.0/1728.0 ,
339 b85 = 801.0/13568.0 ,
340 b86 = -13519.0/368064.0 ,
341 b87 = 11105.0/368064.0 ,
343 b91 = 632855.0/4478976.0 ,
345 b93 = 4146875.0/6491016.0 ,
346 b94 = 5490625.0/14183424.0 ,
347 b95 = -15975.0/108544.0 ,
348 b96 = 8295925.0/220286304.0 ,
349 b97 = -1779595.0/62938944.0 ,
350 b98 = -805.0/4104.0 ;
356 for(
G4int i=0; i<numberOfVariables; ++i)
365 for(
G4int i=0; i<numberOfVariables; ++i)
367 yTemp[i] = yIn[i] + Step*( b81*dydx[i] + b82*ak2[i] + b83*ak3[i] +
368 b84*ak4[i] + b85*ak5[i] + b86*ak6[i] +
373 for(
G4int i=0; i<numberOfVariables; ++i)
375 yTemp[i] = yIn[i] + Step * ( b91*dydx[i] + b92*ak2[i] + b93*ak3[i] +
376 b94*ak4[i] + b95*ak5[i] + b96*ak6[i] +
377 b97*ak7[i] + b98*ak8[i] );
397 bi[1][1] = -38039.0/7040.0 ,
398 bi[1][2] = 125923.0/10560.0 ,
399 bi[1][3] = -19683.0/1760.0 ,
400 bi[1][4] = 3303.0/880.0 ,
413 bi[3][1] = -12500.0/4081.0 ,
414 bi[3][2] = 205000.0/12243.0 ,
415 bi[3][3] = -90000.0/4081.0 ,
416 bi[3][4] = 36000.0/4081.0 ,
421 bi[4][1] = -3125.0/704.0 ,
422 bi[4][2] = 25625.0/1056.0 ,
423 bi[4][3] = -5625.0/176.0 ,
424 bi[4][4] = 1125.0/88.0 ,
429 bi[5][1] = 164025.0/74624.0 ,
430 bi[5][2] = -448335.0/37312.0 ,
431 bi[5][3] = 295245.0/18656.0 ,
432 bi[5][4] = -59049.0/9328.0 ,
437 bi[6][1] = -25.0/28.0 ,
438 bi[6][2] = 205.0/42.0 ,
439 bi[6][3] = -45.0/7.0 ,
440 bi[6][4] = 18.0/7.0 ,
445 bi[7][1] = -2.0/11.0 ,
446 bi[7][2] = 73.0/55.0 ,
447 bi[7][3] = -171.0/55.0 ,
448 bi[7][4] = 108.0/55.0 ,
453 bi[8][1] = 189.0/22.0 ,
454 bi[8][2] = -1593.0/55.0 ,
455 bi[8][3] = 3537.0/110.0 ,
456 bi[8][4] = -648.0/55.0 ,
461 bi[9][1] = 351.0/110.0 ,
462 bi[9][2] = -999.0/55.0 ,
463 bi[9][3] = 2943.0/110.0 ,
464 bi[9][4] = -648.0/55.0 ;
467 for(
G4int i = 0; i< numberOfVariables; ++i)
476 for(
auto i=1; i<=9; ++i)
480 for(
auto j=0; j<=4; ++j)
482 b[i] += bi[i][j]*tau;
487 for(
G4int i=0; i<numberOfVariables; ++i)
489 yOut[i] = yIn[i] + Step*tau0*(b[1]*dydx[i] + b[2]*ak2[i] + b[3]*ak3[i] +
490 b[4]*ak4[i] + b[5]*ak5[i] + b[6]*ak6[i] +
491 b[7]*ak7[i] + b[8]*ak8[i] + b[9]*ak9[i] );
CLHEP::Hep3Vector G4ThreeVector
G4FSALDormandPrince745(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[], G4double nextDydx[])
void Interpolate(const G4double yInput[], const G4double dydx[], const G4double Step, G4double yOut[], G4double tau)
void interpolate(const G4double yInput[], const G4double dydx[], G4double yOut[], G4double Step, G4double tau)
G4double DistChord() const
~G4FSALDormandPrince745()
void SetupInterpolate(const G4double yInput[], const G4double dydx[], const G4double Step)
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4int GetNumberOfVariables() const
void RightHandSide(const double y[], double dydx[])