8 parameter(nmx=10,nmx4=4*nmx)
9 common/close/ rij(4,4),rcoll4,qperi4,size4(4),ecoll4,ip(4)
10 common/ccoll2/ qk(nmx4),pk(nmx4),rik(nmx,nmx),
SIZE(nmx),vstar1,
11 & ecoll1,rcoll,qperi,istar(nmx),icoll,isync,ndiss1
13 REAL*8 cm(6),a0(3),a2(3)
34 dt = min(tblock-tprev,dtmin)
35 IF (dt.GT.2.4e-11)
THEN
38 time = tprev + int((time2 + dt)/dtn)*dtn
39 time = min(tblock,time)
41 time = min(t0(i) + step(i),tblock)
50 semi = -0.5*body(i)/h(kspair)
61 rij2 = rij2 + (x(k,i) - x(k,j))**2
62 vij2 = vij2 + (xdot(k,i) - xdot(k,j))**2
63 rdot = rdot + (x(k,i) - x(k,j))*(xdot(k,i) -xdot(k,j))
68 a0(k) = (x(k1,i1)-x(k1,i2))*(xdot(k2,i1)-xdot(k2,i2))
69 & - (x(k2,i1)-x(k2,i2))*(xdot(k1,i1)-xdot(k1,i2))
70 a2(k) = (x(k1,j) - x(k1,i))*(xdot(k2,j) - xdot(k2,i))
71 & - (x(k2,j) - x(k2,i))*(xdot(k1,j) - xdot(k1,i))
74 a1a2 = a1a2 + a0(k)*a2(k)
77 a1 = 2.0/rip - vij2/(body(i) + body(j))
79 ecc2 = (1.0 - rip/a1)**2 +
80 & rdot**2/(a1*(body(i) + body(j)))
81 IF (1.0/a1.GT.0.5/rmin)
THEN
84 ecc = 1.0 - r(kspair)/semi
87 ga = 2.0*body(j)*(ra/rp1)**3/body(i)
89 fac = a1a2/sqrt(a12*a22)
90 angle = 360.0*acos(fac)/twopi
91 WRITE (6,4) kspair, name(j), h(kspair), ecc, semi,
92 & a1, rp1, ga, ecc1, sr, angle
93 4
FORMAT (
' HIERARCHY: KS NMJ H E A0 A1 RP GA E1 SR ',
94 &
'IN',2i6,f7.0,f9.5,1p,4e9.1,0p,f6.2,f6.1,f7.1)
106 IF (rip.LT.0.5*rmin.AND.j.LE.n)
THEN
108 IF (rip.GT.rip0) go to 5
118 IF (rx.LT.20.0*rmin)
THEN
119 WRITE (6,200) name(jx), eccx, rx, semix*(1.0 - eccx),
121 200
FORMAT (
' PERTURBER: NM E1 RX PM RD A0 ',
126 nam1 = name(2*kspair-1)
127 nam2 = name(2*kspair)
130 IF (listd(k).EQ.nam1.OR.listd(k).EQ.nam2)
THEN
131 WRITE (6,6) nam1, nam2, listd(k), k
132 6
FORMAT (
' KS REMNANT: NAM LISTD K ',3i6,i4)
137 IF (jcl.GT.0) CALL
xvpred(jcl,-1)
140 semi = -0.5*body(n+kspair)/h(kspair)
141 IF (r(kspair).GT.semi.AND.semi.GT.0.0)
THEN
152 IF (h(kspair).GT.0.0) vinf = sqrt(2.0*h(kspair))*vstar
153 ecc = 1.0 - r(kspair)/semi
156 IF (kz(19).GE.3)
THEN
160 IF (k1.LT.0.OR.k2.LT.0)
THEN
162 IF (max(k1,k2).EQ.0) icase = -1
163 IF (max(k1,k2).GT.0) icase = max(k1,k2)
169 CALL
expel(i1,i2,icase)
170 IF (icase.LT.0) go to 100
180 CALL
dtchck(time,step(jcl),dtk(40))
182 x0dot(k,jcl) = xdot(k,jcl)
188 IF(kz(8).GT.3.AND.max(kstar(i1),kstar(i2)).GE.10)
THEN
189 IF(kstar(i1).LE.12)
THEN
190 CALL
degen(kspair,kspair,5)
200 eb = body(i1)*body(i2)*h(kspair)/body(i)
202 IF (h(kspair).GT.0.0)
THEN
210 semi = -0.5*body(i)/h(kspair)
211 tk = days*semi*sqrt(semi/body(i))
212 CALL
dtchck(time,step(i1),dtk(40))
218 dmin2 = min(dmin2,rcoll)
225 IF (nsys.GT.4) i5 = jlist(5)
229 ecc = 1.0 + 2.0*ebs*dminc/(body(i1)*body(i2))
230 ecc = max(ecc,0.001d0)
232 hi = ebs*(body(i1) + body(i2))/(body(i1)*body(i2))
233 vinf = sqrt(2.0*hi)*vstar
240 IF (ich.GT.0.AND.kz(19).GE.3)
THEN
245 WRITE (86,9) tphys, name(i1), name(i2), kstar(i1),
246 & kstar(i2), zm1, zm2, r1, r2, dminc*su, ecc
247 9
FORMAT (
' COLL: TPH NAM K* M R* QP E ',
248 & f8.1,2i7,2i4,2f6.2,3f7.1,f9.5)
264 IF (body(i1).EQ.0.0d0.OR.body(i2).EQ.0.0d0)
THEN
266 IF (body(i1) + body(i2).EQ.0.0d0)
THEN
267 ri = sqrt(x(1,i1)**2 + x(2,i1)**2 +x(3,i1)**2)
268 vi = sqrt(xdot(1,i1)**2 + xdot(2,i1)**2 +
271 CALL
dtchck(time,dtmax,dtk(40))
272 WRITE (6,10) kstar(i1), kstar(i2), dtmax
273 10
FORMAT (
' MASSLESS CM K* DTX ',2i4,1p,e10.2)
279 IF (body(i1).EQ.0.0d0) jlist(1) = i2
281 jlist(l) = jlist(l+1)
295 IF (kz(19).GE.3)
THEN
302 zm = body(i1) + body(i2)
304 cm(k) = (body(i1)*x(k,i1) + body(i2)*x(k,i2))/zm
305 cm(k+3) = (body(i1)*xdot(k,i1) + body(i2)*xdot(k,i2))/zm
313 CALL
dtchck(time,step(j),dtk(40))
318 IF (body(i2).GT.body(i1))
THEN
329 jpert(l) = list(l+1,i1)
335 IF (i2.EQ.n) jpert(1) = n + 1
336 CALL
nbpot(2,nnb,pot1)
340 jpert(l-2) = jlist(l)
343 CALL
nbpot(2,np,pot1)
345 IF (dm.GT.0.0d0)
THEN
349 IF (j.EQ.i1.OR.j.EQ.i2) go to 18
352 rij2 = rij2 + (cm(k) - x(k,j))**2
354 egrav = egrav - dm*body(j)/sqrt(rij2)
356 WRITE (6,19) nsys, egrav, egrav - eg0
357 19
FORMAT (
' CHAIN/TRIPLE MASS LOSS NSYS EGRAV DEGR ',
367 spin(i1) = (spin(i1) + spin(i2))*(1.0 - dm/zm)
368 t0(i2) = tadj + dtadj
369 IF (kz(23).EQ.0.OR.rtide.GT.1000.0*rscale) t0(i2) = 1.0d+10
371 CALL
dtchck(time,dtmax,dtk(40))
373 ri = sqrt((x(1,i2) - rdens(1))**2 + (x(2,i2) - rdens(2))**2
374 & + (x(3,i2) - rdens(3))**2)
375 vi = sqrt(xdot(1,i2)**2 + xdot(2,i2)**2 + xdot(3,i2)**2)
383 x0dot(k,i1) = cm(k+3)
385 x0(k,i2) = 1000.0*rscale*(x(k,i2) - rdens(k))/ri
387 x0dot(k,i2) = sqrt(0.004*zmass/rscale)*xdot(k,i2)/vi
388 xdot(k,i2) = x0dot(k,i2)
396 IF (kstar(i1).GE.13.AND.kz(28).GT.0)
THEN
399 IF (kstar(i2).GE.13.AND.kz(28).GT.0)
THEN
408 CALL
nbpot(1,nnb,pot2)
410 CALL
nbpot(1,np,pot2)
429 IF (list(1,j).GT.nnb)
THEN
437 jpert(l) = list(l+1,icm)
447 rsi = rscale*(10.0/float(n - npairs))**0.3333
452 IF (kz(19).GE.3.AND.dm.GT.0.0d0)
THEN
457 ilist(l) = list(l,i1)
462 body(i1) = max(body(i1),0.0d0)
471 IF (dm*zmbar.GT.0.1)
THEN
476 IF (nsys.EQ.2) nnb2 = nnb2 - 1
482 x0dot(k,j) = xdot(k,j)
493 32
IF (kstar(i1).EQ.15)
THEN
494 t0(i1) = tadj + dtadj
497 x0(k,i1) = 1000.0*rscale*x(k,i1)/ri
499 x0dot(k,i1) = sqrt(0.004*zmass/rscale)*xdot(k,i2)/vi
500 xdot(k,i1) = x0dot(k,i1)
507 IF (body(i2).EQ.0.0d0.AND.i1.NE.i2)
THEN
522 WRITE (6,38) name(i1)
523 38
FORMAT (
' DANGER! ZERO MASS IN CHAIN NAME',i7)
529 IF (nsys.EQ.2) go to 40
530 IF (nsys.EQ.3) go to 45
533 IF (jlist(7).LT.0)
THEN
542 40
IF (nsys.EQ.2)
THEN
552 CALL
fpoly1(icomp,icomp,0)
553 CALL
fpoly2(icomp,icomp,0)
557 WRITE (6,42) name(i5), step(i5)
558 42
FORMAT (
' 5-CHAIN! NM DT ',i7,1p,e10.2)
560 IF (nsys.EQ.0) go to 95
561 IF (nsys.LE.2) go to 80
564 45
IF (ich.GT.0)
THEN
570 jlist(l) = jlist(l+1)
576 ELSE IF (nsys.EQ.3)
THEN
579 dmin3 = min(dmin3,rcoll4)
585 dmin4 = min(dmin4,rcoll4)
598 80 ecoll = ecoll + eb
599 e(10) = e(10) + eb + dp
603 IF (first.AND.(iqcoll.EQ.3.OR.kstari.GE.10))
THEN
604 OPEN (unit=26,
status=
'NEW',form=
'FORMATTED',file=
'COAL2')
608 WRITE (26,82) rbar, bodym*zmbar, body1*zmbar, tscale,
610 82
FORMAT (/,4x,
'MODEL: RBAR =',f5.1,
' <M> =',f6.2,
611 &
' M1 =',f6.1,
' TSCALE =',f6.2,
612 &
' NB =',i4,
' N0 =',i6,//)
615 84
FORMAT (
' TIME NAME NAME K1 K2 IQ M1 M2',
616 &
' DM R1 R2 r/Rc R ECC P',/)
620 IF (iqcoll.EQ.3.OR.kstari.GE.10)
THEN
621 npop(8) = npop(8) + 1
623 WRITE (6,85) iqcoll, name1, name2, zm*smu, rcoll, eb, dp, ecc
624 85
FORMAT (/,
' BINARY COAL IQCOLL =',i3,
' NAME =',2i6,
625 &
' M =',f6.2,
' RCOLL =',1p,e8.1,
' EB =',e9.1,
626 &
' DP =',e9.1,
' E =',0p,f8.4)
630 WRITE (26,86) ttot, name1, name2, kstar(i1), kstar(i2),
631 & iqcoll, zm1, zm2, dm*zmbar, r1, r2, ri/rc,
633 86
FORMAT (1x,f7.1,2i6,3i4,3f5.1,2f7.2,f6.2,f7.2,f9.5,1p,e9.1)
638 npop(8) = npop(8) + 1
641 WRITE (6,90) which1, nsys, name1, name2, zm*smu, rcoll, eb,
643 90
FORMAT (/,a8,
'COLLISION NSYS =',i3,
' NAME =',2i6,
644 &
' M =',f6.2,
' RCOLL =',1p,e8.1,
' EB =',e9.1,
645 &
' VINF =',0p,f5.1,
' ECC =',f9.5,
' DP =',1p,e9.1)
651 100
IF (ich.GT.0)
THEN
652 nsub = max(nsub - 1,0)