Nbody6
 All Files Functions Variables
hmdot2.f
Go to the documentation of this file.
1  SUBROUTINE hmdot2(J,IGHOST,IMERGE,M1,KW,MC,DMS,RNEW,ITERM)
2 *
3 *
4 * Mass loss from outer hierarchical binary.
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 bodyi(2),w(2)
12  REAL*8 m1,mc
13  LOGICAL iquit
14 *
15 *
16 * Define merger termination index and relevant KS/c.m. indices.
17  iterm = 0
18  ipair = kspair
19  icm = n + ipair
20  jpair = ighost - n
21  i1 = 2*jpair - 1
22  i2 = i1 + 1
23 *
24 * Include quitting conditions to avoid large changes at end-point.
25  iquit = .false.
26 * IF (RADIUS(J)*SU.GT.500.0) IQUIT = .TRUE.
27 * IF (BODY0(J)*ZMBAR.GT.15.0.AND.KSTAR(J).GE.4) IQUIT = .TRUE.
28 * IF (ABS(M1 - MC).LT.0.1*M1.OR.MC.GT.1.4) IQUIT = .TRUE.
29 * IF (BODY0(J)*ZMBAR - M1.GT.0.5*M1) IQUIT = .TRUE.
30 * Note that tidal dissipation needs full KS for rectification in MDOT.
31 * IF (KSTAR(IGHOST).LT.0.OR.BODY(ICM).EQ.0.0D0) IQUIT = .TRUE.
32  IF (body(icm).EQ.0.0d0) iquit = .true.
33 *
34 * Quit for mis-identification or advanced evolution.
35  IF (ighost.LE.n.OR.iquit) THEN
36  IF (ighost.LE.n) THEN
37  WRITE (6,5) name(i1), ighost
38  5 FORMAT (' DANGER! HMDOT2 NAM IG ',2i5)
39  stop
40  END IF
41  iterm = 1
42  go to 50
43  END IF
44 *
45 * Update radius for #J and copy #I2 for MDOT & HCORR in case J = I2.
46  rstar = rnew
47  IF (j.GT.i1) THEN
48  radius(j) = rnew
49  rnew = radius(i2)
50 * Return RNEW for copying back to RADIUS(I2) on DM/M < 0.01.
51  END IF
52 *
53 * Skip further modifications on zero mass loss of same type.
54  IF (abs(dms/m1).EQ.0.0d0.AND.kw.EQ.kstar(j)) go to 50
55 *
56 * Set two-body elements for outer orbit and inner semi-major axis.
57  semi = -0.5*body(icm)/h(ipair)
58  ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(body(icm)*semi)
59  ecc1 = sqrt(ecc2)
60  zmb0 = cm(3,imerge) + cm(4,imerge)
61 * Note old H(JPAIR) used with new inner SEMI0 (small effect).
62  semi0 = -0.5*zmb0/h(jpair)
63 *
64 * Form modified mass ratio and semi-major axes from M*A = const.
65  dm = dms/zmbar
66  zmb = zmb0 - dm
67  semi1 = semi*(zmb0 + body(2*ipair-1))/(zmb + body(2*ipair-1))
68  semi2 = semi0*zmb0/zmb
69  pmin = semi1*(1.0 - ecc1)
70 *
71 * Evaluate old separation, square regularized velocity, t'' & ECC.
72  ri = 0.0d0
73  v20 = 0.0
74  td2 = 0.0
75  DO 10 k = 1,4
76  ri = ri + u(k,jpair)**2
77  v20 = v20 + udot(k,jpair)**2
78  td2 = td2 + 2.0*u(k,jpair)*udot(k,jpair)
79  10 CONTINUE
80  ecc2 = (1.0 - ri/semi0)**2 + td2**2/(semi0*zmb0)
81  ecc = sqrt(ecc2)
82 *
83 * Obtain stability parameters for the new configuration.
84  IF (ecc1.LT.1.0) THEN
85  nst = nstab(semi2,semi1,ecc,ecc1,zi,cm(1,imerge),
86  & cm(2,imerge),body(2*ipair))
87  IF (nst.EQ.0) THEN
88  pcrit = 0.99*pmin
89  ELSE
90  pcrit = 1.01*pmin
91  END IF
92  ELSE
93  pcrit = stability(cm(3,imerge),cm(4,imerge),body(2*ipair-1),
94  & ecc,ecc1,0.0d0)*semi2
95  END IF
96 *
97 * Update pericentre distance on successful stability test or exit.
98  IF (pmin.GT.pcrit.AND.h(jpair).LT.-eclose) THEN
99  r0(ipair) = pcrit
100  ELSE
101  iterm = 1
102  go to 50
103  END IF
104 *
105 * Check for possible circularization (tidal or sequential).
106  rp = semi2*(1.0 - ecc)
107  IF (kz(27).GT.0.AND.rp.LT.4.0*radius(j).AND.ecc.GT.0.002) THEN
108  tc = 1.0d+10
109  IF (kz(27).EQ.2) THEN
110  j1 = 2*jpair - 1
111  j2 = j1 + 1
112  DO 14 k = 1,2
113  bodyi(k) = cm(k+2,imerge)
114  14 CONTINUE
115  tg = 1.0
116 * Evaluate the circularization time.
117  CALL hicirc(rp,ecc,j1,j2,bodyi,tg,tc,ec,ed,w)
118  IF (tc.GT.2000) go to 18
119  END IF
120  WRITE (6,15) name(j), kstar(j), kstarm(imerge), ecc, dms,
121  & rp, radius(j), tc
122  15 FORMAT (' HMDOT2 TERM NM K* E DM RP R* TC ',
123  & i6,2i4,f8.4,f7.3,1p,3e10.2)
124  iterm = 1
125  go to 50
126  END IF
127 *
128 * Obtain energy change from M*A = const and H = -M/(2*A) (DCH 8/96).
129  18 dh = dm/semi0*(1.0 - 0.5*dm/zmb0)
130  hi = h(jpair)
131  h(jpair) = h(jpair) + dh
132 *
133 * Form KS coordinate & velocity scaling factors (general point is OK).
134  semi2 = -0.5*zmb/h(jpair)
135  c2 = sqrt(semi2/semi0)
136  v2 = 0.5*(zmb + h(jpair)*ri*(semi2/semi0))
137  c1 = sqrt(v2/v20)
138 *
139 * Re-scale KS variables to new energy (H < 0: constant eccentricity).
140  r(jpair) = 0.0d0
141  DO 20 k = 1,4
142  u(k,jpair) = c2*u(k,jpair)
143  udot(k,jpair) = c1*udot(k,jpair)
144  r(jpair) = r(jpair) + u(k,jpair)**2
145  20 CONTINUE
146 *
147 * Reduce mass of relevant component (ghost is original second member).
148  zmu0 = cm(3,imerge)*cm(4,imerge)/zmb0
149  km = 3
150  IF (j.EQ.2*jpair) km = 4
151  cm(km,imerge) = cm(km,imerge) - dm
152 *
153 * Include corrections to EMERGE & EMDOT (consistency; no net effect!).
154  zmu = cm(3,imerge)*cm(4,imerge)/zmb
155  decorr = zmu*h(jpair) - zmu0*hi
156  emerge = emerge + decorr
157  emdot = emdot - decorr
158  egrav = egrav - decorr
159 *
160 * Correct outer orbit for mass loss (use #I2 for consistency).
161  CALL hcorr(i2,dm,rstar)
162 *
163 * Print some diagnostics on non-zero mass loss.
164  IF (dms.GT.1.0d-03) THEN
165  WRITE (6,30) name(j), kstar(j), imerge, km, m1, dms, pmin,
166  & pcrit, semi2, semi1, r(jpair), h(jpair), decorr
167  30 FORMAT (' HMDOT2 NAM K* IM KM M1 DM PM PC A A1 R H DE ',
168  & i6,3i4,f6.2,1p,7e10.2,0p,f10.6)
169  END IF
170 *
171  50 RETURN
172 *
173  END