obl_pot.f 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. c***************************************************************************
  2. c OBL_POT.F
  3. c*************************************************************************
  4. c OBL_POT returns the total potential in the barycentric frame for NBOD
  5. c particles due to the oblateness of mass(1) using
  6. c the values of J2RP2 and J4RP4 passed into the routine.
  7. c (J2RP2 for example is the product of
  8. c J_2 times the square of the central body's radius)
  9. c Here we return the potential produced
  10. c only by the J2 and J4 terms (i.e. including
  11. c neither the monopole nor higher order terms).
  12. c
  13. c
  14. c Input:
  15. c nbod ==> number of massive bodies (incl. central one)
  16. c mass(*) ==> masses of particles (real*8 array)
  17. c j2rp2 ==> scaled value of j2 moment (real*8 scalar)
  18. c j4rp4 ==> scaled value of j4 moment (real*8 scalar)
  19. c xh(*),yh(*),zh(*) ==> HELIO. positions of particles
  20. c (real*8 vectors)
  21. c irh(*) ==> 1./ magnitude of radius vector (real*8 vector)
  22. c (passed in to save calcs.)
  23. c
  24. c Output:
  25. c oblpot ==> BARY. potential
  26. c (real*8 scalar)
  27. c
  28. c Remarks:
  29. c Authors: Martin Duncan
  30. c Date: 3/4/94
  31. c Last revision:
  32. subroutine obl_pot(nbod,mass,j2rp2,j4rp4,xh,yh,zh,irh,
  33. & oblpot)
  34. include '../swift.inc'
  35. c... Inputs Only:
  36. integer nbod
  37. real*8 mass(NPLMAX)
  38. real*8 j2rp2,j4rp4
  39. real*8 xh(NPLMAX),yh(NPLMAX),zh(NPLMAX),irh(NPLMAX)
  40. c... Output
  41. real*8 oblpot
  42. c... Internals
  43. integer n
  44. real*8 rinv2,t0,t1,t2,t3
  45. real*8 p2,p4
  46. c----
  47. c... executable code
  48. c Sum all the the bary terms for each "planet" due to central oblate "sun"
  49. oblpot = 0.d0
  50. do n =2,nbod
  51. c Note that here we assume we know inverse of radius rather than calc. it
  52. c from (x,y,z) to save the sqrt.
  53. rinv2= irh(n)**2
  54. t0 = mass(1)*mass(n)*rinv2*irh(n)
  55. t1 = j2rp2
  56. t2 = zh(n)*zh(n)*rinv2
  57. t3 = j4rp4*rinv2
  58. p2 = 0.5d0*(3.d0*t2 - 1.d0)
  59. p4 = 0.125d0*( (35.d0*t2 -30.d0)*t2 +3.d0)
  60. oblpot = oblpot + t0*(t1*p2 + t3*p4)
  61. enddo
  62. return
  63. end ! obl_pot.f
  64. c____________________________________________________________________________