lyap2_drift_dan.f 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. c*************************************************************************
  2. c LYAP2_DRIFT_DAN.F
  3. c*************************************************************************
  4. c This subroutine does the Danby and decides which vbles to use
  5. c
  6. c Input:
  7. c nbod ==> number of massive bodies (int scalar)
  8. c mass ==> mass of bodies (real array)
  9. c x0,y0,z0 ==> initial position in jacobi coord
  10. c (real scalar)
  11. c vx0,vy0,vz0 ==> initial position in jacobi coord
  12. c (real scalar)
  13. c dx0,dy0,dz0 ==> initial difference in position
  14. c (real scalar)
  15. c dvx0,dvy0,dvz0 ==> initial difference in velocity
  16. c (real scalar)
  17. c dt0 ==> time step
  18. c Output:
  19. c x0,y0,z0 ==> final position in jacobi coord
  20. c (real scalars)
  21. c vx0,vy0,vz0 ==> final position in jacobi coord
  22. c (real scalars)
  23. c dx0,dy0,dz0 ==> final difference in position
  24. c (real scalar)
  25. c dvx0,dvy0,dvz0 ==> final difference in velocity
  26. c (real scalar)
  27. c iflg ==> integer flag (zero if satisfactory)
  28. c (non-zero if nonconvergence)
  29. c
  30. c Comments: Based on drift_dan.f
  31. c Authors: Hal Levison
  32. c Date: 7/11/95
  33. c Last revision:
  34. subroutine lyap2_drift_dan(mu,x0,y0,z0,vx0,vy0,vz0,dx0,
  35. & dy0,dz0,dvx0,dvy0,dvz0,dt0,iflg)
  36. include '../swift.inc'
  37. c... Inputs Only:
  38. real*8 mu,dt0
  39. c... Inputs and Outputs:
  40. real*8 x0,y0,z0
  41. real*8 vx0,vy0,vz0
  42. real*8 dx0,dy0,dz0
  43. real*8 dvx0,dvy0,dvz0
  44. c... Output
  45. integer iflg
  46. c... Internals:
  47. real*8 x,y,z,vx,vy,vz,dt
  48. real*8 sqrtmu,sn,alfa,eta,zeta,x0dx,w0dx,w0dv,r0pr,alfapr
  49. real*8 x0dv,etapr,zetapr,g3a,g2a,g1a,xpr,g0,g1pr,g2pr,g3pr
  50. real*8 rpr,fpr,gpr,dfpr,dgpr
  51. real*8 wx,wy,wz
  52. real*8 dwx0,dwy0,dwz0
  53. real*8 dwx,dwy,dwz
  54. real*8 dx,dy,dz
  55. real*8 f,g,fdot,gdot
  56. real*8 u,alpha,fp,r0,v0s,s
  57. real*8 cn1,cn2,cn3,cn4,cn5
  58. real*8 c1,c2,c3,c4,c5
  59. c----
  60. c... Executable code
  61. c... Set dt = dt0 to be sure timestep is not altered while solving
  62. c... for new coords.
  63. dt = dt0
  64. iflg = 0
  65. r0 = sqrt(x0*x0 + y0*y0 + z0*z0)
  66. v0s = vx0*vx0 + vy0*vy0 + vz0*vz0
  67. u = x0*vx0 + y0*vy0 + z0*vz0
  68. alpha = 2.0*mu/r0 - v0s
  69. call lyap2_drift_kepu(dt,r0,mu,alpha,u,fp,c1,c2,c3,c4,
  70. & c5,s,iflg)
  71. if(iflg .eq.0) then
  72. f = 1.0 - (mu/r0)*c2
  73. g = dt - mu*c3
  74. fdot = -(mu/(fp*r0))*c1
  75. gdot = 1. - (mu/fp)*c2
  76. x = x0*f + vx0*g
  77. y = y0*f + vy0*g
  78. z = z0*f + vz0*g
  79. vx = x0*fdot + vx0*gdot
  80. vy = y0*fdot + vy0*gdot
  81. vz = z0*fdot + vz0*gdot
  82. c--------------------------------------
  83. c... now do the differentials from Mikkola's code
  84. sqrtmu = sqrt(mu)
  85. wx = vx0/sqrtmu
  86. wy = vy0/sqrtmu
  87. wz = vz0/sqrtmu
  88. dwx0 = dvx0/sqrtmu
  89. dwy0 = dvy0/sqrtmu
  90. dwz0 = dvz0/sqrtmu
  91. cn1 = c1*sqrtmu
  92. cn2 = c2*mu
  93. cn3 = c3*(sqrtmu*mu)
  94. cn4 = c4*(mu**2)
  95. cn5 = c5*(sqrtmu*mu**2)
  96. sn = s*sqrtmu
  97. alfa = 2.d0/r0 - (wx**2 + wy**2 + wz**2)
  98. eta = x0*wx + y0*wy + z0*wz
  99. zeta = 1.0d0 - alfa*r0
  100. x0dx = x0*dx0 + y0*dy0 + z0*dz0
  101. x0dv = x0*dwx0 + y0*dwy0 + z0*dwz0
  102. w0dx = wx*dx0 + wy*dy0 + wz*dz0
  103. w0dv = wx*dwx0 + wy*dwy0 + wz*dwz0
  104. r0pr=x0dx/r0
  105. alfapr = -2.0d0*(r0pr/(r0**2) + w0dv)
  106. etapr = w0dx + x0dv
  107. zetapr = -alfa*r0pr - r0*alfapr
  108. g3a = 0.5d0 * (3.0d0*cn5 - sn*cn4)
  109. g2a = 0.5d0 * (2.0d0*cn4 - sn*cn3)
  110. g1a = 0.5d0 * ( cn3 - sn*cn2)
  111. xpr = -( sn*r0pr + cn2*etapr + cn3*zetapr +
  112. & (eta*g2a+zeta*g3a)*alfapr )/fp
  113. g0 = 1.d0 - alfa*cn2
  114. g1pr = g0*xpr + g1a*alfapr
  115. g2pr = cn1*xpr + g2a*alfapr
  116. g3pr = cn2*xpr + g3a*alfapr
  117. rpr = r0pr + cn1*etapr + cn2*zetapr + eta*g1pr + zeta*g2pr
  118. fpr = cn2*r0pr/r0**2 - g2pr/r0
  119. gpr = -g3pr
  120. dfpr = -g1pr/(r0*fp) + cn1*rpr/(fp*fp*r0) +
  121. & cn1*r0pr/(r0*r0*fp)
  122. dgpr = -g2pr/fp + cn2*rpr/(fp*fp)
  123. dx = f*dx0 + g*dwx0*sqrtmu + x0*fpr + wx*gpr
  124. dy = f*dy0 + g*dwy0*sqrtmu + y0*fpr + wy*gpr
  125. dz = f*dz0 + g*dwz0*sqrtmu + z0*fpr + wz*gpr
  126. dwx = fdot*dx0/sqrtmu + gdot*dwx0 + x0*dfpr + wx*dgpr
  127. dwy = fdot*dy0/sqrtmu + gdot*dwy0 + y0*dfpr + wy*dgpr
  128. dwz = fdot*dz0/sqrtmu + gdot*dwz0 + z0*dfpr + wz*dgpr
  129. dx0 = dx
  130. dy0 = dy
  131. dz0 = dz
  132. dvx0 = dwx*sqrtmu
  133. dvy0 = dwy*sqrtmu
  134. dvz0 = dwz*sqrtmu
  135. c-----------------------------------------
  136. x0 = x
  137. y0 = y
  138. z0 = z
  139. vx0 = vx
  140. vy0 = vy
  141. vz0 = vz
  142. endif
  143. return
  144. end ! lyap2_drift_dan