anal_jacobi_write.f 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. c*************************************************************************
  2. c ANAL_JACOBI_WRITE.F
  3. c*************************************************************************
  4. c Writes the mean and maximum absolute value of the change in jacobi
  5. c to the screen as a function of time. Writes the value of the first 10
  6. c test particles to a file called jacobi.out (unit=iu)
  7. c
  8. c Input:
  9. c t ==> current time
  10. c nbod ==> number of massive bodies (int scalar)
  11. c ntp ==> number of tp (int scalar)
  12. c mass ==> mass of bodies (real array)
  13. c xh,yh,zh ==> current position in helio coord
  14. c (real arrays)
  15. c vxh,vyh,vzh ==> current velocity in helio coord
  16. c (real arrays)
  17. c xht,yht,zht ==> current tp position in helio coord
  18. c (real arrays)
  19. c vxht,vyht,vzht ==> current tp velocity in helio coord
  20. c (real arrays)
  21. c istat ==> status of the test paricles
  22. c (integer array)
  23. c istat(i) = 0 ==> active: = 1 not
  24. c NOTE: it is really a 2d array but
  25. c ipl ==> Planet to take jacobi with respect to
  26. c iu ==> unit to write to
  27. c fopenstat ==> The status flag for the open
  28. c statements of the output files.
  29. c (character*80)
  30. c
  31. c Remarks: If the particle is not active a value of -100 is written out
  32. c Authors: Hal Levison
  33. c Date: 3/4/93
  34. c Last revision: 10/3/96
  35. subroutine anal_jacobi_write(t,nbod,ntp,mass,xh,yh,zh,vxh,
  36. & vyh,vzh,xht,yht,zht,vxht,vyht,vzht,istat,ipl,iu,fopenstat)
  37. include '../swift.inc'
  38. c... Inputs:
  39. integer nbod,ntp,ipl,iu
  40. integer istat(ntp)
  41. real*8 mass(nbod),t
  42. real*8 xh(nbod),yh(nbod),zh(nbod)
  43. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  44. real*8 xht(ntp),yht(ntp),zht(ntp)
  45. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  46. character*80 fopenstat
  47. c... Internals
  48. integer i1st,i,icnt,nw
  49. real*8 xb(NPLMAX),yb(NPLMAX),zb(NPLMAX)
  50. real*8 vxb(NPLMAX),vyb(NPLMAX),vzb(NPLMAX)
  51. real*8 xbt(NTPMAX),ybt(NTPMAX),zbt(NTPMAX)
  52. real*8 vxbt(NTPMAX),vybt(NTPMAX),vzbt(NTPMAX)
  53. real*8 jac,jac0(NTPMAX),djmean,djmax,dj(NTPMAX)
  54. real*8 gmsum,energy,aplh,omega,fac
  55. real*8 omegax,omegay,omegaz,msys
  56. data i1st/0/
  57. save i1st,jac0
  58. c----
  59. c... Executable code
  60. nw = min0(ntp,10)
  61. c... Compute ang. mom. vector for Sun-planet relative orbit
  62. gmsum = mass(1) + mass(ipl)
  63. energy = 0.5d0*(vxh(ipl)**2 + vyh(ipl)**2 + vzh(ipl)**2)
  64. energy = energy - gmsum/sqrt(xh(ipl)**2 + yh(ipl)**2 + zh(ipl)**2)
  65. aplh = -0.5d0*gmsum/energy
  66. omega = sqrt(gmsum/(aplh**3))
  67. omegax = yh(ipl)*vzh(ipl) - zh(ipl)*vyh(ipl)
  68. omegay = zh(ipl)*vxh(ipl) - xh(ipl)*vzh(ipl)
  69. omegaz = xh(ipl)*vyh(ipl) - yh(ipl)*vxh(ipl)
  70. fac = omega/sqrt(omegax**2 + omegay**2 + omegaz**2)
  71. omegax = fac*omegax
  72. omegay = fac*omegay
  73. omegaz = fac*omegaz
  74. c... put things in bary
  75. call coord_h2b(nbod,mass,xh,yh,zh,vxh,vyh,vzh,
  76. & xb,yb,zb,vxb,vyb,vzb,msys)
  77. call coord_h2b_tp(ntp,xht,yht,zht,vxht,vyht,vzht,
  78. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  79. & xbt,ybt,zbt,vxbt,vybt,vzbt)
  80. if(i1st.eq.0) then
  81. do i=1,ntp
  82. call anal_jacobi(mass(1),mass(ipl),omegax,omegay,omegaz,
  83. & xbt(i),ybt(i),zbt(i),vxbt(i),vybt(i),vzbt(i),xb(1),
  84. & yb(1),zb(1),xb(ipl),yb(ipl),zb(ipl),jac0(i))
  85. dj(i) = 0.0
  86. enddo
  87. call io_jacobi_write(i1st,t,jac0,dj,nw,iu,fopenstat)
  88. i1st = 1
  89. else
  90. icnt = 0
  91. djmean = 0.0
  92. djmax = 0.0
  93. do i=1,ntp
  94. if(istat(i).eq.0) then
  95. call anal_jacobi(mass(1),mass(ipl),omegax,omegay,omegaz,
  96. & xbt(i),ybt(i),zbt(i),vxbt(i),vybt(i),vzbt(i),xb(1),
  97. & yb(1),zb(1),xb(ipl),yb(ipl),zb(ipl),jac)
  98. icnt = icnt + 1
  99. dj(i) = jac/jac0(i) - 1.d0
  100. djmean = djmean + abs(dj(i))
  101. djmax = dmax1(djmax,abs(dj(i)))
  102. else
  103. dj(i) = -100.0
  104. endif
  105. enddo
  106. djmean = djmean/float(icnt)
  107. write(*,1) djmean,djmax
  108. 1 format(5x,'mean |dj/j|, max |dj/j|,',2(2x,1p1e12.5))
  109. call io_jacobi_write(i1st,t,jac0,dj,nw,iu,fopenstat)
  110. endif
  111. return
  112. end ! anal_jacobi_write
  113. c-------------------------------------------------------------------------