11 common/modes/ eb0(ntmax),zj0(ntmax),ecrit(ntmax),ar(ntmax),
12 & br(ntmax),eosc(4,ntmax),edec(ntmax),tosc(ntmax),
13 & rp(ntmax),es(ntmax),cm(2,ntmax),iosc(ntmax),
15 common/spins/angmom0,rg2(2),m21,r21,semi0,c1,c2,c3,c4,c5,semi
17 REAL*8 ww(3),qq(3),w(2),q(2),at0(2),m21,wg(2),qg(2),wscale(2),
18 & qscale(2),a(2),b(2),c(6)
20 REAL*8 tscls(20),lums(10),gb(10),lum,k2,menv
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/
28 SAVE icount,itry,isynch,iter,itime,iname,eccm
29 DATA icount,itry,isynch,iter,itime,eccm /0,0,0,0,0,0.002d0/
39 IF (namec(k).EQ.name(i)) ic = k
43 IF (name(i).NE.iname)
THEN
55 CALL
trdot(i2,dtm2,m1)
58 tev(i) = time + 0.1*min(dtm,dtr)
59 a0 = -0.5*body(i)/h(ipair)
60 ecc2 = (1.0 - r(ipair)/a0)**2 + tdot2(ipair)**2/(a0*body(i))
64 WRITE (6,3) name(i1), kstar(i), nchaos, ecc, a0, dtm, dtr
65 3
FORMAT (
' MISSING! SYNCH NM K* NCH ECC A DTM DTR ',
66 & i6,2i4,f8.4,1p,3e10.2)
70 IF (ecc.LT.0.10.AND.list(1,i1).EQ.0)
THEN
72 qperi = a0*(1.0 - ecc)
73 CALL
tcirc(qperi,ecc,i1,i2,icirc,tc)
75 CALL
deform(ipair,ecc,eccm)
81 IF (ecc.LE.0.003.OR.ic.EQ.0)
THEN
85 rp(ic) = a0*(1.0 - ecc)
88 IF (nchaos.GT.ntmax)
THEN
89 WRITE (6,4) name(i1), nchaos, ecc, a0*(1.0 - ecc)
90 4
FORMAT (
' FATAL ERROR! SYNCH NM NCH E QP ',
99 IF (time - tosc(ic).LT.1.0)
THEN
102 IF (dtr.LT.step(i))
THEN
112 a0 = -0.5*body(i)/h(ipair)
113 ecc2 = (1.0 - r(ipair)/a0)**2 + tdot2(ipair)**2/(a0*body(i))
118 qperi = a0*(1.0 - ecc)
119 IF (es0.GT.0.01.OR.abs(qperi-rp0).GT.0.02*qperi)
THEN
121 IF (itime.LT.50)
THEN
122 WRITE (6,5) name(i1), kstar(i1),kstar(i2),kstar(i), es0,
123 & ecc, rp0, qperi, dt
124 5
FORMAT (
' RP RECTIFY SYNCH NM K* ES0 E RP0 QP DT ',
125 & i6,3i4,2f8.4,1p,3e10.2)
134 IF (ecc.GT.0.01.OR.es0.GT.0.01)
THEN
136 IF (ecc.GT.0.01)
THEN
138 WRITE (6,8) name(i1), list(1,i1), es0, ecc, a0*su
139 8
FORMAT (
' NON-CIRCULAR SYNCH NM NP ES0 ECC A ',
140 & i6,i4,2f8.4,1p,e10.2)
151 IF (radius(i1).GE.radius(i2))
THEN
160 IF (kstar(j1).GE.2.AND.kstar(j1).LE.9)
THEN
165 age = time*tstar - epoch(j1)
166 CALL
star(kw,m0,m1,tm,tn,tscls,lums,gb,zpars)
167 CALL
hrdiag(m0,age,m1,tm,tn,tscls,lums,gb,zpars,
168 & rm,lum,kw,mc,rcc,menv,renv,k2)
186 IF (kstar(ik).EQ.3.OR.kstar(ik).EQ.5.OR.
187 & kstar(ik).EQ.6.OR.kstar(ik).EQ.9)
THEN
188 CALL
giant(ipair,ik,wg,qg,wscale,qscale,xn,ql)
191 rg2(k)= 0.1*(1.0 - cm(k,ic)/body(ik))
196 IF (kstar(ik).GE.3) ip = 2
197 IF (kstar(ik).EQ.4.OR.kstar(ik).EQ.7) ip = 3
198 IF (kstar(ik).EQ.8) ip = 3
199 IF (kstar(ik).EQ.0) ip = 1
202 IF (kstar(ik).LE.2.OR.kstar(ik).EQ.7)
THEN
204 ELSE IF (kstar(ik).EQ.4)
THEN
205 cm(k,ic) = min(0.89d0*body(ik),cm(k,ic))
206 rg2(k)= 0.1*(1.0 - cm(k,ic)/body(ik))
211 tl = twopi*radius(ik)*sqrt(radius(ik)/body(ik)/w(k))
212 IF (kstar(ik).GE.11) ql = 1.0d+10
217 IF (radius(i1).GE.radius(i2))
THEN
218 m21 = body(i2)/body(i1)
219 r21 = radius(i2)/radius(i1)
220 rp1 = rp(ic)/radius(i1)
223 m21 = body(i1)/body(i2)
224 r21 = radius(i1)/radius(i2)
225 rp1 = rp(ic)/radius(i2)
230 semi0 = rp1/(1.0 - es0)
233 omeq = sqrt(body(i)/(rad*semi0)**3)
236 IF (kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
237 spin1 = spin(j1)/(rg2(1)*body(j1)*radius(j1)**2)
242 IF (mc1.LE.0.0d0.OR.mc1.GT.m0)
THEN
243 mc1 = 0.3 + 0.1*(kstar(j1) - 3)
244 IF(kw.EQ.9) mc1 = min(0.3d0,0.95*m0)
248 rc1 =
corerd(kw,mc1,m0,zdum)/su
249 spin1 = spin(j1)/(rg2(1)*body(j1)*radius(j1)**2 +
250 & 0.21*mc1/smu*rc1**2)
252 IF (kstar(j2).LE.2.OR.(kstar(j2).GE.7.AND.kstar(j2).NE.9))
THEN
253 spin2 = spin(j2)/(rg2(2)*body(j2)*radius(j2)**2)
258 IF (mc2.LE.0.0d0.OR.mc2.GT.m0)
THEN
259 mc2 = 0.3 + 0.1*(kstar(j2) - 3)
260 IF(kw.EQ.9) mc2 = min(0.3d0,0.95*m0)
264 rc2 =
corerd(kw,mc2,m0,zdum)/su
265 spin2 = spin(j2)/(rg2(2)*body(j2)*radius(j2)**2 +
266 & 0.21*mc2/smu*rc2**2)
270 ds10 = (spin1 - omeq)/omeq
271 ds20 = (spin2 - omeq)/omeq
272 IF (kstar(j1).GE.10) spin1 = omeq
273 IF (kstar(j2).GE.10) spin2 = omeq
274 ds1 = (spin1 - omeq)/omeq
275 ds2 = (spin2 - omeq)/omeq
278 IF (abs(ds1).LT.0.01.AND.abs(ds2).LT.0.01)
THEN
279 kx = max(kstar(j1),kstar(j2))
280 IF (abs(ds20).GT.0.01.AND.kx.LT.10)
THEN
281 WRITE (6,20) name(i1), kstar(i1), kstar(i2), a0*su, ds1,
283 20
FORMAT (
' ENFORCED SYNCH NM K* A DS1 DS2 omeq ',
284 & i6,2i4,f9.3,1p,3e10.2)
290 ds = (spin1 - omeq)/omeq
294 angmom0=(m21/(1+m21))*semi0**2*sqrt(1-es0**2)+rg2(1)*spin10+
295 & m21*r21**2*rg2(2)*spin20
297 IF (icount.LE.-1000)
THEN
299 sum1=(m21/(1+m21))*semi0**2*sqrt(1-es0**2)
301 sum3 = m21*r21**2*rg2(2)*spin20
302 sum4 = sum1 + sum2 + sum3
304 WRITE (92,21)kstar(j1),kstar(j2),zm,a0,sum1,sum2,sum3,sum4,ds
305 21
FORMAT (
' K* M1 A S1 S2 S3 S4 DS ',2i4,f8.4,1p,e12.4,4e10.2,
311 c3 = (cf/9.0)*(at0(1)*(q(1)/w(1))**2*m21**2)/rg2(1)/semi0**6
312 c4 = (cf/9.0)*(at0(2)*(q(2)/w(2))**2/m21**2)*r21**6/rg2(2)/
316 IF (kw1.GE.2.AND.kw1.LE.9)
THEN
319 dmx =
mlwind(kw1,lum,rm,m1,mc,rlperi,zmet)
322 IF (dt.LE.1.0d-10) dt = abs(tev(j1) - time)
323 rdot = (rm/su - radius(j1))/dt
325 c5 = -1.0d+06*dmx*tstar/m1 + 2.0*rdot/radius(j1)
326 r1 = rm/(su*radius(j1))
335 IF (time - time0.LE.0.0d0) go to 70
342 taux = min(abs(1.0/udot1),abs(1.0/udot2))
343 nstep = 1 + 100.0*sqrt(abs(time - time0)/taux)
344 nstep = min(nstep,100)
346 IF (ds1.LT.-0.2) nstep = nstep + 10
347 IF (ds1.LT.-0.8) nstep = nstep + 50
348 IF (ds1.LT.-0.9) nstep = nstep + 50
356 CALL
trdot(j1,dtm,m1)
358 dt = 0.1*min(dtr,dtm,10.0d0)
359 IF (abs(ds2).GT.0.05.OR.ds10.LT.-0.99)
THEN
363 tk = days*a0*sqrt(a0/body(i))
364 IF (icount.LT.50)
THEN
365 WRITE (6,30) name(j1), ds1, ds2, dt, tk
366 30
FORMAT (
' REDUCE SYNCH NM DS1 DS2 DT P ',
372 IF (kstar(j1).EQ.3) dt = 0.5*dt
373 40 dtau1 = abs(dt)/float(nstep)
376 call
hut2(spin10,spin20,spin1,spin2,nstep,dtau1)
381 semi = rad*semi0*semi
385 omeq = sqrt(body(i)/semi**3)
386 ds1 = (spin1 - omeq)/omeq
387 ds2 = (spin2 - omeq)/omeq
392 IF (spin1.LT.0.0.OR.spin2.LT.0.0)
THEN
393 WRITE (6,42) itry, nstep, dt, spin1, spin2, omeq
394 42
FORMAT (
' REPEAT SYNCH IT # DT S1 S2 omeq ',
398 IF (itry.LT.2) go to 40
403 IF ((ds10.LT.0.0.AND.ds1.GT.0.01).OR.
404 & (ds20.LT.0.0.AND.ds2.GT.0.01))
THEN
407 IF (iter.GT.1) dt = 0.5*dt
408 IF (iter.LT.4) go to 40
409 WRITE (6,45) nstep, ds10, ds1, ds20, ds2, dt
410 45
FORMAT (
' LIMIT SYNCH # DS10, DS1, DS20, DS2, DT ',
414 IF ((ds1.GT.0.0.AND.ds10.LT.-0.01).OR.
415 & (ds2.GT.0.0.AND.ds20.LT.-0.01))
THEN
418 IF (iter.GT.1) dt = 0.5*dt
419 IF (iter.LT.4) go to 40
420 WRITE (6,45) nstep, ds10, ds1, ds20, ds2, dt
425 50
IF (kstar(j1).LE.2.OR.(kstar(j1).GE.7.AND.kstar(j1).NE.9))
THEN
426 spin(j1) = rg2(1)*body(j1)*radius(j1)**2*spin1
428 spin(j1) = (rg2(1)*body(j1)*radius(j1)**2 +
429 & 0.21*mc1/smu*rc1**2)*spin1
431 IF (kstar(j2).LE.2.OR.(kstar(j2).GE.7.AND.kstar(j2).NE.9))
THEN
432 spin(j2) = rg2(2)*body(j2)*radius(j2)**2*spin2
434 spin(j2) = (rg2(2)*body(j2)*radius(j2)**2 +
435 & 0.21*mc2/smu*rc2**2)*spin2
437 IF (isynch.GT.0)
THEN
445 dh = -0.5*body(i)*(1.0/semi - 1.0/a0)
447 IF (h(ipair) + dh.LT.-0.5*body(i)/r(ipair))
THEN
448 dh = -0.5*body(i)/r(ipair) - h(ipair)
452 h(ipair) = h(ipair) + dh
453 semi = -0.5*body(i)/h(ipair)
456 IF (list(1,i1).EQ.0)
THEN
457 qperi = semi*(1.0 - ecc)
459 qperi = rp0*(1.0 + es0)/(1.0 + ecc)
466 c2 = sqrt((body(i) + h(ipair)*qperi)/(body(i) + hi*rp0))
472 u(k,ipair) = c1*u(k,ipair)
473 udot(k,ipair) = c2*udot(k,ipair)
474 u0(k,ipair) = u(k,ipair)
475 r(ipair) = r(ipair) + u(k,ipair)**2
476 tdot2(ipair) = tdot2(ipair) + 2.0*u(k,ipair)*udot(k,ipair)
478 tdot2(ipair) = max(tdot2(ipair),0.0d0)
481 zmu = body(i1)*body(i2)/body(i)
482 ecoll = ecoll + zmu*(hi - h(ipair))
483 egrav = egrav + zmu*(hi - h(ipair))
486 IF (list(1,i1).GT.0)
THEN
494 da = (semi - a0)/semi
495 ds1 = (spin1-omeq)/omeq
496 ds2 = (spin2-omeq)/omeq
497 ts1 = min(tev(j1),tev(j2))
498 WRITE (7,65) nstep,time-time0,udot1,udot2,ds1,ds2,da,ts1
499 65
FORMAT (
' HUT2 # t-t0 ud DS DA/A TM ',
500 & i5,f9.3,1p,5e9.1,0p,f10.2)
513 CALL
trdot(j1,dtm,m1)
516 tev(i) = time + 0.1*min(dtr,dtm)
517 tev(i) = min(tev(j1),tev(j2),tev(i))
519 semi = -0.5*body(i)/h(ipair)
520 ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(semi*body(i))
523 IF (abs(ecc - es0).GT.0.001*es0)
THEN
524 CALL
deform(ipair,ecc,es0)
526 qperi = semi*(1.0 - es0)
533 IF (ecc.GT.0.01)
THEN
534 WRITE (6,80) name(i1), ecc, nstep, dtau1, err, c1-1.0, c2-1.0
535 80
FORMAT (
' DANGER! NAM E # dtau DA/A DC1 DC2 ',
536 & i6,f8.4,i5,1p,5e10.2)
540 IF (icount.LE.100.AND.abs(ds1).GT.0.01)
THEN
543 WRITE (7,85) name(j1), kstar(j1), kstar(j2),
544 & semi*su, da, omeq, spin1, spin2, dt
545 85
FORMAT (
' SYNCH NM K* A DA/A om s1 s2 DT ',
546 & i8,2i4,f8.2,1p,5e10.2)
550 IF (spin1.LT.0.0)
THEN
551 WRITE (6,90) name(j1), kstar(j1), spin1, time-time0
552 90
FORMAT (
' DANGER! NEGATIVE SPIN NM K* s1 T-T0 ',
554 IF (spin1.LT.0.0) spin1 = 0.1*omeq
555 IF (spin2.LT.0.0) spin2 = 0.1*omeq
557 IF (itry.LE.2) go to 50