11 subroutine cbdefbyrk(aTrack, leng, newpos, newdir,newmom)
22 real(8),
intent(out):: newmom(3)
24 common /zgeomcnst/ geomcnst
37 integer first, nde, ierr
38 real*8 relaerr, abserr, h
39 real*8 esterr(6), yn(6), y10(6), y1n(6), err(6), y0(6)
45 data first/1/, relaerr/1.
d-2/, abserr/1.
d3/
53 y0(1) = atrack%pos%xyz%r(1)
54 y0(2) = atrack%pos%xyz%r(2)
55 y0(3) = atrack%pos%xyz%r(3)
60 y0(4:6) = atrack%vec%w%r(1:3)
63 geomcnst = max(sqrt(atrack%p%fm%p(4)**2- atrack%p%mass**2), 1.
d-9)
65 geomcnst = atrack%p%charge/geomcnst/3.3358
69 * abserr, yn, esterr, nde, ierr, h, y10, y1n, err, work)
70 if(ierr .eq. 40000 )
then 71 call cbdefbyrk2(atrack, leng, newpos, newdir, newmom)
72 elseif(ierr .ne. 0)
then 73 write(0,*)
' ierr=',ierr
74 call cbdefbyrk2(atrack, leng, newpos, newdir, newmom)
98 * sqrt(dot_product( atrack%p%fm%p(1:3),atrack%p%fm%p(1:3)))
108 #include "Zmagfield.h" 113 common /zgeomcnst/ geomcnst
135 call cgeomag(yearofgeomag, llh, b, icon)
137 f(4)= geomcnst * (y(5)*b%z - y(6)*b%y)
138 f(5) =geomcnst * (y(6)*b%x - y(4)*b%z)
139 f(6) =geomcnst * (y(4)*b%y - y(5)*b%x)
143 subroutine krungekutfds(neq,func,x0,xe,y0,init,relerr,abserr,
144 & yn,esterr,nde,ier,h,yl0,yln,err,work)
202 implicit real*8(
a-
h,
o-
z)
204 dimension y0(neq),yn(neq),esterr(neq),work(neq,12),
205 & yl0(neq),yln(neq),err(neq)
209 & yn,esterr,nde,ier,
h, yl0, yln, err,
210 & work(1,1),work(1,2),work(1,3),work(1,4),work(1,5),
211 & work(1,6),work(1,7),work(1,8))
215 subroutine krungekutfs(neq,func,x0,xe,yh0,init,relerr,abserr,
216 & yhn,esterr,nde,ier,h,yl0,yln,err,
217 & ak1,ak2,ak3,ak4,ak5,ak6,et,work)
220 & c3 = -0.036571
d+0, c4 = 0.023107
d+0,
221 & c5 = -9.515
d-3, c6 = 3.017
d-3 )
223 dimension yh0(neq),yhn(neq),yl0(neq),yln(neq),esterr(neq),
224 & ak1(neq),ak2(neq),ak3(neq),ak4(neq),ak5(neq),ak6(neq),
225 & err(neq),et(neq),work(neq,5)
226 data itemax / 100000 /
227 data epsmin / 1.0
d-15 /
229 if (
init .eq. 1)
then 236 call func(x0,yl0,ak1)
239 if (ak1(
i) .ne. 0.0
d+0)
then 240 tol = relerr * dabs(yl0(
i)) + abserr
241 toldy = min(toldy, tol / dabs(ak1(
i)))
244 hmin = epsmin * (xe - x0)
245 if (toldy .eq. 10.0
d+74)
then 248 h = min((xe - x0) / 100.0
d+0, toldy ** 0.2
d+0)
263 do 30 iter = 1,itemax
264 call krkflstep(neq,func,
x,
h,yl0,yln,ak1,ak2,ak3,ak4,ak5,
269 et(
i) = relerr * 0.5
d+0 * (dabs(yl0(
i)) + dabs(yln(
i))) + abserr
270 if (et(
i) .eq. 0.0
d+0)
then 273 erret = max(erret, dabs(err(
i)) / et(
i))
276 if (erret .ge. 1.0
d+0)
then 278 if (erret .ge. 59049.0
d+0)
then 281 h = 0.9
d+0 *
h / (erret ** 0.2
d+0)
283 if (
h .le. epsmin)
go to 30000
284 else if ((
x +
h) .lt. xe)
then 290 erri =
h * (c1 * ak1(
i) + c2 * ak2(
i) + c3 * ak3(
i)
291 & + c4 * ak4(
i) + c5 * ak5(
i) + c6 * ak6(
i))
292 erretl = max(erretl, dabs(erri) / et(
i))
294 if (erretl .le. 1.0
d+0) istiff = istiff + 1
295 if (icount .eq. 50)
then 296 if (istiff .ge. 25)
then 306 call krkfhstep(neq,func,
x,
h,yh0,yhn,ak1,ak2,ak3,ak4,ak5,
318 if (erret .le. 1.889568
d-4)
then 321 h = 0.9
d+0 *
h / (erret ** 0.2
d+0)
327 call krkflstep(neq,func,
x,
h,yl0,yln,ak1,ak2,ak3,ak4,ak5,
329 call krkfhstep(neq,func,
x,
h,yh0,yhn,ak1,ak2,ak3,ak4,ak5,
335 esterr(
i) = (yln(
i) - yhn(
i)) / 31.0
d+0
350 10001
format(
' ',
'(subr.-rkfds) trouble(too many iterations))',
356 20001
format(
' ',
'(subr.-rkfds) trouble(inappropriate error tolerance)' 357 & ,
' at x = ',1pe15.7)
362 30001
format(
' ',
'(subr.-rkfds) trouble(too small step size)',
363 &
' at x = ',1pe15.7)
367 write( 0 , * )
'the equations are stiff!' 369 40001
format(
' ',
'stiffness was detected at x = ',1pe15.7,
'.')
370 write( 0 , * )
'to use the subroutine (krsnat or krsat)' 375 subroutine krkflstep(neq,func,x,h,y0,yn,ak1,ak2,ak3,ak4,ak5,ak6,
379 dimension y0(neq),yn(neq),ak1(neq),ak2(neq),ak3(neq),ak4(neq),
380 & ak5(neq),ak6(neq),err(neq),work(neq,5)
382 call krkfehl(lindex,neq,func,
x,
h,y0,yn,ak1,ak2,ak3,ak4,ak5,ak6,
383 & err,work(1,1),work(1,2),work(1,3),work(1,4),work(1,5))
388 subroutine krkfhstep(neq,func,x,h,y0,yn,ak1,ak2,ak3,ak4,ak5,ak6,
392 dimension y0(neq),yn(neq),ak1(neq),ak2(neq),ak3(neq),ak4(neq),
393 & ak5(neq),ak6(neq),err(neq),work(neq,5)
398 call krkfehl(lindex,neq,func,
x1,h1,y0,yn,ak1,ak2,ak3,ak4,ak5,ak6,
399 & err,work(1,1),work(1,2),work(1,3),work(1,4),work(1,5))
404 call krkfehl(lindex,neq,func,
x1,h1,y0,yn,ak1,ak2,ak3,ak4,ak5,ak6,
405 & err,work(1,1),work(1,2),work(1,3),work(1,4),work(1,5))
409 subroutine krkfehl(lindex,neq,func,x,h,y0,yn,ak1,ak2,ak3,ak4,ak5,
410 & ak6,err,w2,w3,w4,w5,w6)
412 dimension y0(neq),yn(neq),ak1(neq),ak2(neq),ak3(neq),ak4(neq),
413 & ak5(neq),ak6(neq),err(neq),w2(neq),w3(neq),w4(neq),
415 parameter(one = 1, two = 2, thr = 3, twl = 12)
416 parameter(al2 = one / 4, al3 = thr / 8, al4 = twl / 13,
417 & al5 = one, al6 = one / 2)
418 parameter(b21 = one / 4, b31 = thr / 32, b32 = 9.0
d+0 / 32,
419 & b41 = 1932.0
d+0 / 2197, b42 = -7200.0
d+0 / 2197,
420 & b43 = 7296.0
d+0 / 2197, b51 = 439.0
d+0 / 216,
421 & b52 = -8, b53 = 3680.0
d+0 / 513,
422 & b54 = -845.0
d+0 / 4104, b61 = -8.0
d+0 / 27,
423 & b62 = 2, b63 = -3544.0
d+0 / 2565,
424 & b64 = 1859.0
d+0 / 4104, b65 = -11.0
d+0 / 40)
425 parameter(ga1 = 16.0
d+0 / 135, ga3 = 6656.0
d+0 / 12825,
426 & ga4 = 28561.0
d+0 / 56430,
427 & ga5 = -9.0
d+0 / 50, ga6 = two / 55)
428 parameter(da1 = one / 360, da3 = -128.0
d+0 / 4275,
429 & da4 = -2197.0
d+0 / 75240,
430 & da5 = one / 50, da6 = two / 55)
434 w2(
i) = y0(
i) +
h * b21 * ak1(
i)
436 call func(
x + al2 *
h,w2,ak2)
438 w3(
i) = y0(
i) +
h * (b31 * ak1(
i) + b32 * ak2(
i))
440 call func(
x + al3 *
h,w3,ak3)
442 w4(
i) = y0(
i) +
h * (b41 * ak1(
i) + b42 * ak2(
i) + b43 * ak3(
i))
445 call func(
x + al4 *
h,w4,ak4)
447 w5(
i) = y0(
i) +
h * (b51 * ak1(
i) + b52 * ak2(
i)
448 & + b53 * ak3(
i) + b54 * ak4(
i))
451 call func(
x + al5 *
h,w5,ak5)
453 w6(
i) = y0(
i) +
h * (b61 * ak1(
i) + b62 * ak2(
i) + b63 * ak3(
i)
454 & + b64 * ak4(
i) + b65 * ak5(
i))
456 call func(
x + al6 *
h,w6,ak6)
458 yn(
i) = y0(
i) +
h * (ga1 * ak1(
i) + ga3 * ak3(
i) + ga4 * ak4(
i)
459 & + ga5 * ak5(
i) + ga6 * ak6(
i))
461 if (lindex .eq. 1)
then 463 err(
i) =
h * (da1 * ak1(
i) + da3 * ak3(
i) + da4 * ak4(
i)
464 & + da5 * ak5(
i) + da6 * ak6(
i))
472 subroutine cbdefbyrk2(aTrack, leng, newpos, newdir, newmom)
481 real(8),
intent(out):: newmom(3)
483 common /zgeomcnst/ geomcnst
503 real*8 wk(6,4), y(6,m)
513 y0(1:3) = atrack%pos%xyz%r(1:3)
518 y0(4:6) = atrack%vec%w%r(1:3)
521 geomcnst = max(sqrt(atrack%p%fm%p(4)**2- atrack%p%mass**2), 1.
d-9)
523 geomcnst = atrack%p%charge/geomcnst/3.3358
528 write(0,*)
' ier=',ier
547 newmom(:) = y(4:6,m)*
548 * sqrt( dot_product(atrack%p%fm%p(1:3),atrack%p%fm%p(1:3)) )
553 subroutine krungekutg(func, n, x0, y0, m, h, ny, y, wk, ierr)
575 real*8 zero, half, two, three, const, six
581 * half/0.5
d0/, two/2.0
d0/, three/3.0
d0/, six/6.0
d0/
582 data const/ 0.29289321881345247560
d0 /
588 if(n .le. 0 .or. n .gt. ny .or. m .le. 1)
then 599 call func(x, wk(1,2), wk(1,4))
605 wk(k,1)=wk(k,1)+three*t3-half*t2
608 call func(x+half*h, wk(1,3), wk(1,4))
611 t3=const*(t2-wk(k,1))
614 wk(k,1)=wk(k,1)+three*t3-const*t2
617 call func(x+half*h, wk(1,2), wk(1,4))
621 t3=(two-const)*(t2-wk(k,1))
624 wk(k,1)=wk(k,1)+three*t3-(two-const)*t2
627 call func(x+h, wk(1,3), wk(1,4))
630 t3=(t2-two*wk(k,1))/six
634 wk(k,1)=wk(k,1)+three*t3-half*t2
640 subroutine cbdefuser(aTrack, leng, newpos, newdir,newmom )
653 common /zgeomcnst/ geomcnst
656 real(8),
intent(out):: newmom
684 geomcnst = max(sqrt(atrack%p%fm%p(4)**2- atrack%p%mass**2), 1.
d-9)
685 geomcnst = atrack%p%charge/geomcnst/3.3358
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine cgeomfunc(L, y, f)
block data include Zlatfit h c fitting region data x1(1)/0.03/
block data cblkIncident data *Za1ry *HeightOfInj d3
subroutine cbdefuser(aTrack, leng, newpos, newdir, newmom)
subroutine cgeomag(yearin, llh, h, icon)
subroutine krkfehl(lindex, neq, func, x, h, y0, yn, ak1, ak2, ak3, ak4, ak5, ak6, err, w2, w3, w4, w5, w6)
subroutine krungekutg(func, n, x0, y0, m, h, ny, y, wk, ierr)
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
dE dx *! Nuc Int sampling table d
subroutine cbdefbyrk(aTrack, leng, newpos, newdir, newmom)
Compute magnetic deflection (angle and displacement) Use Runge-Kutta-Fehlberg Method.
subroutine cbdefbyrk2(aTrack, leng, newpos, newdir, newmom)
dE dx *! Nuc Int sampling table h
subroutine ctransmagto(sys, pos, a, b)
subroutine krkfhstep(neq, func, x, h, y0, yn, ak1, ak2, ak3, ak4, ak5, ak6, err, work)
subroutine krungekutfds(neq, func, x0, xe, y0, init, relerr, abserr, yn, esterr, nde, ier, h, yl0, yln, err, work)
subroutine krungekutfs(neq, func, x0, xe, yh0, init, relerr, abserr, yhn, esterr, nde, ier, h, yl0, yln, err, ak1, ak2, ak3, ak4, ak5, ak6, et, work)
subroutine krkflstep(neq, func, x, h, y0, yn, ak1, ak2, ak3, ak4, ak5, ak6, err, work)
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x