symba5_getacch.f 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. c*************************************************************************
  2. c SYMBA5_GETACCH.F
  3. c*************************************************************************
  4. c This subroutine calculates the acceleration on the massive particles
  5. c in the HELIOCENTRIC frame.
  6. c Input:
  7. c nbod ==> number of massive bodies (int scalor)
  8. c nbodm ==> Location of last massive body(int scalar)
  9. c mass ==> mass of bodies (real array)
  10. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  11. c (real scalars)
  12. c xh,yh,zh ==> position in heliocentric coord (real arrays)
  13. c mtiny ==> Small mass (real array)
  14. c ielc ==> number of encounters (integer*2 scalar)
  15. c ielst ==> list of ecnounters (2D integer*2 array)
  16. c Output:
  17. c axh,ayh,azh ==> acceleration in helio coord (real arrays)
  18. c
  19. c Remarks: Based on helio_getacch.f, but does not include the forces of
  20. c an body B on body A, if body B and A are having an encounter.
  21. c Author: Hal Levison
  22. c Date: 3/20/97
  23. c Last revision: 11/8/13
  24. subroutine symba5_getacch(nbod,nbodm,mass,j2rp2,
  25. & j4rp4,xh,yh,zh,axh,ayh,azh,mtiny,ielc,ielst)
  26. include '../swift.inc'
  27. include 'symba5.inc'
  28. c... Inputs:
  29. integer nbod,nbodm
  30. real*8 mass(nbod),j2rp2,j4rp4,mtiny
  31. real*8 xh(nbod),yh(nbod),zh(nbod)
  32. integer*2 ielst(2,NENMAX),ielc
  33. c... Outputs:
  34. real*8 axh(nbod),ayh(nbod),azh(nbod)
  35. c... Internals:
  36. real*8 aoblx(NTPMAX),aobly(NTPMAX),aoblz(NTPMAX)
  37. real*8 ir3h(NTPMAX),irh(NTPMAX)
  38. integer i,j,ie
  39. real*8 dx,dy,dz,rji2,faci,facj,irij3
  40. c---
  41. c... Executable code
  42. c... Zero things
  43. do i=1,nbod
  44. axh(i) = 0.0
  45. ayh(i) = 0.0
  46. azh(i) = 0.0
  47. enddo
  48. c... now the third terms
  49. do i=2,nbodm
  50. do j=i+1,nbod
  51. dx = xh(j) - xh(i)
  52. dy = yh(j) - yh(i)
  53. dz = zh(j) - zh(i)
  54. rji2 = dx*dx + dy*dy + dz*dz
  55. irij3 = 1.0d0/(rji2*sqrt(rji2))
  56. faci = mass(i)*irij3
  57. facj = mass(j)*irij3
  58. axh(j) = axh(j) - faci*dx
  59. ayh(j) = ayh(j) - faci*dy
  60. azh(j) = azh(j) - faci*dz
  61. axh(i) = axh(i) + facj*dx
  62. ayh(i) = ayh(i) + facj*dy
  63. azh(i) = azh(i) + facj*dz
  64. enddo
  65. enddo
  66. c... Now subtract off anyone in an encounter
  67. do ie=1,ielc
  68. i = ielst(1,ie)
  69. j = ielst(2,ie)
  70. dx = xh(j) - xh(i)
  71. dy = yh(j) - yh(i)
  72. dz = zh(j) - zh(i)
  73. rji2 = dx*dx + dy*dy + dz*dz
  74. irij3 = 1.0d0/(rji2*sqrt(rji2))
  75. faci = mass(i)*irij3
  76. facj = mass(j)*irij3
  77. axh(j) = axh(j) + faci*dx
  78. ayh(j) = ayh(j) + faci*dy
  79. azh(j) = azh(j) + faci*dz
  80. axh(i) = axh(i) - facj*dx
  81. ayh(i) = ayh(i) - facj*dy
  82. azh(i) = azh(i) - facj*dz
  83. enddo
  84. c... Now do j2 and j4 stuff
  85. if(j2rp2.ne.0.0d0) then
  86. call getacch_ir3(nbod,2,xh,yh,zh,ir3h,irh)
  87. call obl_acc(nbod,mass,j2rp2,j4rp4,xh,yh,zh,irh,
  88. & aoblx,aobly,aoblz)
  89. do i = 2,nbod
  90. if(mass(i).ne.0.0d0) then
  91. axh(i) = axh(i) + aoblx(i)
  92. ayh(i) = ayh(i) + aobly(i)
  93. azh(i) = azh(i) + aoblz(i)
  94. endif
  95. enddo
  96. endif
  97. return
  98. end ! symba5_getacch
  99. c---------------------------------------------------------------------