lyap2_step.f 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. c*************************************************************************
  2. c LYAP2_STEP.F
  3. c*************************************************************************
  4. c This subroutine takes a step in helio coord.
  5. c Uses the difference equations as discussed my Mikola
  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 rstat(i,3), rstat(i,3), rstat(i,5) =
  30. c the dx(1)-dx(3) from the
  31. c difference equations.
  32. c rstat(i,6), rstat(i,7), rstat(i,8) =
  33. c the dv(1)-dv(3) from the
  34. c difference equations
  35. c dt ==> time step
  36. c Output:
  37. c xh,yh,zh ==> final position in helio coord
  38. c (real arrays)
  39. c vxh,vyh,vzh ==> final velocity in helio coord
  40. c (real arrays)
  41. c xht,yht,zht ==> final position in helio coord
  42. c (real arrays)
  43. c vxht,vyht,vzht ==> final position in helio coord
  44. c (real arrays)
  45. c
  46. c Remarks: Adopted from step_kbk
  47. c Authors: Hal Levison
  48. c Date: 7/11/95
  49. c Last revision:
  50. subroutine lyap2_step(i1st,time,nbod,ntp,mass,j2rp2,j4rp4,
  51. & xh,yh,zh,vxh,vyh,vzh,xht,yht,zht,vxht,vyht,vzht,
  52. & istat,rstat,dt)
  53. include '../swift.inc'
  54. c... Inputs Only:
  55. integer nbod,ntp,i1st
  56. real*8 mass(nbod),dt,time,j2rp2,j4rp4
  57. c... Inputs and Outputs:
  58. integer istat(NTPMAX,NSTAT)
  59. real*8 rstat(NTPMAX,NSTATR)
  60. real*8 xh(nbod),yh(nbod),zh(nbod)
  61. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  62. real*8 xht(ntp),yht(ntp),zht(ntp)
  63. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  64. c... Internals
  65. integer i1sttp,i,i1stin,iul
  66. real*8 xbeg(NPLMAX),ybeg(NPLMAX),zbeg(NPLMAX)
  67. real*8 xend(NPLMAX),yend(NPLMAX),zend(NPLMAX)
  68. real*8 dx0,dy0,dz0,dvx0,dvy0,dvz0
  69. real*8 dxht(NTPMAX),dyht(NTPMAX),dzht(NTPMAX)
  70. real*8 dvxht(NTPMAX),dvyht(NTPMAX),dvzht(NTPMAX)
  71. real*8 dist(NTPMAX)
  72. real*8 tin,tlout,dtlout
  73. data i1stin/0/
  74. save i1stin,tin,tlout,dtlout,iul
  75. save dxht,dyht,dzht,dvxht,dvyht,dvzht
  76. c----
  77. c... Executable code
  78. c... set things up if this is the initial call
  79. if(i1stin.eq.0) then
  80. if( (j2rp2.ne.0.0d0) .or. (j4rp4.ne.0.0d0) ) then
  81. write(*,*) 'LYAP2 routines must have J2,J4=0!'
  82. call util_exit(1) ! <==== NOTE!
  83. endif
  84. write(*,*) 'Input how aften the distance is written:'
  85. read(*,*) dtlout
  86. write(*,*) 'Input the initial separation in phase space'
  87. write(*,*) ' If <0 then use the values currently in rstat'
  88. read(*,*) dx0,dy0,dz0,dvx0,dvy0,dvz0
  89. iul = 50
  90. tin = 0.0
  91. i1stin = 1
  92. tlout = dtlout
  93. if(dx0.gt.0.0d0) then
  94. do i=1,ntp
  95. dxht(i) = dx0
  96. dyht(i) = dy0
  97. dzht(i) = dz0
  98. dvxht(i) = dvx0
  99. dvyht(i) = dvy0
  100. dvzht(i) = dvz0
  101. enddo
  102. else
  103. do i=1,ntp
  104. dxht(i) = rstat(i,3)
  105. dyht(i) = rstat(i,4)
  106. dzht(i) = rstat(i,5)
  107. dvxht(i) = rstat(i,6)
  108. dvyht(i) = rstat(i,7)
  109. dvzht(i) = rstat(i,8)
  110. enddo
  111. endif
  112. do i=1,ntp
  113. if(istat(i,1).ne.0) then
  114. dist(i) = 0.0d0
  115. else
  116. dist(i) = sqrt( dxht(i)**2 + dyht(i)**2 +
  117. & dzht(i)**2 + dvxht(i)**2 + dvyht(i)**2 +
  118. & dvzht(i)**2 )
  119. endif
  120. enddo
  121. call io_lyap2_write(iul,time,dist,ntp)
  122. write(*,*) ' CONTINUE: '
  123. endif
  124. c... for the normal step
  125. i1sttp = i1st
  126. c... remember the current position of the planets
  127. do i=1,nbod
  128. xbeg(i) = xh(i)
  129. ybeg(i) = yh(i)
  130. zbeg(i) = zh(i)
  131. enddo
  132. c... first do the planets
  133. call step_kdk_pl(i1st,nbod,mass,j2rp2,j4rp4,
  134. & xh,yh,zh,vxh,vyh,vzh,dt)
  135. c... now remember these positions
  136. do i=1,nbod
  137. xend(i) = xh(i)
  138. yend(i) = yh(i)
  139. zend(i) = zh(i)
  140. enddo
  141. c... next the test particles
  142. call lyap2_step_tp(i1sttp,nbod,ntp,mass,j2rp2,j4rp4,
  143. & xbeg,ybeg,zbeg,xend,yend,zend,
  144. & xht,yht,zht,vxht,vyht,vzht,
  145. & dxht,dyht,dzht,dvxht,dvyht,dvzht,istat,dt)
  146. tin = tin + dt
  147. c... now do the lyap anal stuff
  148. if(tin .ge. tlout) then
  149. do i=1,ntp
  150. if(istat(i,1).ne.0) then
  151. dist(i) = 0.0d0
  152. else
  153. dist(i) = sqrt( dxht(i)**2 + dyht(i)**2 +
  154. & dzht(i)**2 + dvxht(i)**2 + dvyht(i)**2 +
  155. & dvzht(i)**2 )
  156. endif
  157. enddo
  158. call io_lyap2_write(iul,time,dist,ntp)
  159. tlout = tlout + dtlout
  160. endif
  161. do i=1,ntp
  162. rstat(i,3) = dxht(i)
  163. rstat(i,4) = dyht(i)
  164. rstat(i,5) = dzht(i)
  165. rstat(i,6) = dvxht(i)
  166. rstat(i,7) = dvyht(i)
  167. rstat(i,8) = dvzht(i)
  168. enddo
  169. return
  170. end ! lyap2_step
  171. c------------------------------------------------------------------------