rmvs_step_in.f 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. c*************************************************************************
  2. c RMVS_STEP_IN.F
  3. c*************************************************************************
  4. c This subroutine takes a full dt step in helio coord for test particles
  5. c in the inner region of an encounter.
  6. c
  7. c Input:
  8. c i1st ==> = 0 if first step; = 1 not (int scalar)
  9. c nbod ==> number of massive bodies (int scalar)
  10. c ntp ==> number of test bodies (int scalar)
  11. c mass ==> mass of bodies (real array)
  12. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  13. c (real scalars)
  14. c xpl,ypl,zpl ==> position of planet wrt time
  15. c (2d real arrays)
  16. c xbeg,ybeg,zbeg ==> position of planet @ beginning of dt
  17. c (real arrays)
  18. c vxbeg,vybeg,vzbeg ==> vel of planet @ beginning of dt
  19. c (2d real arrays)
  20. c xend,yend,zend ==> position of planet @ end of dt
  21. c (2d real arrays)
  22. c vxend,vyend,vzend ==> vel of planet @ end of dt
  23. c (2d real arrays)
  24. c xht,yht,zht ==> initial tp position in helio coord
  25. c (real arrays)
  26. c vxht,vyht,vzht ==> initial tp velocity in helio coord
  27. c (real arrays)
  28. c istat ==> status of the test paricles
  29. c (2d integer array)
  30. c istat(i,1) = 0 ==> active: = 1 not
  31. c istat(i,2) = -1 ==> Danby did not work
  32. c nenci ==> nenci(i) is the number of tp enc planet i
  33. c in inner region (integer array)
  34. c itpenci ==> itpenci(*,i) is a list of tp enc planet i
  35. c in inner region (2d integer array)
  36. c dt ==> time step (real sclar)
  37. c Output:
  38. c xht,yht,zht ==> final tp position in helio coord
  39. c (real arrays)
  40. c vxht,vyht,vzht ==> final tp position in helio coord
  41. c (real arrays)
  42. c NOTE: only the tp in the inner region
  43. c will have their x and v's changed
  44. c isperi ==> = 0 if tp went through peri
  45. c =-1 if tp pre peri
  46. c = 1 if tp post peri
  47. c (integer array)
  48. c peri ==> set to pericenter dist. if isperi=0
  49. c (real array)
  50. c
  51. c
  52. c Remarks: Adopted from hal's wiscl_fk.f
  53. c Authors: Hal Levison
  54. c Date: 2/19/93
  55. c Last revision: 1/6/96
  56. subroutine rmvs_step_in(i1st,nbod,ntp,mass,j2rp2,j4rp4,
  57. & xpl,ypl,zpl,xbeg,ybeg,zbeg,vxbeg,vybeg,vzbeg,
  58. & xend,yend,zend,vxend,vyend,vzend,xht,yht,zht,
  59. & vxht,vyht,vzht,istat,nenci,itpenci,isperi,peri,dt)
  60. include '../swift.inc'
  61. include 'rmvs.inc'
  62. c... Inputs Only:
  63. integer nbod,ntp,i1st
  64. real*8 mass(nbod),dt,j2rp2,j4rp4
  65. real*8 xpl(NPLMAX,NTPENC),ypl(NPLMAX,NTPENC)
  66. real*8 zpl(NPLMAX,NTPENC)
  67. Integer nenci(NPLMAX),itpenci(NTPMAX,NPLMAX)
  68. real*8 xbeg(NPLMAX),ybeg(NPLMAX),zbeg(NPLMAX)
  69. real*8 vxbeg(NPLMAX),vybeg(NPLMAX),vzbeg(NPLMAX)
  70. real*8 xend(NPLMAX),yend(NPLMAX),zend(NPLMAX)
  71. real*8 vxend(NPLMAX),vyend(NPLMAX),vzend(NPLMAX)
  72. c... Inputs and Outputs:
  73. integer istat(NTPMAX,NSTAT)
  74. real*8 xht(ntp),yht(ntp),zht(ntp)
  75. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  76. c... Outputs:
  77. real*8 peri(NTPMAX)
  78. integer isperi(NTPMAX)
  79. c... Internals
  80. integer i1sttp,i,j,k,link,istattmp(NTPMAX,NSTAT)
  81. real*8 xtpt(NTPMAX),ytpt(NTPMAX),ztpt(NTPMAX),dti
  82. real*8 vxtpt(NTPMAX),vytpt(NTPMAX),vztpt(NTPMAX)
  83. real*8 xpltb(NPLMAX),ypltb(NPLMAX),zpltb(NPLMAX)
  84. real*8 xplte(NPLMAX),yplte(NPLMAX),zplte(NPLMAX)
  85. real*8 masst(NPLMAX),perit(NTPMAX)
  86. integer isperit(NTPMAX)
  87. logical*2 lperit(NTPMAX)
  88. real*8 irh(NPLMAX),aoblx(NPLMAX,0:NTPENC)
  89. real*8 aobly(NPLMAX,0:NTPENC),aoblz(NPLMAX,0:NTPENC)
  90. c----
  91. c... Executable code
  92. dti = dt/float(NTPENC)
  93. c... First get the accel due to J2 and J4 in barycentric frame on planets
  94. if(j2rp2.ne.0.0d0) then
  95. do i=2,nbod
  96. irh(i) = 1.0d0/sqrt( xbeg(i)**2 + ybeg(i)**2 + zbeg(i)**2 )
  97. enddo
  98. call obl_acc(nbod,mass,j2rp2,j4rp4,xbeg,ybeg,zbeg,
  99. & irh,aoblx(1,0),aobly(1,0),aoblz(1,0))
  100. do j=1,NTPENC
  101. do i=2,nbod
  102. irh(i) = 1.0d0/sqrt( xpl(i,j)**2 + ypl(i,j)**2 +
  103. & zpl(i,j)**2 )
  104. enddo
  105. call obl_acc(nbod,mass,j2rp2,j4rp4,xpl(1,j),ypl(1,j),
  106. & zpl(1,j),irh,aoblx(1,j),aobly(1,j),aoblz(1,j))
  107. enddo
  108. endif
  109. c... Must do each planet one at a time
  110. do i=2,nbod
  111. if(nenci(i).ne.0) then
  112. c... set up test particles
  113. do j = 1,nenci(i)
  114. link = itpenci(j,i)
  115. xtpt(j) = xht(link) - xbeg(i)
  116. ytpt(j) = yht(link) - ybeg(i)
  117. ztpt(j) = zht(link) - zbeg(i)
  118. vxtpt(j) = vxht(link) - vxbeg(i)
  119. vytpt(j) = vyht(link) - vybeg(i)
  120. vztpt(j) = vzht(link) - vzbeg(i)
  121. istattmp(j,1) = 0
  122. lperit(j) = .false.
  123. enddo
  124. C... set up planets at t=0
  125. call rmvs_step_in_mvpl(i,nbod,mass,xbeg,ybeg,zbeg,
  126. & masst,xpltb,ypltb,zpltb,xplte,yplte,zplte)
  127. i1sttp = 0
  128. call util_peri(0,nenci(i),xtpt,ytpt,ztpt,vxtpt,
  129. & vytpt,vztpt,masst(1),isperit,perit,lperit)
  130. do j=1,NTPENC
  131. call rmvs_step_in_mvpl(i,nbod,mass,xpl(1,j),ypl(1,j),
  132. & zpl(1,j),masst,xpltb,ypltb,
  133. & zpltb,xplte,yplte,zplte)
  134. call rmvs_step_in_tp(i1sttp,nbod,nenci(i),masst,
  135. & j2rp2,j4rp4,xpltb,ypltb,zpltb,xplte,yplte,zplte,
  136. & xtpt,ytpt,ztpt,vxtpt,vytpt,vztpt,istattmp,dti,
  137. & i,aoblx(i,j-1),aobly(i,j-1),aoblz(i,j-1),
  138. & aoblx(i,j),aobly(i,j),aoblz(i,j))
  139. call util_peri(1,nenci(i),xtpt,ytpt,ztpt,vxtpt,
  140. & vytpt,vztpt,masst(1),isperit,perit,lperit)
  141. enddo
  142. c... put things back
  143. do j = 1,nenci(i)
  144. link = itpenci(j,i)
  145. xht(link) = xtpt(j) + xend(i)
  146. yht(link) = ytpt(j) + yend(i)
  147. zht(link) = ztpt(j) + zend(i)
  148. vxht(link) = vxtpt(j) + vxend(i)
  149. vyht(link) = vytpt(j) + vyend(i)
  150. vzht(link) = vztpt(j) + vzend(i)
  151. if(lperit(j)) then
  152. isperi(link) = 0
  153. else
  154. isperi(link) = isperit(j)
  155. endif
  156. peri(link) = perit(j)
  157. if(istattmp(j,1).ne.0) then
  158. istat(link,1) = 1
  159. do k=2,NSTAT
  160. istat(link,k) = istattmp(j,k)
  161. enddo
  162. endif
  163. enddo
  164. endif
  165. enddo
  166. return
  167. end ! rmvs_step_in
  168. c------------------------------------------------------------------