8 REAL*8 xorb(2),vorb(2),xrel(3),vrel(3),px(3),qx(3),
9 & bs(mmax),xs(3,mmax),vs(3,mmax)
14 READ (5,*) semi0, ecc0, ratio, range, icirc
16 WRITE (6,1) nhi, semi0, ecc0, ratio, range, icirc
17 1
FORMAT (/,12x,
'HIERARCHIES: NHI =',i4,
' A =',f9.6,
18 &
' E =',f6.2,
' RATIO =',f4.1,
' RANGE =',f6.1,
21 IF (nhi.GT.nbin0)
THEN
22 WRITE (6,2) nbin0, nhi
23 2
FORMAT (5x,
'FATAL ERROR! NBIN0 =',i4,
' NHI =',i4)
31 pi = twopi*
ran2(idum1)
32 omega = twopi*
ran2(idum1)
33 zi = 0.5*twopi*
ran2(idum1)
36 px(1) = cos(pi)*cos(omega) - sin(pi)*sin(omega)*cos(zi)
37 qx(1) =-sin(pi)*cos(omega) - cos(pi)*sin(omega)*cos(zi)
38 px(2) = cos(pi)*sin(omega) + sin(pi)*cos(omega)*cos(zi)
39 qx(2) =-sin(pi)*sin(omega) + cos(pi)*cos(omega)*cos(zi)
40 px(3) = sin(pi)*sin(zi)
41 qx(3) = cos(pi)*sin(zi)
50 xrel(k) = x(k,i1) - x(k,i2)
51 vrel(k) = xdot(k,i1) - xdot(k,i2)
52 rij2 = rij2 + xrel(k)**2
53 vij2 = vij2 + vrel(k)**2
54 rdot = rdot + xrel(k)*vrel(k)
57 zmb1 = body(i1) + body(i2)
58 a1 = 2.0/rij - vij2/zmb1
60 ecc2 = (1.0 - rij/semi1)**2 + rdot**2/(semi1*zmb1)
62 pmin = semi1*(1.0 - ecc1)
65 q0 = 0.5 + 0.4*
ran2(idum1)
66 IF (ratio.EQ.1.0) q0 = 0.5
68 body(i1) = q0*body(i1)
69 body(i2) = body(i1)*(1.0 - q0)/q0
70 zmb = body(i1) + body(i2)
82 10
IF (range.GT.0.0)
THEN
84 exp =
ran2(idum1)*log10(range)
85 semi = semi1/10.0**exp
95 pcrit =
stability(body(i1),body(i2),bs(i),ecc,ecc1,zi)
98 IF (pmin.LT.pcrit.AND.iter.LE.12.AND.semi.LT.semi0) go to 10
100 p0 = days*semi*sqrt(semi/zmb)
101 p1 = days*semi1*sqrt(semi1/zmb1)
102 WRITE (6,20) iter, ecc, ecc1, pmin, pcrit, p0, p1
103 20
FORMAT (
' HIERARCHY: IT E E1 PMIN PCRIT P0 P1 ',
107 xorb(1) = semi*(1.0 + ecc)
110 vorb(2) = sqrt(zmb*(1.0d0 - ecc)/(semi*(1.0d0 + ecc)))
111 ebin0 = ebin0 - 0.5*body(i1)*body(i2)/semi
115 xrel(k) = px(k)*xorb(1) + qx(k)*xorb(2)
116 vrel(k) = px(k)*vorb(1) + qx(k)*vorb(2)
123 x(k,i1) = x(k,i1) + body(i2)*xrel(k)/zmb
124 x(k,i2) = x(k,i1) - xrel(k)
125 xdot(k,i1) = xdot(k,i1) + body(i2)*vrel(k)/zmb
126 xdot(k,i2) = xdot(k,i1) - vrel(k)
132 DO 50 j = 2*nbin0+1,n
137 xdot(k,i) = xdot(k,l)