12 common/modes/ eb0(ntmax),zj0(ntmax),ecrit(ntmax),ar(ntmax),
13 & br(ntmax),eosc(4,ntmax),edec(ntmax),tosc(ntmax),
14 & rp(ntmax),es(ntmax),cm(2,ntmax),iosc(ntmax),
16 common/slow0/ range,islow(10)
17 common/spins/angmom0,rg2(2),m21,r21,semi0,c1,c2,c3,c4,c5,semi
18 REAL*8 ww(3),qq(3),w(2),q(2),at0(2),m21,wg(2),qg(2),wscale(2),
19 & qscale(2),a(2),b(2),c(6),meanmotion,rj(2),rol(2)
22 DATA ww /2.119,3.113,8.175/
23 DATA qq /0.4909,0.4219,0.2372/
24 DATA a /6.306505,-7.297806/
25 DATA b /32.17211,13.01598/
26 DATA c /5.101417,24.71539,-9.627739,1.733964,
27 & -2.314374,-4.127795/
38 IF (namec(k).EQ.name(i)) irem = k
41 IF (irem.GT.0) go to 30
57 IF (namec(k).EQ.name(i)) ic = k
61 IF (nchaos.EQ.0.OR.ic.EQ.0)
THEN
64 semi = -0.5*body(i)/h(ipair)
65 ecc2 = (1.0-r(ipair)/semi)**2 + tdot2(ipair)**2/(body(i)*semi)
69 rp(ic) = semi*(1.0 - ecc)
71 WRITE (6,4) name(i1), name(i), list(1,i1), ecc, r(ipair)
72 4
FORMAT (
' SPIRAL REPAIR NM NMI NP E RP ',
73 & 2i7,i4,f8.4,1p,e10.2)
78 IF (kstar(i).GT.0)
THEN
84 IF (ic.EQ.0.AND.nchaos.GT.0)
THEN
85 WRITE (6,3) nchaos, kstar(i), ipair, name(i1), name(i2),
86 & step(2*ipair-1), step(i)
87 3
FORMAT (
' WARNING! SPIRAL NCH K* KS NAME STEP1 STEPI',
91 IF (namec(k).EQ.name(i1).OR.namec(k).EQ.name(i2)) ic = k
96 WRITE (6,6) name(i), kstar(i), (namec(k),k=1,nchaos)
97 6
FORMAT (
' DANGER! SPIRAL NAMI K* NAMEC ',15i6)
108 semi0 = -0.5*body(i)/h(ipair)
109 tk = semi0*sqrt(semi0/body(i))
112 IF (list(1,i1).GT.0)
THEN
113 ecc2 = (1.0 - r(ipair)/semi0)**2 +
114 & tdot2(ipair)**2/(body(i)*semi0)
117 rp0 = semi0*(1.0 - ecc0)
122 IF (radius(i1).GE.radius(i2))
THEN
140 IF (kstar(ik).EQ.3.OR.kstar(ik).EQ.5.OR.
141 & kstar(ik).EQ.6.OR.kstar(ik).EQ.9)
THEN
142 CALL
giant(ipair,ik,wg,qg,wscale,qscale,xn,ql)
146 rg2(k)= 0.1*(1.0 - cm(k,ic)/body(ik))
150 IF (kstar(ik).GE.3) ip = 2
151 IF (kstar(ik).EQ.4.OR.kstar(ik).EQ.7) ip = 3
152 IF (kstar(ik).EQ.8) ip = 3
153 IF (kstar(ik).EQ.0) ip = 1
157 IF (kstar(ik).LE.2.OR.kstar(ik).EQ.7) rg2(k) = 0.1
158 IF (kstar(ik).EQ.4) rg2(k)= 0.1*(1.0 - cm(k,ic)/body(ik))
160 tl = twopi*radius(ik)*sqrt(radius(ik)/body(ik)/w(k))
165 IF (radius(i1).GE.radius(i2))
THEN
166 m21 = body(i2)/body(i1)
167 r21 = radius(i2)/radius(i1)
168 rp1 = rp(ic)/radius(i1)
171 m21 = body(i1)/body(i2)
172 r21 = radius(i1)/radius(i2)
173 rp1 = rp(ic)/radius(i2)
178 semi0 = rp1/(1.0 - es0)
181 meanmotion = sqrt((body(i1)+body(i2))/(rad*semi0)**3)
184 IF (kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
185 spin1 = spin(j1)/(rg2(1)*body(j1)*radius(j1)**2)
190 IF (mc1.LE.0.0d0.OR.mc1.GT.m0)
THEN
191 mc1 = 0.3 + 0.1*float(kw - 3)
192 IF(kw.EQ.9) mc1 = min(0.3d0,0.95*m0)
196 rc1 =
corerd(kw,mc1,m0,zdum)/su
197 spin1 = spin(j1)/(rg2(1)*body(j1)*radius(j1)**2 +
198 & 0.21*mc1/smu*rc1**2)
200 IF (kstar(j2).LE.2.OR.(kstar(j2).GE.7.AND.kstar(j2).NE.9))
THEN
201 spin2 = spin(j2)/(rg2(2)*body(j2)*radius(j2)**2)
203 IF (kstar(j2).GE.10.AND.kstar(j2).LE.12.AND.
204 & time.LT.tev0(j2) + 0.01)
THEN
205 WRITE (95,780) ttot, name(j2), name(j1), kstar(j1),
206 & spin1, spin2, meanmotion, spin(j2)
207 780
FORMAT (
' WD SPIN T NM K*1 ROT1 ROT2 <n> S2 ',
208 & f8.1,2i6,i4,1p,4e10.2)
215 IF (mc2.LE.1.0d-10.OR.mc2.GT.m0)
THEN
216 mc2 = 0.3 + 0.1*float(kw - 3)
217 IF(kw.EQ.9) mc2 = min(0.3d0,0.95*m0)
221 rc2 =
corerd(kw,mc2,m0,zdum)/su
222 spin2 = spin(j2)/(rg2(2)*body(j2)*radius(j2)**2 +
223 & 0.21*mc2/smu*rc2**2)
228 IF (abs(spin1).GT.0.d0.AND.abs(spin2).GT.0.d0)
THEN
229 ts = 1.0d+06*365.0*twopi*tstar
230 WRITE (6,790) ts/spin1, ts/spin2, ts/meanmotion,
231 & days*tk, radius(j1)*su, radius(j2)*su
232 790
FORMAT (
' BEGIN TROT P TK R* ',1p,2e9.1,0p,4f9.2)
237 spin10=spin1/meanmotion
238 spin20=spin2/meanmotion
239 angmom0=(m21/(1+m21))*semi0**2*sqrt(1-es0**2)+rg2(1)*spin10+
240 & m21*r21**2*rg2(2)*spin20
244 c1 = cf*(at0(1)*(q(1)/w(1))**2*(1.0 + m21)*m21)/semi0**8
245 c2 = cf*(at0(2)*(q(2)/w(2))**2*((1.0 + m21)/m21**2)*r21**8)/
247 c3 = (cf/9.0)*(at0(1)*(q(1)/w(1))**2*m21**2)/rg2(1)/semi0**6
248 c4 = (cf/9.0)*(at0(2)*(q(2)/w(2))**2/m21**2)*r21**6/rg2(2)/
252 IF (kstar(i1).GE.13)
THEN
255 IF (kstar(i2).GE.13)
THEN
259 IF (time - time0.LE.0.0d0) go to 100
263 udot1=-(es0/fac**6.5)*(c1 + c2)
264 udot2=(1.0/fac)**6*c3
265 udot3=(1.0/fac)**6*c4
268 taux = min(abs(1.0/udot1),abs(1.0/udot2),abs(1.0/udot3))
269 nstep = 1 + 100.0*sqrt(abs(time - time0)/taux)
270 nstep = min(nstep,100)
272 IF (time - time0.GT.0.1) nstep = nstep + 20
273 IF (kstar(j1).EQ.5.OR.kstar(j1).EQ.6) nstep = nstep + 10
276 f2 = ((0.3125*e2 + 5.625)*e2 + 7.5)*e2 + 1.0
277 f5 = (0.375*e2 + 3.0)*e2 + 1.0
278 omeq = f2*meanmotion/(f5*fac**1.5)
280 IF (omeq - spin1.GT.0.2*omeq) nstep = nstep + 10
281 dtau1 = abs(time - time0)/float(nstep)
284 IF (iphase.EQ.7.OR.time - time0.GT.1.0)
THEN
286 a0 = -0.5*body(i)/h(ipair)
287 qperi = a0*(1.0 - es0)
288 CALL
tcirc(qperi,es0,i1,i2,icirc,tc)
289 dt = min(0.1d0*tc,1.0d0)
291 IF (tc.LT.10.0.AND.(kstar(j1).GT.1.OR.ecc.GT.0.1))
THEN
292 nstep = 500*(1.0 + 100.0/tc)
293 nstep = min(nstep,5000)
294 WRITE (6,12) name(j1), nstep, es0, qperi, time-time0, tc
295 12
FORMAT (
' SPIRAL RESET NM # E QP T-T0 TC ',
296 & 2i6,f7.3,1p,3e10.2)
298 dtau1 = abs(dt)/float(nstep)
302 IF (ione.LE.2.OR.mod(ione,10000).EQ.0)
THEN
303 WRITE (6,13) list(1,i1), name(i1),es0, omeq, meanmotion,
305 13
FORMAT (
' SPIRAL NP NM es0 omeq <n> spin ',
306 & i4,i6,f9.5,1p,4e10.2)
310 call
hut(es0,spin10,spin20,ecc,spin1,spin2,nstep,dtau1)
313 IF (spin10.LT.1.0.and.spin1.gt.1.0)
THEN
314 IF (mod(iwarn,100).EQ.0)
THEN
315 WRITE (66,14) ttot, name(j1), kstar(j1), nstep, ecc,
316 & rp0*su/(1.0-es0), spin1-1.0
317 14
FORMAT (
' SPIN WARNING T NM K* # E A S-1 ',
318 & f8.1,i7,i4,i6,f7.3,1p,2e10.1)
324 IF (spin20.LT.1.0.and.spin2.gt.1.0)
THEN
325 IF (mod(iwarn,100).EQ.0)
THEN
326 WRITE (66,14) ttot, name(j2), kstar(j2), nstep, ecc,
327 & rp0*su/(1.0-es0), spin2-1.0
335 semi = rad*semi0*semi
336 spin1 = meanmotion*spin1
337 spin2 = meanmotion*spin2
338 ecc = max(ecc,0.001d0)
339 ecc = min(ecc,0.999d0)
342 IF (kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
343 spin(j1) = rg2(1)*body(j1)*radius(j1)**2*spin1
345 spin(j1) = (rg2(1)*body(j1)*radius(j1)**2 +
346 & 0.21*mc1/smu*rc1**2)*spin1
348 IF (kstar(j2).LE.2.OR.(kstar(j2).GE.7.AND.kstar(j2).NE.9))
THEN
349 spin(j2) = rg2(2)*body(j2)*radius(j2)**2*spin2
351 spin(j2) = (rg2(2)*body(j2)*radius(j2)**2 +
352 & 0.21*mc2/smu*rc2**2)*spin2
357 dh = -0.5*body(i)*(1.0/semi - 1.0/a0)
360 h(ipair) = h(ipair) + dh
361 semi = -0.5*body(i)/h(ipair)
364 IF (list(1,i1).EQ.0)
THEN
365 qperi = semi*(1.0 - ecc)
367 qperi = rp0*(1.0 + es0)/(1.0 + ecc)
374 IF (ecc.LT.eccm)
THEN
378 tb = days*semi*sqrt(semi/body(i))
380 IF(kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
381 spin(j1) = rg2(1)*body(j1)*radius(j1)**2*meanmotion
383 spin(j1) = (rg2(1)*body(j1)*radius(j1)**2 +
384 & 0.21*mc1/smu*rc1**2)*meanmotion
386 dom = (spin1 - meanmotion)/meanmotion
387 WRITE (6,15) ttot, ipair, es0, ecc, rp0, r(ipair), h(ipair),
389 15
FORMAT (
' END SPIRAL T KS E0 E RP0 R H P n DOM/OM ',
390 & f9.2,i4,2f8.4,1p,4e10.2,0p,f5.1,f7.3)
395 err = abs(rp0 - r(ipair))/rp0
396 IF (r(ipair).GT.semi.OR.err.GT.1.0e-05)
THEN
398 IF (tdot2(ipair).LT.0.0d0)
THEN
402 IF (gamma(ipair).LT.1.0d-04)
THEN
415 c2 = sqrt((body(i) + h(ipair)*qperi)/(body(i) + hi*rp0))
421 u(k,ipair) = c1*u(k,ipair)
422 udot(k,ipair) = c2*udot(k,ipair)
423 u0(k,ipair) = u(k,ipair)
424 r(ipair) = r(ipair) + u(k,ipair)**2
425 tdot2(ipair) = tdot2(ipair) + 2.0*u(k,ipair)*udot(k,ipair)
427 tdot2(ipair) = max(tdot2(ipair),0.0d0)
430 zmu = body(i1)*body(i2)/body(i)
431 ecoll = ecoll + zmu*(hi - h(ipair))
432 egrav = egrav + zmu*(hi - h(ipair))
435 ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(body(i)*semi)
437 IF (abs(ecc - eccf).GT.0.01)
THEN
444 ac = qperi*(1.0 + ecc)
445 h(ipair) = -0.5*body(i)/ac
452 q1 = body(j)/(body(i) - body(j))
459 IF (rj(1)/rol(1).GE.rj(2)/rol(2))
THEN
468 IF(kstar(j1).EQ.2)
THEN
470 ELSE IF(kstar(j1).GE.3.AND.kstar(j1).LE.6)
THEN
473 IF (j1.EQ.i2) zmc = cm(2,ic)
474 qc = (1.67d0-zpars7+2.d0*(zmc/body(j1))**5)/2.13d0
478 ELSE IF(kstar(j1).EQ.8.OR.kstar(j1).EQ.9)
THEN
485 q1 = body(j1)/body(j2)
487 IF (dtr.LT.0.1/tstar.AND.q1.GT.qc.AND.istar.EQ.0)
THEN
491 CALL
expel(j1,j2,icase)
493 IF (iphase.EQ.-1) go to 100
494 tev(i1) = tev(i) + 2.0*stepx
501 IF (dtr.LE.0.1/tstar.OR.
502 & (step(i1).GT.100.0*tk.AND.kstar(j1).GE.5))
THEN
504 af = semi*(1.0 - ecc**2)/(1.0 - eccm**2)
505 h(ipair) = -0.5*body(i)/af
506 ecoll = ecoll + zmu*(hi - h(ipair))
507 egrav = egrav + zmu*(hi - h(ipair))
509 WRITE (6,21) es0, ecc, af/semi, dtr, semi, af
510 21
FORMAT (
' WARNING! SPIRAL TERM E0 E A/A0 DTR A AF ',
511 & 2f8.4,f6.2,1p,3e10.2)
513 meanmotion = sqrt(body(i)/af**3)
514 IF(kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
515 spin(j1) = rg2(1)*body(j1)*radius(j1)**2*meanmotion
517 spin(j1) = (rg2(1)*body(j1)*radius(j1)**2 +
518 & 0.21*mc1/smu*rc1**2)*meanmotion
520 dom = (spin1 - meanmotion)/meanmotion
521 WRITE (6,26) name(j1), q1, qc, dom
522 26
FORMAT (
' ENFORCED ROCHE NM(J1) Q1 QC DOM/OM',i8,2f8.2,f7.3)
524 CALL
expand(ipair,r(ipair))
529 IF (list(1,i1).GT.0)
THEN
531 IF (gamma(ipair).LT.1.0d-10.AND.es0.LT.0.95)
THEN
534 IF (gamma(ipair).LT.5.0d-07.AND.es0.LT.0.3)
THEN
543 IF (kstar(i).EQ.10)
THEN
547 semi = -0.5*body(i)/h(ipair)
548 ecc2 = (1.0-r(ipair)/semi)**2 + tdot2(ipair)**2/(body(i)*semi)
552 IF (ecc.GT.eccm)
THEN
553 CALL
deform(ipair,ecc,eccm)
555 WRITE (6,22) ecc, eccm, time-time0, semi,
556 & body(i1)*zmbar, body(i2)*zmbar
557 22
FORMAT (
' DEFORM SPIRAL E EF T-TOSC SEMI M1 M2 ',
558 & 2f8.4,f9.4,1p,e10.2,0p,2f6.2)
562 IF (body(i1)/radius(i1)**3.LT.body(i2)/radius(i2)**3)
THEN
571 q0 = body(j1)/body(j2)
574 rl1 = 0.49*q2/(0.6*q2 + log(1.0d0 + q1))*semi
579 tk = days*semi*sqrt(semi/body(i))
581 WRITE (6,24) ic, name(j1), name(j2), kstar(j1), kstar(j2),
582 & semi*su, rl1*su, radius(j1)*su, radius(j2)*su,
584 24
FORMAT (
' ROCHE CHECK IC NAM K* A RL R* TP TK DTR ',
585 & i4,2i6,2i4,4f7.1,f9.2,1p,2e9.1)
587 CALL
trdot(j1,dtm,zm1)
594 IF (dtr.EQ.0.0d0.AND.semi.LT.0.5*radius(j1))
THEN
598 23
FORMAT (
' ENFORCED COAL KS = ',i4)
606 IF (abs(time - tadj).LT.step(i1))
THEN
607 IF (rp1.LT.3.0.AND.(ecc.LT.0.1.OR.kstar(j1).GE.3))
THEN
609 tk = days*semi*sqrt(semi/body(i))
610 WRITE (6,25) name(i1), name(i2), ipair, nchaos,
611 & kstar(i1), kstar(i2), np, ecc, rp1, tk
612 25
FORMAT (
' SPIRAL NAM KS NCH K* NP E RP P ',
613 & 2i6,i5,4i4,f8.4,f6.2,f8.2)
618 IF ((ecc.LT.0.6.AND.gamma(ipair).LT.2.0d-07).OR.
619 & (ecc.LT.0.8.AND.gamma(ipair).LT.1.0d-08).OR.
620 & (ecc.LT.0.95.AND.gamma(ipair).LT.1.0d-09))
THEN
622 CALL
tcirc(qperi,ecc,i1,i2,icirc,tc)
623 IF (tc.GT.200.0.OR.(tc.GT.10.AND.ecc.LT.0.7))
THEN
626 CALL
deform(ipair,ecc,eccm)
632 WRITE (6,28) ipair, np, name(i1), ecc, tc, gamma(ipair)
633 28
FORMAT (
' ENFORCED CIRC KS NP NM E TC G ',
634 & 2i4,i6,f7.3,1p,2e9.1)
639 IF (ecc.GT.0.95.AND.gamma(ipair).LT.1.0d-09)
THEN
641 CALL
tcirc(qperi,ecc,i1,i2,icirc,tc)
642 IF (tc.GT.1.0d+04)
THEN
645 WRITE (6,29) name(i1), list(1,i1), ecc, tc
646 29
FORMAT (
' FROZEN CIRC NM NP E TC ',i7,i4,f9.5,1p,e9.1)
652 30
IF (kstar(i).EQ.10.OR.irem.GT.0)
THEN
653 IF (irem.GT.0) go to 50
656 40
DO 45 jpair = 1,npairs
657 IF (namec(j).EQ.name(n+jpair))
THEN
659 IF (kstar(n+jpair).GT.0)
THEN
673 IF (nmerge.GT.0)
THEN
674 DO 48 jpair = 1,npairs
675 IF (name(n+jpair).LT.0)
THEN
676 IF (namec(j).EQ.nzero + name(2*jpair-1).OR.
677 & namec(j).EQ.nzero + name(2*jpair).OR.
678 & namec(j).LT.-2*nzero.OR.
679 & namec(j).EQ.name(2*jpair))
THEN
680 WRITE (71,46) nchaos, namec(j), name(n+jpair),
682 46
FORMAT (
' MERGED SPIRAL NCH NAM ',i4,3i7)
691 50 nchaos = nchaos - 1
700 eosc(k,l) = eosc(k,l1)
722 IF (j.LE.nchaos.AND.irem.EQ.0) go to 40
726 IF (kz(8).GT.3.AND.kstar(i).NE.-2)
THEN
728 IF (ipair.LT.0) ipair = i - n