Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4DormandPrinceRK56.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // FDormand-Prince RK 6(5) FSAL implementation by Somnath Banerjee
27 // Supervision / code review: John Apostolakis
28 //
29 // Sponsored by Google in Google Summer of Code 2015.
30 //
31 // First version: 26 June 2015
32 //
33 // G4DormandPrince745.cc
34 // Geant4
35 //
36 // History
37 // -----------------------------
38 // Created by Somnath on 26 June 2015
39 //
40 //
42 
43 #include "G4DormandPrinceRK56.hh"
44 #include "G4LineSection.hh"
45 
46 //Constructor
48  G4int noIntegrationVariables,
49  G4bool primary)
50 : G4MagIntegratorStepper(EqRhs, noIntegrationVariables),
51  fLastStepLength(-1.0), fAuxStepper(nullptr)
52 {
53  const G4int numberOfVariables = noIntegrationVariables;
54 
55  //New Chunk of memory being created for use by the stepper
56 
57  //aki - for storing intermediate RHS
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 = new G4double[numberOfVariables];
64  ak8 = new G4double[numberOfVariables];
65  ak9 = new G4double[numberOfVariables];
66 
67  // Memory for Additional stages
68  ak10 = new G4double[numberOfVariables];
69  ak11 = new G4double[numberOfVariables];
70  ak12 = new G4double[numberOfVariables];
71  ak10_low = new G4double[numberOfVariables];
72 
73  const G4int numStateVars = std::max(noIntegrationVariables, 8);
74  yTemp = new G4double[numStateVars];
75  yIn = new G4double[numStateVars] ;
76 
77  fLastInitialVector = new G4double[numStateVars] ;
78  fLastFinalVector = new G4double[numStateVars] ;
79 
80  fLastDyDx = new G4double[numStateVars];
81 
82  fMidVector = new G4double[numStateVars];
83  fMidError = new G4double[numStateVars];
84 
85  if( primary )
86  {
87  fAuxStepper = new G4DormandPrinceRK56(EqRhs, numberOfVariables,
88  !primary);
89  }
90 }
91 
92 
93 //Destructor
95  //clear all previously allocated memory for stepper and DistChord
96  delete[] ak2;
97  delete[] ak3;
98  delete[] ak4;
99  delete[] ak5;
100  delete[] ak6;
101  delete[] ak7;
102  delete[] ak8;
103  delete[] ak9;
104 
105  delete[] ak10;
106  delete[] ak10_low;
107  delete[] ak11;
108  delete[] ak12;
109 
110  delete[] yTemp;
111  delete[] yIn;
112 
113  delete[] fLastInitialVector;
114  delete[] fLastFinalVector;
115  delete[] fLastDyDx;
116  delete[] fMidVector;
117  delete[] fMidError;
118 
119  delete fAuxStepper;
120 
121 }
122 
123 
124 //Stepper :
125 
126 // Passing in the value of yInput[],the first time dydx[] and Step length
127 // Giving back yOut and yErr arrays for output and error respectively
128 
130  const G4double dydx[],
131  G4double Step,
132  G4double yOut[],
133  G4double yErr[] )
134  // G4double nextDydx[] ) -- Output:
135  // endpoint DyDx ( for future FSAL version )
136 {
137  G4int i;
138 
139  //The various constants defined on the basis of butcher tableu
140  const G4double //G4double - only once
141 
142  // Old Coefficients from
143  // Table 1. RK6(5)8M
144 //---Ref---
145 //[P. J. Prince and J. R. Dormand, “High order embedded Runge-Kutta formulae,”
146 // Journal of Computational and Applied Mathematics, vol. 7, no. 1, pp. 67–75,
147 // Dec. 1980.
148 //----------------
149 
150  b21 = 1.0/10.0 ,
151 
152  b31 = -2.0/81.0 ,
153  b32 = 20.0/81.0 ,
154 
155  b41 = 615.0/1372.0 ,
156  b42 = -270.0/343.0 ,
157  b43 = 1053.0/1372.0 ,
158 
159  b51 = 3243.0/5500.0 ,
160  b52 = -54.0/55.0 ,
161  b53 = 50949.0/71500.0 ,
162  b54 = 4998.0/17875.0 ,
163 
164  b61 = -26492.0/37125.0 ,
165  b62 = 72.0/55.0 ,
166  b63 = 2808.0/23375.0 ,
167  b64 = -24206.0/37125.0 ,
168  b65 = 338.0/459.0 ,
169 
170  b71 = 5561.0/2376.0 ,
171  b72 = -35.0/11.0 ,
172  b73 = -24117.0/31603.0 ,
173  b74 = 899983.0/200772.0 ,
174  b75 = -5225.0/1836.0 ,
175  b76 = 3925.0/4056.0 ,
176 
177  b81 = 465467.0/266112.0 ,
178  b82 = -2945.0/1232.0 ,
179  b83 = -5610201.0/14158144.0 ,
180  b84 = 10513573.0/3212352.0 ,
181  b85 = -424325.0/205632.0 ,
182  b86 = 376225.0/454272.0 ,
183  b87 = 0.0 ,
184 
185  c1 = 61.0/864.0 ,
186  c2 = 0.0 ,
187  c3 = 98415.0/321776.0 ,
188  c4 = 16807.0/146016.0 ,
189  c5 = 1375.0/7344.0 ,
190  c6 = 1375.0/5408.0 ,
191  c7 = -37.0/1120.0 ,
192  c8 = 1.0/10.0 ,
193 
194  b91 = 61.0/864.0 ,
195  b92 = 0.0 ,
196  b93 = 98415.0/321776.0 ,
197  b94 = 16807.0/146016.0 ,
198  b95 = 1375.0/7344.0 ,
199  b96 = 1375.0/5408.0 ,
200  b97 = -37.0/1120.0 ,
201  b98 = 1.0/10.0 ,
202 
203  dc1 = c1 - 821.0/10800.0 ,
204  dc2 = c2 - 0.0 ,
205  dc3 = c3 - 19683.0/71825,
206  dc4 = c4 - 175273.0/912600.0 ,
207  dc5 = c5 - 395.0/3672.0 ,
208  dc6 = c6 - 785.0/2704.0 ,
209  dc7 = c7 - 3.0/50.0 ,
210  dc8 = c8 - 0.0 ,
211  dc9 = 0.0;
212 
213 
214 // New Coefficients obtained from
215  // Table 3 RK6(5)9FM with corrected coefficients
216 //---Ref---
217 // T. S. Baker, J. R. Dormand, J. P. Gilmore, and P. J. Prince,
218 // “Continuous approximation with embedded Runge-Kutta methods,”
219 // Applied Numerical Mathematics, vol. 22, no. 1, pp. 51–62, 1996.
220 //------------------------------------
221 
222 // b21 = 1.0/9.0 ,
223 //
224 // b31 = 1.0/24.0 ,
225 // b32 = 1.0/8.0 ,
226 //
227 // b41 = 1.0/16.0 ,
228 // b42 = 0.0 ,
229 // b43 = 3.0/16.0 ,
230 //
231 // b51 = 280.0/729.0 ,
232 // b52 = 0.0 ,
233 // b53 = -325.0/243.0 ,
234 // b54 = 1100.0/729.0 ,
235 //
236 // b61 = 6127.0/14680.0 ,
237 // b62 = 0.0 ,
238 // b63 = -1077.0/734.0 ,
239 // b64 = 6494.0/4037.0 ,
240 // b65 = -9477.0/161480.0 ,
241 //
242 // b71 = -13426273320.0/14809773769.0 ,
243 // b72 = 0.0 ,
244 // b73 = 4192558704.0/2115681967.0 ,
245 // b74 = 14334750144.0/14809773769.0 ,
246 // b75 = 117092732328.0/14809773769.0 ,
247 // b76 = -361966176.0/40353607.0 ,
248 //
249 // b81 = -2340689.0/1901060.0 ,
250 // b82 = 0.0 ,
251 // b83 = 31647.0/13579.0 ,
252 // b84 = 253549596.0/149518369.0 ,
253 // b85 = 10559024082.0/977620105.0 ,
254 // b86 = -152952.0/12173.0 ,
255 // b87 = -5764801.0/186010396.0 ,
256 //
257 // b91 = 203.0/2880.0 ,
258 // b92 = 0.0 ,
259 // b93 = 0.0 ,
260 // b94 = 30208.0/70785.0 ,
261 // b95 = 177147.0/164560.0 ,
262 // b96 = -536.0/705.0 ,
263 // b97 = 1977326743.0/3619661760.0 ,
264 // b98 = -259.0/720.0 ,
265 //
266 //
267 // dc1 = 36567.0/458800.0 - b91,
268 // dc2 = 0.0 - b92,
269 // dc3 = 0.0 - b93,
270 // dc4 = 9925984.0/27063465.0 - b94,
271 // dc5 = 85382667.0/117968950.0 - b95,
272 // dc6 = - 310378.0/808635.0 - b96 ,
273 // dc7 = 262119736669.0/345979336560.0 - b97,
274 // dc8 = - 1.0/2.0 - b98 ,
275 // dc9 = -101.0/2294.0 ;
276 
277 
278  //end of declaration
279 
280 
281  const G4int numberOfVariables= this->GetNumberOfVariables();
282 
283  // The number of variables to be integrated over
284  yOut[7] = yTemp[7] = yIn[7];
285  // Saving yInput because yInput and yOut can be aliases for same array
286 
287  for(i=0;i<numberOfVariables;i++)
288  {
289  yIn[i]=yInput[i];
290  }
291 
292 
293 
294  // RightHandSide(yIn, dydx) ;
295  // 1st Step - Not doing, getting passed
296 
297  for(i=0;i<numberOfVariables;i++)
298  {
299  yTemp[i] = yIn[i] + b21*Step*dydx[i] ;
300  }
301  RightHandSide(yTemp, ak2) ; // 2nd Stage
302 
303  for(i=0;i<numberOfVariables;i++)
304  {
305  yTemp[i] = yIn[i] + Step*(b31*dydx[i] + b32*ak2[i]) ;
306  }
307  RightHandSide(yTemp, ak3) ; // 3rd Stage
308 
309  for(i=0;i<numberOfVariables;i++)
310  {
311  yTemp[i] = yIn[i] + Step*(b41*dydx[i] + b42*ak2[i] + b43*ak3[i]) ;
312  }
313  RightHandSide(yTemp, ak4) ; // 4th Stage
314 
315  for(i=0;i<numberOfVariables;i++)
316  {
317  yTemp[i] = yIn[i] + Step*(b51*dydx[i] + b52*ak2[i] + b53*ak3[i] +
318  b54*ak4[i]) ;
319  }
320  RightHandSide(yTemp, ak5) ; // 5th Stage
321 
322  for(i=0;i<numberOfVariables;i++)
323  {
324  yTemp[i] = yIn[i] + Step*(b61*dydx[i] + b62*ak2[i] + b63*ak3[i] +
325  b64*ak4[i] + b65*ak5[i]) ;
326  }
327  RightHandSide(yTemp, ak6) ; // 6th Stage
328 
329  for(i=0;i<numberOfVariables;i++)
330  {
331  yTemp[i] = yIn[i] + Step*(b71*dydx[i] + b72*ak2[i] + b73*ak3[i] +
332  b74*ak4[i] + b75*ak5[i] + b76*ak6[i]);
333  }
334  RightHandSide(yTemp, ak7); //7th Stage
335 
336  for(i=0;i<numberOfVariables;i++)
337  {
338  yTemp[i] = yIn[i] + Step*(b81*dydx[i] + b82*ak2[i] + b83*ak3[i] +
339  b84*ak4[i] + b85*ak5[i] + b86*ak6[i] +
340  b87*ak7[i]);
341  }
342  RightHandSide(yTemp, ak8); //8th Stage
343 
344  for(i=0;i<numberOfVariables;i++)
345  {
346  yOut[i] = yIn[i] + Step*(b91*dydx[i] + b92*ak2[i] + b93*ak3[i] +
347  b94*ak4[i] + b95*ak5[i] + b96*ak6[i] +
348  b97*ak7[i] + b98*ak8[i] );
349  }
350  RightHandSide(yOut, ak9); //9th Stage
351 
352 
353  for(i=0;i<numberOfVariables;i++)
354  {
355 
356  // Estimate error as difference between 5th and
357  // 6th order methods
358 
359  yErr[i] = Step*( dc1*dydx[i] + dc2*ak2[i] + dc3*ak3[i] + dc4*ak4[i]
360  + dc5*ak5[i] + dc6*ak6[i] + dc7*ak7[i] + dc8*ak8[i]
361  + dc9*ak9[i] ) ;
362 
363  // - Saving 'estimated' derivative at end-point
364  // nextDydx[i] = ak9[i];
365 
366  // Store Input and Final values, for possible use in calculating chord
367  fLastInitialVector[i] = yIn[i] ;
368  fLastFinalVector[i] = yOut[i];
369  fLastDyDx[i] = dydx[i];
370 
371  }
372 
373  fLastStepLength = Step;
374 
375  return ;
376 }
377 
378 
379 //The following has not been tested
380 
381 //The DistChord() function fot the class - must define it here.
383 {
384  G4double distLine, distChord;
385  G4ThreeVector initialPoint, finalPoint, midPoint;
386 
387  // Store last initial and final points (they will be overwritten in self-Stepper call!)
388  initialPoint = G4ThreeVector( fLastInitialVector[0],
390  finalPoint = G4ThreeVector( fLastFinalVector[0],
392 
393  // Do half a step using StepNoErr
394 
397 
398  midPoint = G4ThreeVector( fMidVector[0], fMidVector[1], fMidVector[2]);
399 
400  // Use stored values of Initial and Endpoint + new Midpoint to evaluate
401  // distance of Chord
402 
403 
404  if (initialPoint != finalPoint)
405  {
406  distLine = G4LineSection::Distline( midPoint, initialPoint, finalPoint );
407  distChord = distLine;
408  }
409  else
410  {
411  distChord = (midPoint-initialPoint).mag();
412  }
413  return distChord;
414 }
415 
416 
417 // The following interpolation scheme has been obtained from
418 // Table 5. The RK6(5)9FM process and associated dense formula
419 //---Ref---
420 // J. R. Dormand, M. A. Lockyer, N. E. McGorrigan, and P. J. Prince,
421 // “Global error estimation with runge-kutta triples,”
422 // Computers & Mathematics with Applications, vol. 18, no. 9, pp. 835–846, 1989.
423 //-----------------------------
424 
425 // Fifth order interpolant with one extra function evaluation per step
426 
428  const G4double dydx[],
429  const G4double Step ){
430  const G4int numberOfVariables= this->GetNumberOfVariables();
431 
432  G4double
433  b_101 = 33797.0/460800.0 ,
434  b_102 = 0. ,
435  b_103 = 0. ,
436  b_104 = 27757.0/70785.0 ,
437  b_105 = 7923501.0/26329600.0 ,
438  b_106 = -927.0/3760.0 ,
439  b_107 = -3314760575.0/23165835264.0 ,
440  b_108 = 2479.0/23040.0 ,
441  b_109 = 1.0/64.0 ;
442 
443  for(int i=0;i<numberOfVariables;i++)
444  {
445  yIn[i]=yInput[i];
446  }
447 
448 
449  for(int i=0;i<numberOfVariables;i++)
450  {
451  yTemp[i] = yIn[i] + Step*(b_101*dydx[i] + b_102*ak2[i] + b_103*ak3[i] +
452  b_104*ak4[i] + b_105*ak5[i] + b_106*ak6[i] +
453  b_107*ak7[i] + b_108*ak8[i] + b_109*ak9[i]);
454  }
455  RightHandSide(yTemp, ak10_low); //10th Stage
456 }
457 
459  const G4double dydx[],
460  const G4double Step,
461  G4double yOut[],
462  G4double tau ){
463  {
464 
465  G4double
466  bf1, bf4, bf5, bf6, bf7, bf8, bf9, bf10;
467 
468  G4double tau0 = tau;
469  const G4int numberOfVariables= this->GetNumberOfVariables();
470 
471  for(int i=0;i<numberOfVariables;i++)
472  {
473  yIn[i]=yInput[i];
474  }
475 
476  G4double
477  tau_2 = tau0*tau0 ,
478  tau_3 = tau0*tau_2,
479  tau_4 = tau_2*tau_2;
480 
481  //bf2 = bf3 = 0
482  bf1 = (66480.0*tau_4 - 206243.0*tau_3 + 237786.0*tau_2 - 124793.0*tau + 28800.0)/28800.0 ,
483  bf4 = -16.0*tau*(45312.0*tau_3 - 125933.0*tau_2 + 119706.0*tau -40973.0)/70785.0 ,
484  bf5 = -2187.0*tau*(19440.0*tau_3 - 45743.0*tau_2 + 34786.0*tau - 9293.0)/1645600.0 ,
485  bf6 = tau*(12864.0*tau_3 - 30653.0*tau_2 + 23786.0*tau - 6533.0)/705.0 ,
486  bf7 = -5764801.0*tau*(16464.0*tau_3 - 32797.0*tau_2 + 17574.0*tau - 1927.0)/7239323520.0 ,
487  bf8 = 37.0*tau*(336.0*tau_3 - 661.0*tau_2 + 342.0*tau -31.0)/1440.0 ,
488  bf9 = tau*(tau-1.0)*(16.0*tau_2 - 15.0*tau +3.0)/4.0 ,
489  bf10 = 8.0*tau*(tau - 1.0)*(tau - 1.0)*(2.0*tau - 1.0) ;
490 
491  for( int i=0; i<numberOfVariables; i++){
492  yOut[i] = yIn[i] + Step*tau*( bf1*dydx[i] + bf4*ak4[i] + bf5*ak5[i] +
493  bf6*ak6[i] + bf7*ak7[i] + bf8*ak8[i] +
494  bf9*ak9[i] + bf10*ak10_low[i] ) ;
495  }
496 
497 
498 
499  }
500 
501 }
502 
503 //The following scheme and set of coefficients have been obtained from
504 //Table 2. Sixth order dense formula based on linear optimisation for RK6(5)9FM
505 //with extra stages C1O= 1/2, C11 =1/6, c12= 5/12
506 
507 //---Ref---
508 // T. S. Baker, J. R. Dormand, J. P. Gilmore, and P. J. Prince,
509 // “Continuous approximation with embedded Runge-Kutta methods,”
510 // Applied Numerical Mathematics, vol. 22, no. 1, pp. 51–62, 1996.
511 //--------------------
512 
513 
514 // --- Sixth order interpolant with 3 additional stages per step ---
515 
516 //Function for calculating the additional stages :
518  const G4double dydx[],
519  const G4double Step ){
520 
521  //Coefficients for the additional stages :
522 
523  G4double
524  b101 = 33797.0/460800.0 ,
525  b102 = 0.0 ,
526  b103 = 0.0 ,
527  b104 = 27757.0/70785.0 ,
528  b105 = 7923501.0/26329600.0 ,
529  b106 = -927.0/3760.0 ,
530  b107 = -3314760575.0/23165835264.0 ,
531  b108 = 2479.0/23040.0 ,
532  b109 = 1.0/64.0 ,
533 
534  b111 = 5843.0/76800.0 ,
535  b112 = 0.0 ,
536  b113 = 0.0 ,
537  b114 = 464.0/2673.0 ,
538  b115 = 353997.0/1196800.0 ,
539  b116 = -15068.0/57105.0 ,
540  b117 = -282475249.0/3644974080.0 ,
541  b118 = 8678831.0/156245760.0 ,
542  b119 = 116113.0/11718432.0 ,
543  b1110 = -25.0/243.0 ,
544 
545  b121 = 15088049.0/199065600.0 ,
546  b122 = 0.0 ,
547  b123 = 0.0 ,
548  b124 = 2.0/5.0 ,
549  b125 = 92222037.0/268083200.0 ,
550  b126 = -433420501.0/1528586640.0 ,
551  b127 = -11549242677007.0/83630285291520.0 ,
552  b128 = 2725085557.0/26167173120.0 ,
553  b129 = 235429367.0/16354483200.0 ,
554  b1210 = -90924917.0/1040739840.0 ,
555  b1211 = -271149.0/21414400.0 ;
556 
557 
558  const G4int numberOfVariables= this->GetNumberOfVariables();
559 
560  // Saving yInput because yInput and yOut can be aliases for same array
561  for(int i=0;i<numberOfVariables;i++)
562  {
563  yIn[i]=yInput[i];
564  }
565 
566  yTemp[7] = yIn[7];
567 
568 
569 
570  //Evaluate the extra stages :
571 
572  for(int i=0;i<numberOfVariables;i++)
573  {
574  yTemp[i] = yIn[i] + Step*(b101*dydx[i] + b102*ak2[i] + b103*ak3[i] +
575  b104*ak4[i] + b105*ak5[i] + b106*ak6[i] +
576  b107*ak7[i] + b108*ak8[i] + b109*ak9[i]);
577  }
578  RightHandSide(yTemp, ak10); //10th Stage
579 
580  for(int i=0;i<numberOfVariables;i++)
581  {
582  yTemp[i] = yIn[i] + Step*(b111*dydx[i] + b112*ak2[i] + b113*ak3[i] +
583  b114*ak4[i] + b115*ak5[i] + b116*ak6[i] +
584  b117*ak7[i] + b118*ak8[i] + b119*ak9[i] +
585  b1110*ak10[i]);
586  }
587  RightHandSide(yTemp, ak11); //11th Stage
588 
589  for(int i=0;i<numberOfVariables;i++)
590  {
591  yTemp[i] = yIn[i] + Step*(b121*dydx[i] + b122*ak2[i] + b123*ak3[i] +
592  b124*ak4[i] + b125*ak5[i] + b126*ak6[i] +
593  b127*ak7[i] + b128*ak8[i] + b129*ak9[i] +
594  b1210*ak10[i] + b1211*ak11[i]);
595  }
596  RightHandSide(yTemp, ak12); //12th Stage
597 
598 }
599 
600 
601 
602 //Function to interpolate to tau(passed in) fraction of the step
604  const G4double dydx[],
605  const G4double Step,
606  G4double yOut[],
607  G4double tau )
608 {
609 
610  //Define the coefficients for the polynomials
611  G4double bi[13][6], b[13];
612  G4int numberOfVariables = this->GetNumberOfVariables();
613 
614 
615  // COEFFICIENTS OF bi[ 1]
616  bi[1][0] = 1.0 ,
617  bi[1][1] = -18487.0/2880.0 ,
618  bi[1][2] = 139189.0/7200.0 ,
619  bi[1][3] = -53923.0/1800.0 ,
620  bi[1][4] = 13811.0/600,
621  bi[1][5] = -2071.0/300,
622  // --------------------------------------------------------
623  //
624  // COEFFICIENTS OF bi[2]
625  bi[2][0] = 0.0 ,
626  bi[2][1] = 0.0 ,
627  bi[2][2] = 0.0 ,
628  bi[2][3] = 0.0 ,
629  bi[2][4] = 0.0 ,
630  bi[2][5] = 0.0 ,
631  // --------------------------------------------------------
632  //
633  // COEFFICIENTS OF bi[3]
634  bi[3][0] = 0.0 ,
635  bi[3][1] = 0.0 ,
636  bi[3][2] = 0.0 ,
637  bi[3][3] = 0.0 ,
638  bi[3][4] = 0.0 ,
639  bi[3][5] = 0.0 ,
640  // --------------------------------------------------------
641  //
642  // COEFFICIENTS OF bi[4]
643  bi[4][0] = 0.0 ,
644  bi[4][1] = -30208.0/14157.0 ,
645  bi[4][2] = 1147904.0/70785.0 ,
646  bi[4][3] = -241664.0/5445.0 ,
647  bi[4][4] = 241664.0/4719.0 ,
648  bi[4][5] = -483328.0/23595.0 ,
649  // --------------------------------------------------------
650  //
651  // COEFFICIENTS OF bi[5]
652  bi[5][0] = 0.0 ,
653  bi[5][1] = -177147.0/32912.0 ,
654  bi[5][2] = 3365793.0/82280.0 ,
655  bi[5][3] = -2302911.0/20570.0 ,
656  bi[5][4] = 531441.0/4114.0 ,
657  bi[5][5] = -531441.0/10285.0 ,
658  // --------------------------------------------------------
659  //
660  // COEFFICIENTS OF bi[6]
661  bi[6][0] = 0.0 ,
662  bi[6][1] = 536.0/141.0 ,
663  bi[6][2] = -20368.0/705.0 ,
664  bi[6][3] = 55744.0/705.0 ,
665  bi[6][4] = -4288.0/47.0 ,
666  bi[6][5] = 8576.0/235,
667  // --------------------------------------------------------
668  //
669  // COEFFICIENTS OF bi[7]
670  bi[7][0] = 0.0 ,
671  bi[7][1] = -1977326743.0/723932352.0 ,
672  bi[7][2] = 37569208117.0/1809830880.0 ,
673  bi[7][3] = -1977326743.0/34804440.0 ,
674  bi[7][4] = 1977326743.0/30163848.0 ,
675  bi[7][5] = -1977326743.0/75409620.0 ,
676  // --------------------------------------------------------
677  //
678  // COEFFICIENTS OF bi[8]
679  bi[8][0] = 0.0 ,
680  bi[8][1] = 259.0/144.0 ,
681  bi[8][2] = -4921.0/360.0 ,
682  bi[8][3] = 3367.0/90.0 ,
683  bi[8][4] = -259.0/6.0 ,
684  bi[8][5] = 259.0/15.0 ,
685  // --------------------------------------------------------
686  //
687  // COEFFICIENTS OF bi[9]
688  bi[9][0] = 0.0 ,
689  bi[9][1] = 62.0/105.0 ,
690  bi[9][2] = -2381.0/525.0 ,
691  bi[9][3] = 949.0/75.0 ,
692  bi[9][4] = -2636.0/175.0 ,
693  bi[9][5] = 1112.0/175.0 ,
694  // --------------------------------------------------------
695  //
696  // COEFFICIENTS OF bi[10]
697  bi[10][0] = 0.0 ,
698  bi[10][1] = 43.0/3.0 ,
699  bi[10][2] = -1534.0/15.0 ,
700  bi[10][3] = 3767.0/15.0 ,
701  bi[10][4] = -1264.0/5.0 ,
702  bi[10][5] = 448.0/5.0 ,
703  // --------------------------------------------------------
704  //
705  // COEFFICIENTS OF bi[11]
706  bi[11][0] = 0.0 ,
707  bi[11][1] = 63.0/5.0 ,
708  bi[11][2] = -1494.0/25.0 ,
709  bi[11][3] = 2907.0/25.0 ,
710  bi[11][4] = -2592.0/25.0 ,
711  bi[11][5] = 864.0/25.0 ,
712  // --------------------------------------------------------
713  //
714  // COEFFICIENTS OF bi[12]
715  bi[12][0] = 0.0 ,
716  bi[12][1] = -576.0/35.0 ,
717  bi[12][2] = 19584.0/175.0 ,
718  bi[12][3] = -6336.0/25.0 ,
719  bi[12][4] = 41472.0/175.0 ,
720  bi[12][5] = -13824.0/175.0 ;
721  // --------------------------------------------------------
722 
723 
724  for(G4int i = 0; i< numberOfVariables; i++)
725  yIn[i] = yInput[i];
726 
727  G4double tau0 = tau;
728  // Calculating the polynomials (coefficents for the respective stages) :
729 
730  for(int i=1; i<=12; i++){ //Here i is NOT the coordinate no. , it's stage no.
731  b[i] = 0;
732  tau = 1.0;
733  for(int j=0; j<=5; j++){
734  b[i] += bi[i][j]*tau;
735  tau*=tau0;
736  }
737  }
738 
739 // Calculating the interpolation at the fraction tau of the step using the polynomial
740 // coefficients and the respective stages
741 
742  for(int i=0; i<numberOfVariables; i++){ //Here i IS the cooridnate no.
743  yOut[i] = yIn[i] + Step*tau0*(b[1]*dydx[i] + b[2]*ak2[i] + b[3]*ak3[i] +
744  b[4]*ak4[i] + b[5]*ak5[i] + b[6]*ak6[i] +
745  b[7]*ak7[i] + b[8]*ak8[i] + b[9]*ak9[i] +
746  b[10]*ak10[i] + b[11]*ak11[i] + b[12]*ak12[i]);
747  }
748 }
749 
750 //-----Verified--------- - hackabot
G4DormandPrinceRK56(G4EquationOfMotion *EqRhs, G4int numberOfVariables=6, G4bool primary=true)
void SetupInterpolate_high(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
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
void Interpolate_low(const G4double yInput[], const G4double dydx[], const G4double Step, G4double yOut[], G4double tau)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
TCanvas * c2
Definition: plot_hist.C:75
void RightHandSide(const double y[], double dydx[]) const
void Interpolate_high(const G4double yInput[], const G4double dydx[], const G4double Step, G4double yOut[], G4double tau)
void Stepper(const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])
int G4int
Definition: G4Types.hh:78
void SetupInterpolate_low(const G4double yInput[], const G4double dydx[], const G4double Step)
G4int GetNumberOfVariables() const
G4double DistChord() const
Definition: Step.hh:41
G4DormandPrinceRK56 * fAuxStepper