util_peri1.f 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. c*************************************************************************
  2. c UTIL_PERI1.F
  3. c*************************************************************************
  4. c This subroutine determines whether peri has taken place.
  5. c Only for one particle.
  6. c
  7. c Input:
  8. c iflg ==> = 0 if first step; = 1 not (int scalar)
  9. c xt,yt,zt ==> planocantric position of tp's
  10. c (real scalar)
  11. c vxt,vyt,vzt ==> planocantric velcocities of tp's
  12. c (real scalar)
  13. c massc ==> mass of the central body (real scalar)
  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 scalar)
  20. c peri ==> set to pericenter dist. if isperi=0
  21. c (real scalar)
  22. c tperi ==> set to time to next or last perihelion,
  23. c which ever is less, if isperi=0
  24. c (real scalar)
  25. c
  26. c
  27. c Remarks: Based on util_peri
  28. c Authors: Hal Levison
  29. c Date: 2/13/01
  30. c Last revision: 8/7/01
  31. subroutine util_peri1(iflg,xt,yt,zt,vxt,vyt,vzt,
  32. & massc,isperi,peri,tperi)
  33. include '../swift.inc'
  34. c... Inputs Only:
  35. integer ntp,iflg
  36. real*8 xt,yt,zt,massc
  37. real*8 vxt,vyt,vzt
  38. c... Outputs:
  39. real*8 peri,tperi
  40. integer isperi
  41. c... Internals
  42. integer i,ialpha
  43. real*8 vdotr,a,e
  44. real*8 capm ! Not used
  45. c----
  46. c... Executable code
  47. if(iflg.eq.0) then ! are we just setting thing up?
  48. vdotr = xt*vxt + yt*vyt + zt*vzt
  49. if (vdotr .gt. 0.d0) then
  50. isperi = 1
  51. else
  52. isperi =-1
  53. endif
  54. else
  55. vdotr = xt*vxt + yt*vyt + zt*vzt
  56. if(isperi.eq.-1) then ! was coming in
  57. if (vdotr .lt. 0.d0) then ! still coming in
  58. isperi = -1
  59. else ! turned around
  60. isperi = 0
  61. call orbel_xv2aqt(xt,yt,zt,vxt,vyt,
  62. & vzt,massc,ialpha,a,peri,capm,tperi)
  63. endif
  64. else
  65. if (vdotr .lt. 0.d0) then ! coming in
  66. isperi = -1
  67. else
  68. isperi = 1 ! going out
  69. endif
  70. endif
  71. endif
  72. return
  73. end ! util_peri1
  74. c------------------------------------------------------------------