util_mass_peri.f 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. c*************************************************************************
  2. c UTIL_MASS_PERI.F
  3. c*************************************************************************
  4. c This subroutine determines whether peri of a planet has taken place
  5. c
  6. c Input:
  7. c iflg ==> = 0 if first step; = 1 not (int scalar)
  8. c nbod ==> number of bodies (int scalar)
  9. c x,y,z ==> heliocentric position of planets
  10. c (real arrays)
  11. c vx,vy,vz ==> heliocentric velcocities of planets
  12. c (real arrays)
  13. c mass ==> mass of the bodies (real array)
  14. c
  15. c Output:
  16. c isperi ==> = 0 if tp went through peri
  17. c =-1 if tp pre peri
  18. c = 1 if tp post peri
  19. c (integer array)
  20. c peri ==> set to pericenter dist. if isperi=0
  21. c (real array)
  22. c lperi ==> set to .true. if isperi=0
  23. c (logical*2 array)
  24. c
  25. c
  26. c Remarks: Based on util_peri.f
  27. c Authors: Hal Levison
  28. c Date: 12/30/96
  29. c Last revision:
  30. subroutine util_mass_peri(iflg,nbod,x,y,z,vx,vy,vz,
  31. & mass,isperi,peri,lperi)
  32. include '../swift.inc'
  33. c... Inputs Only:
  34. integer nbod,iflg
  35. real*8 x(nbod),y(nbod),z(nbod),mass(nbod)
  36. real*8 vx(nbod),vy(nbod),vz(nbod),gm
  37. c... Outputs:
  38. real*8 peri(NTPMAX)
  39. integer isperi(NTPMAX)
  40. logical*2 lperi(NTPMAX)
  41. c... Internals
  42. integer i,ialpha
  43. real*8 vdotr,a,e
  44. c----
  45. c... Executable code
  46. if(iflg.eq.0) then ! are we just setting thing up?
  47. do i=2,nbod
  48. vdotr = x(i)*vx(i) + y(i)*vy(i) + z(i)*vz(i)
  49. if (vdotr .gt. 0.d0) then
  50. isperi(i) = 1
  51. else
  52. isperi(i) =-1
  53. endif
  54. enddo
  55. else
  56. do i=2,nbod
  57. vdotr = x(i)*vx(i) + y(i)*vy(i) + z(i)*vz(i)
  58. if(isperi(i).eq.-1) then ! was coming in
  59. if (vdotr .lt. 0.d0) then ! still coming in
  60. isperi(i) = -1
  61. else ! turned around
  62. isperi(i) = 0
  63. lperi(i) = .true.
  64. gm = mass(1) + mass(i)
  65. call orbel_xv2aeq(x(i),y(i),z(i),vx(i),vy(i),
  66. & vz(i),gm,ialpha,a,e,peri(i))
  67. endif
  68. else
  69. if (vdotr .lt. 0.d0) then ! coming in
  70. isperi(i) = -1
  71. else
  72. isperi(i) = 1 ! going out
  73. endif
  74. endif
  75. enddo
  76. endif
  77. return
  78. end ! util_mass_peri
  79. c------------------------------------------------------------------