bs_step.f 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. c*************************************************************************
  2. c BS_STEP.F
  3. c*************************************************************************
  4. c This subroutine has same i/o as STEP_KDK but here we use a BS
  5. c Steps both massive and test particles in the same subroutine.
  6. c
  7. c Input:
  8. c i1st ==> = 0 if first step; = 1 not (int scalar)
  9. c time ==> current time (real scalar)
  10. c nbod ==> number of massive bodies (int scalar)
  11. c ntp ==> number of massive bodies (int scalar)
  12. c mass ==> mass of bodies (real array)
  13. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  14. c (real scalars)
  15. c xh,yh,zh ==> initial position in helio coord
  16. c (real arrays)
  17. c vxh,vyh,vzh ==> initial velocity in helio coord
  18. c (real arrays)
  19. c xht,yht,zht ==> initial part position in helio coord
  20. c (real arrays)
  21. c vxht,vyht,vzht ==> initial velocity in helio coord
  22. c (real arrays)
  23. c istat ==> status of the test paricles
  24. c (2d integer array)
  25. c istat(i,1) = 0 ==> active: = 1 not
  26. c istat(i,2) = -1 ==> Danby did not work
  27. c rstat ==> status of the test paricles
  28. c (2d real array)
  29. c dt ==> time step
  30. c Output:
  31. c xh,yh,zh ==> final position in helio coord
  32. c (real arrays)
  33. c vxh,vyh,vzh ==> final velocity in helio coord
  34. c (real arrays)
  35. c xht,yht,zht ==> final position in helio coord
  36. c (real arrays)
  37. c vxht,vyht,vzht ==> final position in helio coord
  38. c (real arrays)
  39. c
  40. c
  41. c Remarks:
  42. c Authors: Hal Levison
  43. c Date: 5/17/93
  44. c Last revision: 2/24/94
  45. subroutine bs_step(i1st,time,nbod,ntp,mass,j2rp2,j4rp4,
  46. & xh,yh,zh,vxh,vyh,vzh,xht,yht,zht,vxht,vyht,vzht,
  47. & istat,rstat,dt)
  48. include '../swift.inc'
  49. include 'bs.inc'
  50. c... Inputs Only:
  51. integer nbod,ntp,i1st
  52. real*8 mass(nbod),dt,time,j2rp2,j4rp4
  53. c... Inputs and Outputs:
  54. integer istat(NTPMAX,NSTAT)
  55. real*8 rstat(NTPMAX,NSTATR)
  56. real*8 xh(nbod),yh(nbod),zh(nbod)
  57. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  58. real*8 xht(ntp),yht(ntp),zht(ntp)
  59. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  60. c... Internals
  61. integer j,i,ntpi,link(NTPMAX)
  62. integer istattmp(NTPMAX,NSTAT),jj,i1stin
  63. real*8 xb(NPLMAX),yb(NPLMAX),zb(NPLMAX),eps
  64. real*8 vxb(NPLMAX),vyb(NPLMAX),vzb(NPLMAX)
  65. real*8 xbt(NTPMAX),ybt(NTPMAX),zbt(NTPMAX)
  66. real*8 vxbt(NTPMAX),vybt(NTPMAX),vzbt(NTPMAX)
  67. real*8 ybs(6,(NTPMAX+NPLMAX)),tfake,dttmp,msys
  68. data i1stin/0/
  69. save i1stin,eps
  70. c----
  71. c... Executable code
  72. c... set things up if this is the initial call
  73. if(i1stin.eq.0) then
  74. write(*,*) 'Enter the value for eps : '
  75. read(*,*) eps
  76. write(*,*) ' eps = ',eps
  77. write(*,*) ' CONTINUE: '
  78. i1stin = 1
  79. endif
  80. c... Convert to barycentric coords
  81. call coord_h2b(nbod,mass,xh,yh,zh,vxh,vyh,vzh,
  82. & xb,yb,zb,vxb,vyb,vzb,msys)
  83. call coord_h2b_tp(ntp,xht,yht,zht,vxht,vyht,vzht,
  84. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  85. & xbt,ybt,zbt,vxbt,vybt,vzbt)
  86. c... copy to the big array
  87. do i=1,nbod
  88. ybs(1,i) = xb(i)
  89. ybs(2,i) = yb(i)
  90. ybs(3,i) = zb(i)
  91. ybs(4,i) = vxb(i)
  92. ybs(5,i) = vyb(i)
  93. ybs(6,i) = vzb(i)
  94. enddo
  95. ntpi = 0
  96. do i=1,ntp
  97. if(istat(i,1).eq.0) then
  98. ntpi = ntpi + 1
  99. j = ntpi + nbod
  100. link(ntpi) = i
  101. ybs(1,j) = xbt(i)
  102. ybs(2,j) = ybt(i)
  103. ybs(3,j) = zbt(i)
  104. ybs(4,j) = vxbt(i)
  105. ybs(5,j) = vybt(i)
  106. ybs(6,j) = vzbt(i)
  107. do jj = 1,NSTAT
  108. istattmp(ntpi,jj) = istat(i,jj)
  109. enddo
  110. endif
  111. enddo
  112. tfake = 0.0d0
  113. dttmp = dt
  114. c do while(tfake.lt.dt)
  115. do while( (abs(tfake-dt)/dt) .gt. 1.0e-7 ) ! just to be real safe
  116. call bs_int(nbod,ntpi,mass,j2rp2,j4rp4,istattmp,
  117. & tfake,dttmp,ybs,eps)
  118. dttmp = dt - tfake
  119. enddo
  120. c... put things back
  121. do i=1,nbod
  122. xb(i) = ybs(1,i)
  123. yb(i) = ybs(2,i)
  124. zb(i) = ybs(3,i)
  125. vxb(i) = ybs(4,i)
  126. vyb(i) = ybs(5,i)
  127. vzb(i) = ybs(6,i)
  128. enddo
  129. do i=1,ntpi
  130. j = i + nbod
  131. xbt(link(i)) = ybs(1,j)
  132. ybt(link(i)) = ybs(2,j)
  133. zbt(link(i)) = ybs(3,j)
  134. vxbt(link(i)) = ybs(4,j)
  135. vybt(link(i)) = ybs(5,j)
  136. vzbt(link(i)) = ybs(6,j)
  137. do jj = 1,NSTAT
  138. istat(link(i),jj) = istattmp(i,jj)
  139. enddo
  140. enddo
  141. c... Convert back to helio. coords at the end of the step
  142. call coord_b2h(nbod,mass,xb,yb,zb,vxb,vyb,vzb,
  143. & xh,yh,zh,vxh,vyh,vzh)
  144. call coord_b2h_tp(ntp,xbt,ybt,zbt,vxbt,vybt,vzbt,
  145. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  146. & xht,yht,zht,vxht,vyht,vzht)
  147. return
  148. end ! bs_step
  149. c------------------------------------------------------------------------