coord_vh2vj.f 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ***********************************************************************
  2. * COORD_VH2VJ.F
  3. ***********************************************************************
  4. * PURPOSE: Converts from Heliocentric to Jacobi coords. VELOCITIES ONLY.
  5. * ARGUMENTS: Input is
  6. * nbod ==> number of objects (must be less than NBMAX)
  7. * (integer)
  8. * mass(*) ==> planetary masses (real array)
  9. * vxh(*),vyh(*),vzh(*) ==>barycentric particle velocities
  10. * (real array)
  11. * Returned are
  12. * vxj(*),vyj(*),vzj(*) ==> jacobi. particle velocities
  13. * (real array)
  14. *
  15. * ALGORITHM: See my notes Nov 21/92
  16. * REMARKS:
  17. *
  18. * AUTHOR: M. Duncan.
  19. * DATE WRITTEN: Jan 29, 1993.
  20. * REVISIONS: 2/20/2K HFL
  21. subroutine coord_vh2vj(nbod,mass,vxh,vyh,vzh,vxj,vyj,vzj)
  22. include '../swift.inc'
  23. c... Inputs:
  24. integer nbod
  25. real*8 mass(nbod)
  26. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  27. c... Outputs:
  28. real*8 vxj(nbod),vyj(nbod),vzj(nbod)
  29. c... Internals:
  30. real*8 eta(NTPMAX)
  31. real*8 sumvx,sumvy,sumvz
  32. real*8 capvx,capvy,capvz
  33. integer n
  34. c----
  35. c... Executable code
  36. c First calc. the array eta(*) then convert to jacobi velocities
  37. eta(1) = mass(1)
  38. do n = 2,nbod
  39. eta(n) = eta(n-1) + mass(n)
  40. enddo
  41. vxj(1) =0.d0
  42. vyj(1) =0.d0
  43. vzj(1) =0.d0
  44. vxj(2) = vxh(2)
  45. vyj(2) = vyh(2)
  46. vzj(2) = vzh(2)
  47. sumvx = mass(2)*vxh(2)
  48. sumvy = mass(2)*vyh(2)
  49. sumvz = mass(2)*vzh(2)
  50. capvx = sumvx/eta(2)
  51. capvy = sumvy/eta(2)
  52. capvz = sumvz/eta(2)
  53. do n=3,nbod
  54. vxj(n) = vxh(n) - capvx
  55. vyj(n) = vyh(n) - capvy
  56. vzj(n) = vzh(n) - capvz
  57. if(n.lt.nbod) then
  58. sumvx = sumvx + mass(n)*vxh(n)
  59. sumvy = sumvy + mass(n)*vyh(n)
  60. sumvz = sumvz + mass(n)*vzh(n)
  61. capvx =sumvx/eta(n)
  62. capvy =sumvy/eta(n)
  63. capvz =sumvz/eta(n)
  64. endif
  65. enddo
  66. 123 return
  67. end ! coord_vh2vj
  68. c--------------------------------------------------------------------------