Nbody6
 All Files Functions Variables
binev.f
Go to the documentation of this file.
1  SUBROUTINE binev(IPAIR)
2 *
3 *
4 * Binary evolution.
5 * -----------------
6 *
7  include 'common6.h'
8  common/binary/ cm(4,mmax),xrel(3,mmax),vrel(3,mmax),
9  & hm(mmax),um(4,mmax),umdot(4,mmax),tmdis(mmax),
10  & namem(mmax),nameg(mmax),kstarm(mmax),iflagm(mmax)
11  REAL*8 m1,m2
12  LOGICAL first
13  SAVE first,iprev,iskip
14  DATA first,iprev,iskip /.true.,0,0/
15 *
16 *
17 * Open unit #17 the first time.
18  IF (first) THEN
19  OPEN (unit=17,status='NEW',form='FORMATTED',file='BINEV')
20  first = .false.
21  WRITE (17,5)
22  5 FORMAT (' TPHYS NAM1 NAM2 K1 K2 KC M1 M2 R1',
23  & ' R2 RI ECC SEMI PERIOD C',/)
24  END IF
25 *
26 * Define KS & c.m. indices and set component masses & radii.
27  i1 = 2*ipair - 1
28  i2 = i1 + 1
29  i = n + ipair
30  m1 = body(i1)*smu
31  m2 = body(i2)*smu
32  r1 = radius(i1)*su
33  r2 = radius(i2)*su
34 *
35 * Skip identical or alternating sequences (i.e. KSTAR(I) = -1 & 0).
36  isum = kstar(i1) + kstar(i2) + kstar(i)
37  IF (isum.EQ.iprev.OR.isum.EQ.iskip) go to 20
38  iskip = iprev
39  iprev = isum
40 *
41 * Form basic two-body elements (distinguish mergers & ghosts).
42  IF (name(i).GT.0.AND.body(i).GT.0.0d0) THEN
43  semi = -0.5*body(i)/h(ipair)
44  bodyc = body(i)
45  ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(bodyc*semi)
46  ELSE
47  CALL findj(i1,j,im)
48  IF (j.LE.0) RETURN
49  bodyc = cm(1,im) + cm(2,im)
50  semi = -0.5*bodyc/hm(im)
51  rj = um(1,im)**2 + um(2,im)**2 + um(3,im)**2 + um(4,im)**2
52  ecc2 = (1.0 - rj/semi)**2
53  END IF
54 *
55  ecc = sqrt(ecc2)
56  p = days*semi*sqrt(abs(semi)/bodyc)
57  p = min(p,99999.9d0)
58  p = max(p,-1.0d0)
59  a0 = min(semi*su,9999.9d0)
60  a0 = max(a0,-1.0d0)
61  ri2 = (x(1,i) - rdens(1))**2 + (x(2,i) - rdens(2))**2 +
62  & (x(3,i) - rdens(3))**2
63  ri = min(sqrt(ri2),99.9d0)
64  r1 = min(r1,999.9d0)
65  r2 = min(r2,999.9d0)
66 *
67 * Print one line for every new stage (type change of #I1, #I2 or c.m.).
68  WRITE (17,10) tphys, name(i1), name(i2), kstar(i1), kstar(i2),
69  & kstar(i), m1, m2, r1, r2, ri, ecc, a0, p, iqcoll
70  10 FORMAT (f8.1,2i6,3i4,2f5.1,f7.1,f6.1,f5.1,f7.3,f8.1,f9.1,i3)
71  CALL flush(17)
72 *
73  20 RETURN
74 *
75  END