rmvs2_interp.f 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. c*************************************************************************
  2. c RMVS2_INTERP.F
  3. c*************************************************************************
  4. c This subroutine interpolates between two kepler orbits.
  5. c
  6. c Input:
  7. c nbod ==> number of massive bodies
  8. c (int scalar)
  9. c xbeg,ybeg,zbeg ==> initial planet position in helio
  10. c (real arrays)
  11. c vxbeg,vybeg,vzbeg ==> initial planet vel in helio
  12. c (real arrays)
  13. c xend,yend,zend ==> final planet position in helio
  14. c (real arrays)
  15. c vxend,vyend,vzend ==> final planet position in helio
  16. c (real arrays)
  17. c dt ==> time step (real sclar)
  18. c msun ==> mass of sun (real sclar)
  19. c Output:
  20. c xtmp,ytmp,ztmp ==> position of planet wrt time
  21. c for inner region
  22. c (2d real arrays)
  23. c xtmpo,ytmpo,ztmpo ==> position of planet wrt time
  24. c for outer region
  25. c (2d real arrays)
  26. c
  27. c
  28. c Remarks:
  29. c Authors: Hal Levison
  30. c Date: 8/25/94
  31. c Last revision:
  32. subroutine rmvs2_interp(nbod,xbeg,ybeg,zbeg,vxbeg,vybeg,
  33. & vzbeg,xend,yend,zend,vxend,vyend,vzend,dt,msun,
  34. & xtmp,ytmp,ztmp,xtmpo,ytmpo,ztmpo)
  35. include '../swift.inc'
  36. include '../rmvs/rmvs.inc'
  37. c... Inputs Only:
  38. integer nbod
  39. real*8 dt,msun
  40. real*8 xbeg(NPLMAX),ybeg(NPLMAX),zbeg(NPLMAX)
  41. real*8 vxbeg(NPLMAX),vybeg(NPLMAX),vzbeg(NPLMAX)
  42. real*8 xend(NPLMAX),yend(NPLMAX),zend(NPLMAX)
  43. real*8 vxend(NPLMAX),vyend(NPLMAX),vzend(NPLMAX)
  44. c... Outputs:
  45. real*8 xtmp(NPLMAX,NTPENC),ytmp(NPLMAX,NTPENC)
  46. real*8 ztmp(NPLMAX,NTPENC)
  47. real*8 xtmpo(NPLMAX,NTENC),ytmpo(NPLMAX,NTENC)
  48. real*8 ztmpo(NPLMAX,NTENC)
  49. c... Internals
  50. integer i,iflg,ib,is,ic
  51. real*8 xc2(NPLMAX),yc2(NPLMAX),zc2(NPLMAX)
  52. real*8 vxc2(NPLMAX),vyc2(NPLMAX),vzc2(NPLMAX)
  53. real*8 xc1(NPLMAX),yc1(NPLMAX),zc1(NPLMAX)
  54. real*8 vxc1(NPLMAX),vyc1(NPLMAX),vzc1(NPLMAX)
  55. real*8 dti,dtb,frac,onemf
  56. c----
  57. c... Executable code
  58. dti = dt/float(NTPENC)
  59. dtb = -1.0d0*dt
  60. c... move the end positions to beginning
  61. do i=2,nbod
  62. xc1(i) = xbeg(i)
  63. yc1(i) = ybeg(i)
  64. zc1(i) = zbeg(i)
  65. vxc1(i) = vxbeg(i)
  66. vyc1(i) = vybeg(i)
  67. vzc1(i) = vzbeg(i)
  68. xc2(i) = xend(i)
  69. yc2(i) = yend(i)
  70. zc2(i) = zend(i)
  71. vxc2(i) = vxend(i)
  72. vyc2(i) = vyend(i)
  73. vzc2(i) = vzend(i)
  74. call drift_one(msun,xc2(i),yc2(i),zc2(i),
  75. & vxc2(i),vyc2(i),vzc2(i),dtb,iflg)
  76. if(iflg.ne.0) then
  77. write(*,*) ' Planet ',i,' is lost in rmvs2_interp !!!!!!!!!'
  78. write(*,*) msun,dtb
  79. write(*,*) xc2(i),yc2(i),zc2(i)
  80. write(*,*) vxc2(i),vyc2(i),vzc2(i)
  81. write(*,*) ' STOPPING '
  82. call util_exit(1)
  83. endif
  84. enddo
  85. do i=2,nbod
  86. ic = 0
  87. do ib = 1,NTENC
  88. do is=1,NTPHENC
  89. ic = ic + 1
  90. call drift_one(msun,xc1(i),yc1(i),zc1(i),
  91. & vxc1(i),vyc1(i),vzc1(i),dti,iflg)
  92. if(iflg.ne.0) then
  93. write(*,*) ' Planet ',i,' is lost in rmvs2_interp !!!'
  94. write(*,*) msun,dtb
  95. write(*,*) xc1(i),yc1(i),zc1(i)
  96. write(*,*) vxc1(i),vyc1(i),vzc1(i)
  97. write(*,*) ' STOPPING '
  98. call util_exit(1)
  99. endif
  100. call drift_one(msun,xc2(i),yc2(i),zc2(i),
  101. & vxc2(i),vyc2(i),vzc2(i),dti,iflg)
  102. if(iflg.ne.0) then
  103. write(*,*) ' Planet ',i,' is lost in rmvs2_interp !!!'
  104. write(*,*) msun,dtb
  105. write(*,*) xc2(i),yc2(i),zc2(i)
  106. write(*,*) vxc2(i),vyc2(i),vzc2(i)
  107. write(*,*) ' STOPPING '
  108. call util_exit(1)
  109. endif
  110. frac = float(ic)/float(NTPENC)
  111. onemf = 1.0d0 - frac
  112. xtmp(i,ic) = onemf*xc1(i) + frac*xc2(i)
  113. ytmp(i,ic) = onemf*yc1(i) + frac*yc2(i)
  114. ztmp(i,ic) = onemf*zc1(i) + frac*zc2(i)
  115. enddo
  116. frac = float(ib)/float(NTENC)
  117. onemf = 1.0d0 - frac
  118. xtmpo(i,ib) = onemf*xc1(i) + frac*xc2(i)
  119. ytmpo(i,ib) = onemf*yc1(i) + frac*yc2(i)
  120. ztmpo(i,ib) = onemf*zc1(i) + frac*zc2(i)
  121. enddo
  122. enddo
  123. c... put zeros in position 1
  124. do ib = 1,NTENC
  125. xtmpo(1,ib) = 0.0d0
  126. ytmpo(1,ib) = 0.0d0
  127. ztmpo(1,ib) = 0.0d0
  128. enddo
  129. do is = 1,NTPENC
  130. xtmp(1,is) = 0.0d0
  131. ytmp(1,is) = 0.0d0
  132. ztmp(1,is) = 0.0d0
  133. enddo
  134. return
  135. end ! rmvs2_interp.f
  136. c-----------------------------------------------------------------------