Nbody6
 All Files Functions Variables
hmdot.f
Go to the documentation of this file.
1  SUBROUTINE hmdot(J,IMERGE,M1,KW,MC,DMS,RNEW,ITERM)
2 *
3 *
4 * Mass loss from inner 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  i1 = 2*ipair - 1
20  icm = n + ipair
21 *
22 * Include quitting conditions to avoid large changes at end-point.
23  iquit = .false.
24 * IF (RADIUS(J)*SU.GT.500.0) IQUIT = .TRUE.
25 * IF (BODY0(J)*ZMBAR.GT.15.0.AND.KSTAR(J).GE.4) IQUIT = .TRUE.
26 * IF (ABS(M1 - MC).LT.0.1*M1.OR.MC.GT.1.4) IQUIT = .TRUE.
27 * IF (BODY0(J)*ZMBAR - M1.GT.0.5*M1) IQUIT = .TRUE.
28 * Note that tidal dissipation needs full KS for rectification in MDOT.
29 * IF (KSTARM(IMERGE).LT.0.OR.BODY(ICM).EQ.0.0D0) IQUIT = .TRUE.
30  IF (body(icm).EQ.0.0d0) iquit = .true.
31 *
32 * Quit for mis-identification, advanced evolution or double merger.
33  IF (j.LE.0.OR.iquit) THEN
34  iterm = 1
35  go to 50
36  END IF
37 *
38 * Update radius for #J and copy #I1 for MDOT & HCORR in case of ghost.
39  rstar = rnew
40  IF (j.GT.i1) THEN
41  radius(j) = rnew
42  rstar = radius(i1)
43 * Return RNEW for copying back to RADIUS(I1) on ghost & DM/M < 0.01.
44  END IF
45 *
46 * Skip further modifications on zero mass loss of same type.
47  IF (abs(dms/m1).EQ.0.0d0.AND.kw.EQ.kstar(j)) go to 50
48 *
49 * Set two-body elements for outer orbit and inner semi-major axis.
50  semi = -0.5*body(icm)/h(ipair)
51  ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(body(icm)*semi)
52  ecc1 = sqrt(ecc2)
53  zmb0 = cm(1,imerge) + cm(2,imerge)
54  semi0 = -0.5*zmb0/hm(imerge)
55 *
56 * Form modified mass ratio and semi-major axes from M*A = const.
57  dm = dms/zmbar
58  zmb = zmb0 - dm
59  semi1 = semi*(zmb0 + body(2*ipair))/(zmb + body(2*ipair))
60  semi2 = semi0*zmb0/zmb
61  pmin = semi1*(1.0 - ecc1)
62 *
63 * Evaluate old separation, square regularized velocity, t'' & ECC.
64  ri = 0.0d0
65  v20 = 0.0
66  td2 = 0.0
67  DO 10 k = 1,4
68  ri = ri + um(k,imerge)**2
69  v20 = v20 + umdot(k,imerge)**2
70  td2 = td2 + 2.0*um(k,imerge)*umdot(k,imerge)
71  10 CONTINUE
72  ecc2 = (1.0 - ri/semi0)**2 + td2**2/(semi0*zmb0)
73  ecc = sqrt(ecc2)
74 *
75 * Determine inclination (use #I1 as first KS component).
76  CALL himax(i1,imerge,ecc,semi0,emax,emin,zi,tg,edav)
77 *
78 * Evaluate the general stability function (Mardling 2008).
79  IF (ecc1.LT.1.0) THEN
80  eout = ecc1
81 * Increase tolerance near sensitive stability boundary (RM 10/2008).
82  IF (eout.GT.0.9) THEN
83  de = 0.5*(1.0 - eout)
84  de = min(de,0.01d0)
85 * Add extra amount 0.011 to avoid switching.
86  IF (ecc1.GT.0.9) de = de + 0.011
87  eout = eout - de
88  pmin = semi1*(1.0 - eout)
89  END IF
90  nst = nstab(semi2,semi1,ecc,eout,zi,cm(1,imerge),
91  & cm(2,imerge),body(2*ipair))
92  IF (nst.EQ.0) THEN
93  pcrit = 0.99*pmin
94  pcr = stability(cm(1,imerge),cm(2,imerge),body(2*ipair),
95  & ecc,ecc1,zi)*semi2
96  ELSE
97  pcrit = 1.01*pmin
98  END IF
99  ELSE
100  pcrit = stability(cm(1,imerge),cm(2,imerge),body(2*ipair),
101  & ecc,ecc1,zi)*semi2
102  END IF
103 *
104 * Update pericentre distance on successful stability test or exit.
105  IF (pmin.GT.pcrit) THEN
106  r0(ipair) = pcrit
107  ELSE
108  iterm = 1
109  go to 50
110  END IF
111 *
112 * Check for possible circularization (tidal or sequential).
113  rp = semi2*(1.0 - ecc)
114  IF (kz(27).GT.0.AND.rp.LT.4.0*radius(j).AND.ecc.GT.0.002.AND.
115  & kstarm(imerge).GE.0) THEN
116  tc = 1.0d+10
117  IF (kz(27).EQ.2) THEN
118  i2 = 0
119 * Identify the ghost by searching single bodies.
120  DO 12 k = ifirst,n
121  IF (body(k).EQ.0.0d0.AND.
122  & name(k).EQ.nameg(imerge)) THEN
123  i2 = k
124  END IF
125  12 CONTINUE
126  IF (i2.GT.0) THEN
127  DO 14 k = 1,2
128  bodyi(k) = cm(k,imerge)
129  14 CONTINUE
130  tg = 1.0
131 * Evaluate the circularization time.
132  CALL hicirc(rp,ecc,i1,i2,bodyi,tg,tc,ec,ed,w)
133  IF (tc.GT.2000) go to 18
134  END IF
135  END IF
136  WRITE (6,15) name(j), kstar(j), kstarm(imerge), ecc, dms,
137  & rp, radius(j), tc
138  15 FORMAT (' HMDOT TERM NAM K* E DM RP R* TC ',
139  & i6,2i4,f8.4,f7.3,1p,3e10.2)
140  iterm = 1
141  go to 50
142  ELSE IF (ecc.GT.0.002) THEN
143  IF (rp.LT.2.0*radius(j)) THEN
144  WRITE (6,15) name(j), kstar(j), kstarm(imerge), ecc, dms,
145  & rp, radius(j)
146  iterm = 1
147  go to 50
148  END IF
149  END IF
150 *
151 * Obtain energy change from M*A = const and H = -M/(2*A) (DCH 8/96).
152  18 dh = dm/semi0*(1.0 - 0.5*dm/zmb0)
153  hm0 = hm(imerge)
154  hm(imerge) = hm(imerge) + dh
155 *
156 * Form KS coordinate & velocity scaling factors (general point is OK).
157  semi2 = -0.5*zmb/hm(imerge)
158  c2 = sqrt(semi2/semi0)
159  v2 = 0.5*(zmb + hm(imerge)*ri*(semi2/semi0))
160  c1 = sqrt(v2/v20)
161 *
162 * Re-scale KS variables to new energy (H < 0: constant eccentricity).
163  DO 20 k = 1,4
164  um(k,imerge) = c2*um(k,imerge)
165  umdot(k,imerge) = c1*umdot(k,imerge)
166 * Note no need to update XREL & VREL for RESTART (c.m. error cancels).
167  20 CONTINUE
168 *
169 * Reduce mass of relevant component (ghost is original second member).
170  zmu0 = cm(1,imerge)*cm(2,imerge)/zmb0
171  km = 1
172  IF (j.GE.ifirst) km = 2
173  cm(km,imerge) = cm(km,imerge) - dm
174 *
175 * Include corrections to EMERGE & EMDOT (consistency; no net effect!).
176  zmu = cm(1,imerge)*cm(2,imerge)/zmb
177  decorr = zmu*hm(imerge) - zmu0*hm0
178  emerge = emerge + decorr
179  emdot = emdot - decorr
180 * Compensate for EMERGE contribution in DEGRAV (cf. EVENTS).
181  egrav = egrav - decorr
182 *
183 * Correct outer orbit for mass loss (use #I1 in case #J is a ghost).
184  CALL hcorr(i1,dm,rstar)
185 *
186 * Print some diagnostics on non-zero mass loss.
187  IF (dms.GT.1.0d-03) THEN
188  WRITE (6,30) name(j), kstar(j), imerge, km, m1, dms, pmin,
189  & pcrit, semi2, semi1, decorr
190  30 FORMAT (' HMDOT NAM K* IM KM M1 DM PM PC A A1 DE ',
191  & i6,3i4,f6.2,1p,5e10.2,0p,f10.6)
192  END IF
193 *
194  50 RETURN
195 *
196  END