orbel_eget.f 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ***********************************************************************
  2. c ORBEL_EGET.F
  3. ***********************************************************************
  4. * PURPOSE: Solves Kepler's eqn. e is ecc. m is mean anomaly.
  5. *
  6. * Input:
  7. * e ==> eccentricity anomaly. (real scalar)
  8. * m ==> mean anomaly. (real scalar)
  9. * Returns:
  10. * orbel_eget ==> eccentric anomaly. (real scalar)
  11. *
  12. * ALGORITHM: Quartic convergence from Danby
  13. * REMARKS: For results very near roundoff, give it M between
  14. * 0 and 2*pi. One can condition M before calling EGET
  15. * by calling my double precision function MOD2PI(M).
  16. * This is not done within the routine to speed it up
  17. * and because it works fine even for large M.
  18. * AUTHOR: M. Duncan
  19. * DATE WRITTEN: May 7, 1992.
  20. * REVISIONS: May 21, 1992. Now have it go through EXACTLY two iterations
  21. * with the premise that it will only be called if
  22. * we have an ellipse with e between 0.15 and 0.8
  23. ***********************************************************************
  24. real*8 function orbel_eget(e,m)
  25. include '../swift.inc'
  26. c... Inputs Only:
  27. real*8 e,m
  28. c... Internals:
  29. real*8 x,sm,cm,sx,cx
  30. real*8 es,ec,f,fp,fpp,fppp,dx
  31. c----
  32. c... Executable code
  33. c Function to solve Kepler's eqn for E (here called
  34. c x) for given e and M. returns value of x.
  35. c MAY 21 : FOR e < 0.18 use ESOLMD for speed and sufficient accuracy
  36. c MAY 21 : FOR e > 0.8 use EHIE - this one may not converge fast enough.
  37. call orbel_scget(m,sm,cm)
  38. c begin with a guess accurate to order ecc**3
  39. x = m + e*sm*( 1.d0 + e*( cm + e*( 1.d0 -1.5d0*sm*sm)))
  40. c Go through one iteration for improved estimate
  41. call orbel_scget(x,sx,cx)
  42. es = e*sx
  43. ec = e*cx
  44. f = x - es - m
  45. fp = 1.d0 - ec
  46. fpp = es
  47. fppp = ec
  48. dx = -f/fp
  49. dx = -f/(fp + dx*fpp/2.d0)
  50. dx = -f/(fp + dx*fpp/2.d0 + dx*dx*fppp/6.d0)
  51. orbel_eget = x + dx
  52. c Do another iteration.
  53. c For m between 0 and 2*pi this seems to be enough to
  54. c get near roundoff error for eccentricities between 0 and 0.8
  55. x = orbel_eget
  56. call orbel_scget(x,sx,cx)
  57. es = e*sx
  58. ec = e*cx
  59. f = x - es - m
  60. fp = 1.d0 - ec
  61. fpp = es
  62. fppp = ec
  63. dx = -f/fp
  64. dx = -f/(fp + dx*fpp/2.d0)
  65. dx = -f/(fp + dx*fpp/2.d0 + dx*dx*fppp/6.d0)
  66. orbel_eget = x + dx
  67. return
  68. end ! orbel_eget
  69. c---------------------------------------------------------------------