discard.f 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. c*************************************************************************
  2. c DISCARD.F
  3. c*************************************************************************
  4. c This subroutine checks to see if a partical should be discarded because
  5. c of its position or becuase it becomes unbound
  6. c
  7. c Input:
  8. c time ==> current time (real scalar)
  9. c dt ==> time step (real scalar)
  10. c nbod ==> number of massive bodies (int scalar)
  11. c ntp ==> number of massive bodies (int scalar)
  12. c mass ==> mass of bodies (real array)
  13. c xh,yh,zh ==> position in helio coord
  14. c (real arrays)
  15. c vxh,vyh,vzh ==> pl vel in helio coord
  16. c (real arrays)
  17. c xht,yht,zht ==> part position in helio coord
  18. c (real arrays)
  19. c vxht,vyht,vzht ==> velocity in helio coord
  20. c (real arrays)
  21. c rmin,rmax ==> maximum and min distance from Sun
  22. c if <0 then don't check
  23. c (real scalar)
  24. c rmaxu ==> maximum distance from Sun in not bound
  25. c if <0 then don't check
  26. c (real scalar)
  27. c qmin ==> Smallest perihelion distance
  28. c if <0 then don't check
  29. c (real scalar)
  30. c lclose ==> .true. --> discard particle if it gets
  31. c too close to a planet. Read in that
  32. c distance in io_init_pl
  33. c (logical*2 scalar)
  34. c rplsq ==> min distance^2 that a tp can get from pl
  35. c (real array)
  36. c istat ==> status of the test paricles
  37. c (2d integer array)
  38. c istat(i,1) = 0 ==> active: = 1 not
  39. c rstat ==> status of the test paricles
  40. c (2d real array)
  41. c rstat(i,1) closest approach to a planet
  42. c
  43. c Output:
  44. c istat ==> status of the test paricles
  45. c (2d integer array)
  46. c istat(i,1) = 1 if discarded
  47. c istat(i,2) = -2 -> a<0 & r_helio>rmaxu
  48. c istat(i,2) = -3 r_helio>rmax
  49. c istat(i,2) = -4 q<qmin
  50. c istat(i,2) = 1 r_helio<rmin
  51. c istat(i,2) = n too close to planet n
  52. c rstat ==> status of the test paricles
  53. c (2d real array)
  54. c rstat(i,2) closest approach to a planet
  55. c as determined by encounter routines.
  56. c
  57. c Output:
  58. c istat ==> status of the test paricles
  59. c (2d integer array)
  60. c istat(i,1) = 1 if discarded
  61. c istat(i,2) = n too close to planet n
  62. c rstat ==> status of the test paricles
  63. c (2d real array)
  64. c rstat(i,1) time of discard.
  65. c
  66. c Remarks:
  67. c Authors: Hal Levison
  68. c Date: 3/2/93
  69. c Last revision: 1/20/97
  70. subroutine discard(time,dt,nbod,ntp,mass,xh,yh,zh,vxh,
  71. & vyh,vzh,xht,yht,zht,vxht,vyht,vzht,rmin,rmax,rmaxu,
  72. & qmin,lclose,rplsq,istat,rstat)
  73. include '../swift.inc'
  74. c... Inputs:
  75. integer nbod,ntp
  76. real*8 mass(nbod),xh(nbod),yh(nbod),zh(nbod),time,rplsq(NPLMAX)
  77. real*8 vxh(nbod),vyh(nbod),vzh(nbod)
  78. real*8 xht(ntp),yht(ntp),zht(ntp)
  79. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  80. real*8 rmin,rmax,rmaxu,dt,qmin
  81. logical*2 lclose
  82. c... Input and Output
  83. integer istat(NTPMAX,NSTAT)
  84. real*8 rstat(NTPMAX,NSTATR)
  85. c... Internals
  86. real*8 xb(NPLMAX),yb(NPLMAX),zb(NPLMAX)
  87. real*8 vxb(NPLMAX),vyb(NPLMAX),vzb(NPLMAX)
  88. real*8 xbt(NTPMAX),ybt(NTPMAX),zbt(NTPMAX)
  89. real*8 vxbt(NTPMAX),vybt(NTPMAX),vzbt(NTPMAX),msys
  90. c-----
  91. c... Executable code
  92. if( (rmin.ge.0.0) .or. (rmax.ge.0.0) .or. (rmaxu.ge.0.0) ) then
  93. call coord_h2b(nbod,mass,xh,yh,zh,vxh,vyh,vzh,
  94. & xb,yb,zb,vxb,vyb,vzb,msys)
  95. call coord_h2b_tp(ntp,xht,yht,zht,vxht,vyht,vzht,
  96. & xb(1),yb(1),zb(1),vxb(1),vyb(1),vzb(1),
  97. & xbt,ybt,zbt,vxbt,vybt,vzbt)
  98. call discard_sun(time,ntp,msys,xht,yht,zht,xbt,ybt,zbt,
  99. & vxbt,vybt,vzbt,rmin,rmax,rmaxu,istat,rstat)
  100. endif
  101. if(qmin.ge.0.0) then
  102. call discard_peri(time,ntp,xht,yht,zht,vxht,vyht,vzht,
  103. & qmin,istat,rstat,nbod,mass,xh,yh,zh,vxh,vyh,vzh)
  104. endif
  105. if(lclose) then
  106. call discard_pl(time,dt,nbod,ntp,mass,xh,yh,zh,vxh,vyh,vzh,
  107. & xht,yht,zht,vxht,vyht,vzht,rplsq,istat,rstat)
  108. endif
  109. return
  110. end ! discard.f
  111. c-----------------------------------------------------------------------