drift_kepu_new.f 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. c*************************************************************************
  2. c DRIFT_KEPU_NEW.F
  3. c*************************************************************************
  4. c subroutine for solving kepler's equation in universal variables.
  5. c using NEWTON'S METHOD
  6. c
  7. c Input:
  8. c s ==> inital value of universal variable
  9. c dt ==> time step (real scalor)
  10. c r0 ==> Distance between `Sun' and paritcle
  11. c (real scalor)
  12. c mu ==> Reduced mass of system (real scalor)
  13. c alpha ==> energy (real scalor)
  14. c u ==> angular momentun (real scalor)
  15. c Output:
  16. c s ==> final value of universal variable
  17. c fp ==> f' from p170
  18. c (real scalors)
  19. c c1,c2,c3 ==> c's from p171-172
  20. c (real scalors)
  21. c iflgn ==> =0 if converged; !=0 if not
  22. c
  23. c Author: Hal Levison
  24. c Date: 2/3/93
  25. c Last revision: 4/21/93
  26. subroutine drift_kepu_new(s,dt,r0,mu,alpha,u,fp,c1,c2,c3,iflgn)
  27. include '../../swift.inc'
  28. c... Inputs:
  29. real*8 s,dt,r0,mu,alpha,u
  30. c... Outputs:
  31. real*8 fp,c1,c2,c3
  32. integer iflgn
  33. c... Internals:
  34. integer nc
  35. real*8 x,c0,ds
  36. real*8 f,fpp,fppp,fdt
  37. c----
  38. c... Executable code
  39. do nc=0,6
  40. x = s*s*alpha
  41. call drift_kepu_stumpff(x,c0,c1,c2,c3)
  42. c1 = c1*s
  43. c2 = c2*s*s
  44. c3 = c3*s*s*s
  45. f = r0*c1 + u*c2 + mu*c3 - dt
  46. fp = r0*c0 + u*c1 + mu*c2
  47. fpp = (-r0*alpha + mu)*c1 + u*c0
  48. fppp = (- r0*alpha + mu)*c0 - u*alpha*c1
  49. ds = - f/fp
  50. ds = - f/(fp + ds*fpp/2.0)
  51. ds = -f/(fp + ds*fpp/2.0 + ds*ds*fppp/6.0)
  52. s = s + ds
  53. fdt = f/dt
  54. c.. quartic convergence
  55. if( fdt*fdt.lt.DANBYB*DANBYB) then
  56. iflgn = 0
  57. return
  58. endif
  59. c... newton's method succeeded
  60. enddo
  61. c.. newton's method failed
  62. iflgn = 1
  63. return
  64. end ! drift_kepu_new
  65. c----------------------------------------------------------------------