getacch_ah3.f 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. c*************************************************************************
  2. c GETACCH_A3.F
  3. c*************************************************************************
  4. c This subroutine calculates the 3rd term acceleration on the massive particles
  5. c in the HELIOCENTRIC frame. This term is the direct cross terms
  6. c Input:
  7. c nbod ==> number of massive bodies (int scalor)
  8. c mass ==> mass of bodies (real array)
  9. c xh,yh,zh ==> position in heliocentric coord
  10. c (real arrays)
  11. c Output:
  12. c axh3,ayh3,azh3 ==> 3rd term of acceleration in helio coord
  13. c (real arrays)
  14. c
  15. c Author: Hal Levison
  16. c Date: 2/2/93
  17. c Last revision: 11/21/96
  18. subroutine getacch_ah3(nbod,mass,xh,yh,zh,axh3,ayh3,azh3)
  19. include '../../swift.inc'
  20. c... Inputs:
  21. integer nbod
  22. real*8 mass(nbod),xh(nbod),yh(nbod),zh(nbod)
  23. c... Outputs:
  24. real*8 axh3(nbod),ayh3(nbod),azh3(nbod)
  25. c... Internals:
  26. integer i,j
  27. real*8 dx,dy,dz,rji2,faci,facj,irij3
  28. c------
  29. c... Executable code
  30. do i=1,nbod
  31. axh3(i) = 0.0
  32. ayh3(i) = 0.0
  33. azh3(i) = 0.0
  34. enddo
  35. do i=2,nbod-1
  36. do j=i+1,nbod
  37. dx = xh(j) - xh(i)
  38. dy = yh(j) - yh(i)
  39. dz = zh(j) - zh(i)
  40. rji2 = dx*dx + dy*dy + dz*dz
  41. irij3 = 1.0d0/(rji2*sqrt(rji2))
  42. faci = mass(i)*irij3
  43. facj = mass(j)*irij3
  44. axh3(j) = axh3(j) - faci*dx
  45. ayh3(j) = ayh3(j) - faci*dy
  46. azh3(j) = azh3(j) - faci*dz
  47. axh3(i) = axh3(i) + facj*dx
  48. ayh3(i) = ayh3(i) + facj*dy
  49. azh3(i) = azh3(i) + facj*dz
  50. enddo
  51. enddo
  52. return
  53. end ! getacch_ah3