drift_kepu_lag.f 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. c*************************************************************************
  2. c DRIFT_KEPU_LAG.F
  3. c*************************************************************************
  4. c subroutine for solving kepler's equation in universal variables.
  5. c using LAGUERRE'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_lag(s,dt,r0,mu,alpha,u,fp,c1,c2,c3,iflg)
  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 iflg
  33. c... Internals:
  34. integer nc,ncmax
  35. real*8 ln
  36. real*8 x,fpp,ds,c0,f
  37. real*8 fdt
  38. integer NTMP
  39. parameter(NTMP=NLAG2+1)
  40. c----
  41. c... Executable code
  42. c... To get close approch needed to take lots of iterations if alpha<0
  43. if(alpha.lt.0.0) then
  44. ncmax = NLAG2
  45. else
  46. ncmax = NLAG2
  47. endif
  48. ln = 5.0
  49. c... start laguere's method
  50. do nc =0,ncmax
  51. x = s*s*alpha
  52. call drift_kepu_stumpff(x,c0,c1,c2,c3)
  53. c1 = c1*s
  54. c2 = c2*s*s
  55. c3 = c3*s*s*s
  56. f = r0*c1 + u*c2 + mu*c3 - dt
  57. fp = r0*c0 + u*c1 + mu*c2
  58. fpp = (-40.0*alpha + mu)*c1 + u*c0
  59. ds = - ln*f/(fp + dsign(1.d0,fp)*sqrt(abs((ln - 1.0)*
  60. & (ln - 1.0)*fp*fp - (ln - 1.0)*ln*f*fpp)))
  61. s = s + ds
  62. fdt = f/dt
  63. c.. quartic convergence
  64. if( fdt*fdt.lt.DANBYB*DANBYB) then
  65. iflg = 0
  66. return
  67. endif
  68. c... Laguerre's method succeeded
  69. enddo
  70. iflg = 2
  71. return
  72. end ! drift_kepu_leg
  73. c-----------------------------------------------------------------------