coord_vh2b.f 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. c***********************************************************************
  2. c COORD_VH2B.F
  3. c***********************************************************************
  4. * PURPOSE: Converts from Heliocentric to Barycentric coords.
  5. * Velocity only
  6. * ARGUMENTS: Input is
  7. * nbod ==> number of bodies (must be less than NBMAX)
  8. * (integer)
  9. * mass(*) ==> masses (real array)
  10. * vxh(*),vyh(*),vzh(*) ==> heliocentric particle velocities
  11. * (real array)
  12. * Returned are
  13. * vxb(*),vyb(*),vzb(*) ==> bary. particle velocities
  14. * (real array)
  15. * msys ==> Total mass of of system
  16. * (real scalar)
  17. * Authors: Hal Levison
  18. * ALGORITHM: Obvious
  19. * WRITTEN: 11/14/96
  20. * REVISIONS: 11/21/96
  21. subroutine coord_vh2b(nbod,mass,vxh,vyh,vzh,vxb,vyb,vzb,msys)
  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 vxb(nbod),vyb(nbod),vzb(nbod)
  29. c... Internals:
  30. real*8 msys,vxtmp,vytmp,vztmp
  31. integer n
  32. c----
  33. c... Executable code
  34. msys = mass(1)
  35. vxtmp =0.d0
  36. vytmp =0.d0
  37. vztmp =0.d0
  38. do n=2,nbod
  39. msys = msys +mass(n)
  40. vxtmp = vxtmp + mass(n)*vxh(n)
  41. vytmp = vytmp + mass(n)*vyh(n)
  42. vztmp = vztmp + mass(n)*vzh(n)
  43. enddo
  44. vxb(1) = -vxtmp/msys
  45. vyb(1) = -vytmp/msys
  46. vzb(1) = -vztmp/msys
  47. do n=2,nbod
  48. vxb(n) = vxh(n) + vxb(1)
  49. vyb(n) = vyh(n) + vyb(1)
  50. vzb(n) = vzh(n) + vzb(1)
  51. enddo
  52. return
  53. end ! coord_vh2b
  54. c--------------------------------------------------------------------------