Nbody6
 All Files Functions Variables
hivel.f
Go to the documentation of this file.
1  SUBROUTINE hivel(IH)
2 *
3 *
4 * High-velocity particle search.
5 * ------------------------------
6 *
7  include 'common6.h'
8 *
9 *
10 * Copy membership and add 1 for analogy with HARP/GRAPE.
11  nhi = listv(1) + 1
12 *
13 * Specify square velocity limit in terms of current state.
14  vmax2 = 16.0*eclose
15 *
16 * Check for removal of distant high-velocity particle.
17  IF (ih.LT.0) THEN
18  1 lh = 0
19  DO 2 l = 2,nhi
20  i = listv(l)
21  vi2 = x0dot(1,i)**2 + x0dot(2,i)**2 + x0dot(3,i)**2
22  ri2 = (x(1,i) - rdens(1))**2 + (x(2,i) - rdens(2))**2 +
23  & (x(3,i) - rdens(3))**2
24 * Save index of fast particle outside 3*<R> or VI < VMAX/4.
25  IF (ri2.GT.9.0*rscale**2.OR.vi2.LT.vmax2/16.0) THEN
26  lh = l
27  li = i
28  rl2 = ri2
29  vl2 = vi2
30  END IF
31  2 CONTINUE
32 * Reduce membership and remove any distant member from the list.
33  IF (lh.GT.0) THEN
34  WRITE (29,3) time+toff, li, name(li), sqrt(rl2),
35  & sqrt(vl2)
36  3 FORMAT (' HIVEL REMOVE T I NAM R V ',f12.4,2i6,2f6.1)
37  CALL flush(29)
38  nhi = nhi - 1
39  listv(1) = listv(1) - 1
40  DO 4 l = lh,nhi
41  listv(l) = listv(l+1)
42  4 CONTINUE
43  go to 1
44  END IF
45  END IF
46 *
47 * Set index to known neutron star or terminated KS/chain.
48  IF (ih.GT.0) THEN
49  i1 = ih
50  i2 = ih
51  ELSE
52 * Include two first single particles or up to five chain members.
53  i1 = ifirst
54  i2 = ifirst + 1
55  IF (iphase.EQ.8) THEN
56  i2 = ifirst + 4
57 * Search all particles after escaper removal (defined by IPHASE = -1).
58  ELSE IF (ih.EQ.0.AND.iphase.EQ.-1) THEN
59  i2 = ntot
60  nhi = 1
61  listv(1) = 0
62  ELSE IF (iphase.EQ.1) THEN
63 * See whether the first few locations may have been exchanged.
64  DO 5 l = 2,nhi
65  IF (listv(l).LT.ifirst + 3) THEN
66  i2 = ntot
67  END IF
68  5 CONTINUE
69  END IF
70  END IF
71 *
72 * Add any new high-velocity particles (save F**2 > N & STEP < DTMIN).
73  nhv = 0
74  DO 10 i = i1,i2
75  fi2 = f(1,i)**2 + f(2,i)**2 + f(3,i)**2
76  vi2 = x0dot(1,i)**2 + x0dot(2,i)**2 + x0dot(3,i)**2
77  ri2 = (x(1,i) - rdens(1))**2 + (x(2,i) - rdens(2))**2 +
78  & (x(3,i) - rdens(3))**2
79 * Form a list of recently ejected candidates.
80  IF (fi2.GT.float(n).OR.step(i).LT.dtmin.OR.
81  & stepr(i).LT.20.0*dtmin) THEN
82  IF (vi2.GT.vmax2) THEN
83  nhv = nhv + 1
84  jlist(nhv) = i
85  END IF
86  go to 10
87  END IF
88 * Include all VMAX2 members inside 2*RSCALE or with negative velocity.
89  rd = x(1,i)*xdot(1,i) + x(2,i)*xdot(2,i) + x(3,i)*xdot(3,i)
90  IF (vi2.GT.vmax2.AND.(ri2.LT.4.0*rscale**2.OR.rd.LT.0.)) THEN
91  DO 8 l = 2,nhi
92  IF (i.EQ.listv(l)) go to 10
93  8 CONTINUE
94 * Check maximum membership and possible ghost particle.
95  IF (nhi.GE.mlv.OR.step(i).GT.1.0) go to 10
96  nhi = nhi + 1
97  listv(1) = listv(1) + 1
98  nfast = nfast + 1
99  listv(nhi) = i
100  WRITE (29,9) time+toff, nhi-1, i, name(i), kstar(i),
101  & sqrt(vi2), sqrt(ri2), step(i)
102  9 FORMAT (' HIVEL ADD T NHI I NM K* VI R DT ',
103  & f12.4,i4,2i6,i4,2f6.2,1p,e10.2)
104  CALL flush(29)
105  END IF
106  10 CONTINUE
107 *
108 * Consider single fast particle or hyperbolic two-body motion.
109  IF ((nhv.EQ.1.OR.nhv.EQ.2).AND.nhi.LE.mlv-nhv) THEN
110 * Compare any candidates with existing members.
111  DO 20 k = 1,nhv
112  DO 15 l = 2,nhi
113  IF (jlist(k).EQ.listv(l)) go to 30
114  15 CONTINUE
115  20 CONTINUE
116  i1 = jlist(1)
117 * Include single particles without further tests.
118  IF (nhv.EQ.1) THEN
119  nhi = nhi + 1
120  listv(1) = listv(1) + 1
121  nfast = nfast + 1
122  listv(nhi) = i1
123  ri2 = (x(1,i1) - rdens(1))**2 + (x(2,i1) - rdens(2))**2 +
124  & (x(3,i1) - rdens(3))**2
125  vi2 = x0dot(1,i1)**2 + x0dot(2,i1)**2 + x0dot(3,i1)**2
126  WRITE (29,22) ttot, nhi-1, name(i1), iphase, sqrt(vi2),
127  & sqrt(ri2), step(i1)
128  22 FORMAT (' HIVEL ADD T NHI NM IPH VI R DT ',
129  & f12.4,i4,i6,i4,2f6.2,1p,e10.2)
130  go to 30
131  END IF
132 * Evaluate two-body energy.
133  i2 = jlist(2)
134  rij2 = 0.0
135  vij2 = 0.0
136  rdot = 0.0
137  DO 25 k = 1,3
138  rij2 = rij2 + (x(k,i1) - x(k,i2))**2
139  vij2 = vij2 + (xdot(k,i1) - xdot(k,i2))**2
140  rdot = rdot + (x(k,i1) - x(k,i2))*(xdot(k,i1)-xdot(k,i2))
141  25 CONTINUE
142  rij = sqrt(rij2)
143  semi = 2.0/rij - vij2/(body(i1) + body(i2))
144 * Accept outwards hyperbolic motion arising from recent interaction.
145  IF (semi.LT.0.0.AND.rij.LT.10.0*rmin.AND.rdot.GT.0.0) THEN
146  nhi = nhi + 1
147  listv(nhi) = i1
148  nhi = nhi + 1
149  listv(nhi) = i2
150  listv(1) = listv(1) + 2
151  nfast = nfast + 2
152  WRITE (29,28) ttot, nhi-1, name(i1), name(i2), iphase, rij
153  28 FORMAT (' HIVEL ADD T NHI NM IPH RIJ ',
154  & f12.4,i4,2i6,i4,1p,e10.2)
155  END IF
156  END IF
157 *
158  30 CONTINUE
159 * Increase counter if loop is over all particles.
160 * IF (I2.EQ.NTOT) THEN
161 * NHIVEL = NHIVEL + 1
162 * END IF
163 *
164  RETURN
165 *
166  END