drift_kepmd.f 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. c********************************************************************#
  2. c DRIFT_KEPMD
  3. c********************************************************************#
  4. c Subroutine for solving kepler's equation in difference form for an
  5. c ellipse, given SMALL dm and SMALL eccentricity. See DRIFT_DAN.F
  6. c for the criteria.
  7. c WARNING - BUILT FOR SPEED : DOES NOT CHECK HOW WELL THE ORIGINAL
  8. c EQUATION IS SOLVED! (CAN DO THAT IN THE CALLING ROUTINE BY
  9. c CHECKING HOW CLOSE (x - ec*s +es*(1.-c) - dm) IS TO ZERO.
  10. c
  11. c Input:
  12. c dm ==> increment in mean anomaly M (real*8 scalar)
  13. c es,ec ==> ecc. times sin and cos of E_0 (real*8 scalars)
  14. c
  15. c Output:
  16. c x ==> solution to Kepler's difference eqn (real*8 scalar)
  17. c s,c ==> sin and cosine of x (real*8 scalars)
  18. c
  19. subroutine drift_kepmd(dm,es,ec,x,s,c)
  20. implicit none
  21. c... Inputs
  22. real*8 dm,es,ec
  23. c... Outputs
  24. real*8 x,s,c
  25. c... Internals
  26. real*8 A0, A1, A2, A3, A4
  27. parameter(A0 = 39916800.d0, A1 = 6652800.d0, A2 = 332640.d0)
  28. parameter(A3 = 7920.d0, A4 = 110.d0)
  29. real*8 dx
  30. real*8 fac1,fac2,q,y
  31. real*8 f,fp,fpp,fppp
  32. c... calc initial guess for root
  33. fac1 = 1.d0/(1.d0 - ec)
  34. q = fac1*dm
  35. fac2 = es*es*fac1 - ec/3.d0
  36. x = q*(1.d0 -0.5d0*fac1*q*(es -q*fac2))
  37. c... excellent approx. to sin and cos of x for small x.
  38. y = x*x
  39. s = x*(A0-y*(A1-y*(A2-y*(A3-y*(A4-y)))))/A0
  40. c = sqrt(1.d0 - s*s)
  41. c... Compute better value for the root using quartic Newton method
  42. f = x - ec*s + es*(1.-c) - dm
  43. fp = 1. - ec*c + es*s
  44. fpp = ec*s + es*c
  45. fppp = ec*c - es*s
  46. dx = -f/fp
  47. dx = -f/(fp + 0.5*dx*fpp)
  48. dx = -f/(fp + 0.5*dx*fpp + 0.16666666666666666*dx*dx*fppp)
  49. x = x + dx
  50. c... excellent approx. to sin and cos of x for small x.
  51. y = x*x
  52. s = x*(A0-y*(A1-y*(A2-y*(A3-y*(A4-y)))))/A0
  53. c = sqrt(1.d0 - s*s)
  54. return
  55. end
  56. c-----------------------------------------------------------------------------