util_hills.f 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. c*************************************************************************
  2. c UTIL_HILLS.F
  3. c*************************************************************************
  4. c This subroutine calculates the hill's sphere for the planets
  5. c
  6. c Input:
  7. c nbod ==> number of massive bodies (int scalar)
  8. c mass ==> mass of bodies (real array)
  9. c xh,yh,zh ==> initial position in helio coord
  10. c (real arrays)
  11. c vxh,vyh,vzh ==> initial velocity in helio coord
  12. c (real arrays)
  13. c Output:
  14. c r2hill ==> the SQUARE of the planet's hill's sphere
  15. c (real array)
  16. c
  17. c
  18. c Remarks:
  19. c Authors: Hal Levison
  20. c Date: 2/19/93
  21. c Last revision: 1/6/97
  22. subroutine util_hills(nbod,mass,xh,yh,zh,vxh,vyh,vzh,r2hill)
  23. include '../swift.inc'
  24. c... Inputs:
  25. integer nbod
  26. real*8 mass(nbod),xh(nbod),yh(nbod),zh(nbod)
  27. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  28. c... Outputs
  29. real*8 r2hill(nbod)
  30. c... Internals
  31. integer i
  32. real*8 mu,energy,ap,rhil,r,v2
  33. c-----
  34. c... Executable code
  35. do i=2,nbod
  36. if(mass(i).ne.0.0d0) then
  37. mu = mass(1)*mass(i)/(mass(1)+mass(i))
  38. r = sqrt( xh(i)*xh(i) + yh(i)*yh(i) + zh(i)*zh(i) )
  39. v2 = vxh(i)*vxh(i) + vyh(i)*vyh(i) + vzh(i)*vzh(i)
  40. energy =-1.0d0*mass(1)*mass(i)/r + 0.5*mu*v2
  41. ap = -1.0d0*mass(1)*mass(i)/(2.0d0*energy)
  42. rhil = ap * (((mu/mass(1))/3.0)**(0.3333333333))
  43. r2hill(i) = rhil*rhil
  44. else
  45. r2hill(i) = 0.0d0
  46. endif
  47. enddo
  48. r2hill(1) = 0.0
  49. return
  50. end ! util_hills
  51. c---------------------------------------------------