tu4_step.f 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. c*************************************************************************
  2. c TU4_STEP.F
  3. c*************************************************************************
  4. c This subroutine has same i/o as STEP_KDK but here we use a 4th
  5. c order T + U decomposition of the Hamiltonian like the old symplectic
  6. c method (4th order) used by Gladman and Duncan.
  7. c Steps both massive and test particles in the same subroutine.
  8. c
  9. c Input:
  10. c i1st ==> = 0 if first step; = 1 not (int scalar)
  11. c time ==> current time (real scalar)
  12. c nbod ==> number of massive bodies (int scalar)
  13. c ntp ==> number of massive bodies (int scalar)
  14. c mass ==> mass of bodies (real array)
  15. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  16. c (real scalars)
  17. c xh,yh,zh ==> initial position in helio coord
  18. c (real arrays)
  19. c vxh,vyh,vzh ==> initial velocity in helio coord
  20. c (real arrays)
  21. c xht,yht,zht ==> initial part position in helio coord
  22. c (real arrays)
  23. c vxht,vyht,vzht ==> initial velocity in helio coord
  24. c (real arrays)
  25. c istat ==> status of the test paricles
  26. c (2d integer array)
  27. c istat(i,1) = 0 ==> active: = 1 not
  28. c istat(i,2) = -1 ==> Danby did not work
  29. c rstat ==> status of the test paricles
  30. c (2d real array)
  31. c dt ==> time step
  32. c Output:
  33. c xh,yh,zh ==> final position in helio coord
  34. c (real arrays)
  35. c vxh,vyh,vzh ==> final velocity in helio coord
  36. c (real arrays)
  37. c xht,yht,zht ==> final position in helio coord
  38. c (real arrays)
  39. c vxht,vyht,vzht ==> final position in helio coord
  40. c (real arrays)
  41. c
  42. c
  43. c Remarks: Based on Martin's NB4M routines and Hal's STEP_KDK
  44. c Authors: Martin Duncan
  45. c Date: 3/8/93
  46. c Last revision: 2/24/94
  47. subroutine tu4_step(i1st,time,nbod,ntp,mass,j2rp2,j4rp4,
  48. & xh,yh,zh,vxh,vyh,vzh,xht,yht,zht,vxht,vyht,vzht,
  49. & istat,rstat,dt)
  50. include '../swift.inc'
  51. c... Inputs Only:
  52. integer nbod,ntp,i1st
  53. real*8 mass(nbod),dt,time,j2rp2,j4rp4
  54. c... Inputs and Outputs:
  55. integer istat(NTPMAX,NSTAT)
  56. real*8 rstat(NTPMAX,NSTATR)
  57. real*8 xh(nbod),yh(nbod),zh(nbod)
  58. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  59. real*8 xht(ntp),yht(ntp),zht(ntp)
  60. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  61. c... Internals
  62. integer j
  63. real*8 xb(NPLMAX),yb(NPLMAX),zb(NPLMAX)
  64. real*8 vxb(NPLMAX),vyb(NPLMAX),vzb(NPLMAX)
  65. real*8 axb(NPLMAX),ayb(NPLMAX),azb(NPLMAX)
  66. real*8 xbt(NTPMAX),ybt(NTPMAX),zbt(NTPMAX)
  67. real*8 vxbt(NTPMAX),vybt(NTPMAX),vzbt(NTPMAX)
  68. real*8 axbt(NTPMAX),aybt(NTPMAX),azbt(NTPMAX)
  69. real*8 msys
  70. real*8 w0,w1,asymp(4),bsymp(4),adt,bdt
  71. save asymp,bsymp
  72. c----
  73. c... Executable code
  74. c If first time, load up the symplectic coeffs asymp(*) and bsymp(*)
  75. if (i1st .eq.0) then
  76. w1= 1.d0/(2.d0 -(2.d0**(1.d0/3.d0)))
  77. w0= 1.d0 - 2.d0*(w1)
  78. asymp(1) = 0.5*w1
  79. asymp(4) = asymp(1)
  80. asymp(2) = 0.5*(w0 + w1)
  81. asymp(3) = asymp(2)
  82. bsymp(1) = 0.0d0
  83. bsymp(2) = w1
  84. bsymp(3) = w0
  85. bsymp(4) = w1
  86. i1st = 1
  87. endif
  88. c... Convert to barycentric coords
  89. call coord_h2b(nbod,mass,xh,yh,zh,vxh,vyh,vzh,
  90. & xb,yb,zb,vxb,vyb,vzb,msys)
  91. call coord_h2b_tp(ntp,xht,yht,zht,vxht,vyht,vzht,
  92. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  93. & xbt,ybt,zbt,vxbt,vybt,vzbt)
  94. c Take a drift forward to begin the leapfrog (the first kick = 0).
  95. adt = asymp(1)*dt
  96. call tu4_ldrift(nbod,xb,yb,zb,vxb,vyb,vzb,adt)
  97. call tu4_ldrift_tp(ntp,xbt,ybt,zbt,vxbt,vybt,vzbt,
  98. & adt,istat)
  99. c Get the accelerations, kick and drift three times
  100. do j=2,4
  101. call tu4_getaccb(nbod,mass,j2rp2,j4rp4,xb,yb,zb,axb,ayb,azb)
  102. call tu4_getaccb_tp(nbod,mass,j2rp2,j4rp4,xb,yb,zb,
  103. & ntp,xbt,ybt,zbt,istat,axbt,aybt,azbt)
  104. bdt = bsymp(j)*dt
  105. call tu4_vkickb(nbod,vxb,vyb,vzb,axb,ayb,azb,bdt)
  106. call tu4_vkickb_tp(ntp,vxbt,vybt,vzbt,axbt,aybt,
  107. & azbt,bdt,istat)
  108. adt = asymp(j)*dt
  109. call tu4_ldrift(nbod,xb,yb,zb,vxb,vyb,vzb,adt)
  110. call tu4_ldrift_tp(ntp,xbt,ybt,zbt,vxbt,vybt,
  111. & vzbt,adt,istat)
  112. enddo
  113. c... Convert back to helio. coords at the end of the step
  114. call coord_b2h(nbod,mass,xb,yb,zb,vxb,vyb,vzb,
  115. & xh,yh,zh,vxh,vyh,vzh)
  116. call coord_b2h_tp(ntp,xbt,ybt,zbt,vxbt,vybt,vzbt,
  117. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  118. & xht,yht,zht,vxht,vyht,vzht)
  119. return
  120. end ! step_tu4
  121. c------------------------------------------------------------------------