10 common/rche/ cmrch(13,mmax),namer(2,mmax),kstarr(3,mmax)
11 REAL*8 tscls(20),lums(10),gb(10),tm,tn,tphys0
12 REAL*8 m01,m1,age,r1,lum,mc,rcc,sep,m1ce,m2ce,rce,km0,km,m2,mcx
13 REAL*8 mass0(2),mass(2),massc(2),rad(2),radx(2),rol(2),
14 & radc(2),q(2),aj(2),tkh(2),tms(2),tbgb(2),
15 & jspin(2),ospin(2),djspin(2),dtmi(2)
16 REAL*8 menv(2),renv(2),k2str(2)
17 REAL*8 jorb,oorb,rlperi,djorb,djmb,djgr,djt,rdmin,rdisk
19 REAL*8 dms(2),dma(2),dmr(2),ivsqm,vwind2,vorb2
20 REAL*8 dm1,dm2,dm22,dspin,dspin0,delet,delet1,eqspin,mew,mt2
21 REAL*8 tc,tsyn,ttid,fac,fac0,ecc0,dtmmin,djtk(2),dspink(2)
22 REAL*8 mch,epsnov,eddfac,gamm1
23 parameter(mch=1.44d0,epsnov=0.d0,eddfac=100.d0,gamm1=-1.d0)
24 REAL*8 k2,k3,acc1,acc2,beta,xi,aursun
25 parameter(k3=0.21d0,acc1=3.920659d+08,acc2=1.5d0)
26 parameter(beta=0.125d0,xi=1.d0,aursun=214.95d0)
29 LOGICAL coals,disk,novae,supedd,isave
32 DATA iwarn,igr,imb /0,0,0/
50 semi = -0.5d0*body(i)/h(ipair)
51 ecc2 = (1.d0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(semi*body(i))
57 q(k) = body(j)/(body(i) - body(j))
58 rol(k) =
rl(q(k))*semi*su
65 IF (rad(1)/rol(1).GE.rad(2)/rol(2))
THEN
85 IF (rad(1).LE.rl1)
THEN
89 tphys0 = max(tev0(j1),tev0(j2))*tstar
90 tphys = tphys0 + toff*tstar
101 mass(1) = body(j1)*zmbar
102 mass(2) = body(j2)*zmbar
103 mass0(1) = body0(j1)*zmbar
104 mass0(2) = body0(j2)*zmbar
107 tb = yrs*semi*sqrt(semi/body(i))
110 jorb = mass(1)*mass(2)/(mass(1)+mass(2))
111 & *sqrt(1.d0-ecc*ecc)*sep*sep*oorb
123 age = tev0(j)*tstar - epoch(j)
124 CALL
star(kw,m01,m1,tm,tn,tscls,lums,gb,zpars)
125 CALL
hrdiag(m01,age,m1,tm,tn,tscls,lums,gb,zpars,
126 & r1,lum,kw,mc,rcc,m1ce,rce,k2)
134 radx(k) = min(radx(k),rol(k))
135 radx(k) = max(rcc,radx(k))
137 jspin(k) = max(spin(j)*spnfac,1.0d-10)
138 ospin(k) = jspin(k)/(k2*radx(k)*radx(k)*(m1-mc) +
148 rlperi = rol(k)*(1.d0 - ecc)
149 dmr(k) =
mlwind(kw,lum,r1,m1,mc,rlperi,zmet)
160 vorb2 = acc1*(mass(1)+mass(2))/sep
161 ivsqm = 1.d0/sqrt(1.d0-ecc*ecc)
163 dt = 1.0d+06*(tphys0 - tev0(j)*tstar)
164 IF(dt.EQ.0.0) goto 99
170 dms(k) = (dmr(k) - dma(k))*dt
171 djspin(k) = (2.d0/3.d0)*(dmr(k)*radx(k)*radx(k)*ospin(k) -
172 & xi*dma(k)*radx(3-k)*radx(3-k)*ospin(3-k))*dt
175 dms(k) = min(dms(k),mass(k)-massc(k))
176 CALL
magbrk(kw,mass(k),menv(k),rad(k),ospin(k),djmb)
177 djspin(k) = djspin(k) + djmb*dt
179 mass(k) = mass(k) - dms(k)
180 jspin(k) = max(jspin(k) - djspin(k),1.0d-10)
181 IF(kw.LE.2.OR.kw.EQ.7)
THEN
184 body0(j) = mass(k)/zmbar
185 CALL
star(kw,mass0(k),mass(k),tm,tn,tscls,lums,gb,zpars)
187 IF(gb(9).LT.massc(k).OR.m01.GT.zpars(3))
THEN
190 epoch(j) = tm + (tscls(1)-tm)*(aj(k)-tms(k))/
192 epoch(j) = tev0(j)*tstar - epoch(j)
195 epoch(j) = tev0(j)*tstar - aj(k)*tm/tms(k)
198 CALL
star(kw,mass0(k),mass(k),tm,tn,tscls,lums,gb,zpars)
200 age = tphys0 - epoch(j)
201 IF((age-tn).GT.1.0d-02)
THEN
203 age = min(age,0.9999*tscls(11))
205 age = min(age,0.9999*tscls(8))
207 epoch(j) = tphys0 - age
212 sep = sep*(mass(1)+mass(2)+dms(1)+dms(2))/(mass(1)+mass(2))
214 tb = yrs*semi*sqrt(semi*zmbar/(mass(1)+mass(2)))
217 jorb = mass(1)*mass(2)/(mass(1)+mass(2))
218 & *sqrt(1.d0-ecc*ecc)*sep*sep*oorb
221 IF (kstar(i).LE.10.OR.
222 & (kstar(i).GT.10.AND.mod(kstar(i),2).EQ.0))
THEN
223 kstar(i) = kstar(i) + 1
226 WRITE (6,8) name(j1), name(j2), tphys, kw1, kw2,
227 & kstar(i), mass, sep, tk, rad, rl1
228 8
FORMAT (
' NEW ROCHE NAM TP K* M A P R* RL ',
229 & 2i6,f9.2,3i4,2f8.4,f8.2,1p,4e10.2)
230 IF(kstar(i).EQ.50)
THEN
231 WRITE(6,9)name(j1),name(j2),kw1,kw2
232 9
FORMAT(
' WARNING: TOO MUCH ROCHE NAM K* ',2i6,2i3)
241 OPEN(unit=85,
status=
'NEW',form=
'FORMATTED',
245 94
FORMAT (/,
' NAM1 NAM2 K1 K2 TPHYS AGE1 ',
246 &
' AGE2 M01 M02 M1 M2 Z ',
247 &
' e P JSPIN1 JSPIN2')
250 WRITE(85,95)name(j1),name(j2),kstar(j1),kstar(j2),
251 & kstar(i),tphys,aj(1),aj(2),
252 & mass0(1),mass0(2),mass(1),mass(2),
253 & zmet,ecc,tk,jspin(1),jspin(2),ch5
254 95
FORMAT(2i7,3i3,3f10.3,4f7.3,f7.4,f6.3,1p,3e12.4,a5)
260 CALL
trdot(j1,dtm,m1)
267 IF (sep.LT.10.0)
THEN
268 dsepg = -1.663d-09*mass(1)*mass(2)*(mass(1) + mass(2))/
269 & (sep*sep*sep)*1.0d+06
270 dtgr = -0.1d0*sep/dsepg
272 IF (kstar(j1).LE.1.AND.
273 & mass(1).GT.0.35.AND.mass(1).LT.1.25)
THEN
274 dsepm = -4.574d-07*(mass(1) + mass(2))**2*
275 & radx(1)**3/(mass(2)*sep**4)*1.0d+06
276 dtmb = -0.1d0*sep/dsepm
283 zmu0 = body(j1)*body(j2)/body(i)
289 10 tk = semi*sqrt(semi/body(i))
296 zmu0 = body(j1)*body(j2)/body(i)
301 dme = 2.08d-03*eddfac*(1.d0/(1.d0 + zpars(11)))*rad(2)*tb
305 rdmin = 0.0425d0*sep*(q(2)*(1.d0+q(2)))**(1.d0/4.d0)
306 IF(rdmin.GT.rad(2)) disk = .true.
312 tkh(k) = 1.0d+07*mass(k)/(rad(k)*zlmsty(j))
313 IF(kstar(j).LE.1.OR.kstar(j).EQ.7.OR.kstar(j).GE.10)
THEN
314 tkh(k) = tkh(k)*mass(k)
316 tkh(k) = tkh(k)*(mass(k) - massc(k))
322 tdyn = 5.05d-05*sqrt(rad(1)**3/mass(1))
325 IF(kstar(j1).EQ.2)
THEN
327 ELSEIF(kstar(j1).EQ.3.OR.kstar(j1).EQ.5.OR.kstar(j1).EQ.6)
THEN
331 qc = 0.362d0 + 1.d0/(3.d0*(1.d0 - massc(1)/mass(1)))
332 ELSEIF(kstar(j1).EQ.8.OR.kstar(j1).EQ.9)
THEN
338 IF(kstar(j1).EQ.0.AND.q(1).GT.0.695)
THEN
343 taum = sqrt(tkh(1)*tdyn)
345 IF (kstar(j2).LE.1)
THEN
349 dm2 = taum/tkh(2)*dm1
350 mass(2) = mass(2) + dm2
355 CALL
star(kstar(j2),mass0(2),mass(2),tm,tn,
356 & tscls,lums,gb,zpars)
359 IF(mass(2).LT.0.35.OR.mass(2).GT.1.25)
THEN
360 aj(2) = tm/tms(2)*aj(2)*(mass(2) - dm2)/mass(2)
362 aj(2) = tm/tms(2)*aj(2)
364 epoch(j2) = tphys0 - aj(2)
368 WRITE(6,16)name(j2),mass(2),tm,tphys,aj(2)
369 16
FORMAT(
' NEW BS (ROCHE): NAM M3 TM TP AGE ',
373 ELSEIF(kstar(j2).LE.6)
THEN
378 mass(2) = mass(2) + dm2
379 IF(kstar(j2).EQ.2)
THEN
381 CALL
star(kstar(j2),mass0(2),mass(2),tm,tn,
382 & tscls,lums,gb,zpars)
383 aj(2) = tm + tscls(1)*(aj(2)-tms(2))/tbgb(2)
384 epoch(j2) = tphys0 - aj(2)
386 ELSEIF(kstar(j2).LE.12)
THEN
391 IF (min(kstar(j1),kstar(j2)).LT.0)
THEN
394 kst = ktype(kstar(j1),kstar(j2))
396 IF(kst.GT.100) kst = kst - 100
404 IF((kstar(j2).EQ.10.AND.mass(2).LT.0.05d0).OR.
405 & (kstar(j2).GE.11.AND.mass(2).LT.0.5d0))
THEN
407 mass(1) = mass(2) + dm2
410 mass(2) = mass(2) + dm2
411 CALL
gntage(massc(2),mass(2),kst,zpars,mass0(2),aj(2))
412 epoch(j2) = tphys0 - aj(2)
419 dm2 = min(dme*taum/tb,dm1)
420 IF(dm2.LT.dm1) supedd = .true.
421 mass(2) = mass(2) + dm2
424 IF(mass(2).GT.0.d0) mass(1) = 0.d0
427 ELSEIF(((abs(abs(2*kstar(j1)-11)-3).EQ.2.OR.kstar(j1).EQ.9).
428 & and.(q(1).GT.qc.OR.radx(1).LE.radc(1))).OR.
429 & (kstar(j1).EQ.2.AND.q(1).GT.qc).OR.
430 & (kstar(j1).EQ.4.AND.q(1).GT.qc))
THEN
436 WRITE (6,20) mass, kstar(j1), kstar(j2), rad, rol, sep
437 20
FORMAT (
' NEW CE M K R RL A ',2f7.3,2i3,4f9.3,f9.3)
440 CALL
comenv(mass0(1),mass(1),massc(1),aj(1),jspin(1),kw1,
441 & mass0(2),mass(2),massc(2),aj(2),jspin(2),kw2,
443 WRITE (6,25) mass, kw1, kw2, sep
444 25
FORMAT (
' END CE M K A ',2f7.3,2i3,f9.3)
449 epoch(j1) = tphys0 - aj(1)
453 IF(kstar(j1).LT.13.AND.(kw1.EQ.13.OR.kw1.EQ.14))
THEN
457 IF (kstar(j2).LT.13.AND.(kw2.EQ.13.OR.kw2.EQ.14))
THEN
461 IF(kstar(j1).LT.10.AND.kw1.GE.10.AND.kw1.LE.12)
THEN
465 IF(kstar(j2).LT.10.AND.kw2.GE.10.AND.kw2.LE.12)
THEN
479 epoch(j2) = tphys0 - aj(2)
481 ELSEIF(kstar(j1).GE.10.AND.kstar(j1).LE.12.AND.q(1).GE.0.628)
THEN
485 taum = sqrt(tkh(1)*tdyn)
487 IF(eddfac.LT.10.d0)
THEN
488 dm2 = min(dme*taum/tb,dm1)
489 IF(dm2.LT.dm1) supedd = .true.
493 mass(2) = mass(2) + dm2
494 IF(kstar(j1).EQ.10.AND.kstar(j2).EQ.10)
THEN
501 ELSEIF(kstar(j1).EQ.10.OR.kstar(j2).EQ.10)
THEN
508 IF(kstar(j2).EQ.10) massc(j2) = dm2
509 CALL
gntage(massc(2),mass(2),kstar(j2),zpars,mass0(2),aj(2))
510 epoch(j2) = tphys0 - aj(2)
511 ELSEIF(kstar(j2).LE.12)
THEN
525 IF(kstar(j2).LE.11.AND.mass(2).GT.mch)
THEN
526 WRITE (6,27) name(j1), name(j2), kstar(j2), mass(2)
527 27
FORMAT (
' ROCHE SN NAM K2* M2 ',2i6,i4,f6.2)
535 ELSEIF(kstar(j1).EQ.13)
THEN
543 mass(2) = mass(2) + dm2
547 ELSEIF(kstar(j1).EQ.14)
THEN
555 mass(2) = mass(2) + dm2
562 dm1 = 3.0d-06*tb*(log(rad(1)/rol(1))**3)*
563 & min(mass(1),5.d0)**2
564 IF(kstar(j1).EQ.2)
THEN
565 mew = (mass(1) - massc(1))/mass(1)
566 dm1 = max(mew,0.01d0)*dm1
567 ELSEIF(kstar(j1).GE.10)
THEN
568 dm1 = dm1*1.0d+03/max(rad(1),1.0d-04)
575 IF(kstar(j1).GE.2.AND.kstar(j1).LE.9.AND.kstar(j1).NE.7)
THEN
576 dm1 = min(dm1,mass(1)*tb/tkh(1))
577 ELSEIF(rad(1).GT.10.d0*rol(1).OR.(kstar(j1).LE.1.AND.
578 & kstar(j2).LE.1.AND.q(1).GT.qc))
THEN
583 WRITE (6,28) sep, dm1, rad(1), rol(1)
584 28
FORMAT (
' OVERFILL A DM1 RAD ROL ',f7.1,1p,3e10.2)
591 dm1 = min(dm1,mass(1)*tb/tdyn)
596 vorb2 = acc1*(mass(1)+mass(2))/sep
597 ivsqm = 1.d0/sqrt(1.d0-ecc*ecc)
600 rlperi = rol(k)*(1.d0-ecc)
601 dmr(k) =
mlwind(kstar(j),zlmsty(j),radx(k),
602 & mass(k),massc(k),rlperi,zmet)
603 vwind2 = 2.d0*beta*acc1*mass(k)/radx(k)
604 omv2 = (1.d0 + vorb2/vwind2)**(3.d0/2.d0)
605 dma(3-k) = ivsqm*acc2*dmr(k)*((acc1*mass(3-k)/vwind2)**2)/
606 & (2.d0*sep*sep*omv2)
607 dma(3-k) = min(dma(3-k),dmr(k))
612 dms(k) = (dmr(k)-dma(k))*tb
616 km = 5.0d-03/max(abs(dm1+dms(1))/mass(1),dms(2)/mass(2))
617 km = min(km,2.d0*km0)
625 IF(iter.LE.100) dtm = min(dtm,dtmi(1),dtmi(2))
626 dtm = min(dtm,(time-tev0(i))*tstar)
627 dtm = max(dtm,1.0d-10)
632 taum = mass(2)/dm1*tb
633 IF(kstar(j2).LE.2.OR.kstar(j2).EQ.4)
THEN
637 dm2 = min(1.d0,10.d0*taum/tkh(2))*dm1
638 ELSEIF(kstar(j2).GE.7.AND.kstar(j2).LE.9)
THEN
643 IF(kstar(j1).GE.7)
THEN
644 dm2 = min(1.d0,10.d0*taum/tkh(2))*dm1
647 dmchk = dm2 - 1.05d0*dms(2)
648 IF(dmchk.GT.0.d0.AND.dm2/mass(2).GT.1.0d-04)
THEN
649 kst = min(6,2*kstar(j2)-10)
656 m2 = mass(2) + km*(dm2 - dms(2))
657 CALL
gntage(mcx,m2,kst,zpars,mass0(2),aj(2))
658 epoch(j2) = tphys0 + dtm - aj(2)
661 ELSEIF(kstar(j1).LE.6.AND.
662 & (kstar(j2).GE.10.AND.kstar(j2).LE.12))
THEN
666 IF(dm1/tb.LT.2.71d-07)
THEN
667 IF(dm1/tb.LT.1.03d-07)
THEN
673 IF(dm2.LT.dm1) supedd = .true.
690 IF((kstar(j2).EQ.10.AND.mass(2).LT.0.05d0).OR.
691 & (kstar(j2).GE.11.AND.mass(2).LT.0.5d0))
THEN
694 kst = min(6,3*kstar(j2)-27)
695 m2 = mass(2) + km*(dm2 - dms(2))
696 CALL
gntage(massc(2),m2,kst,zpars,mass0(2),aj(2))
697 epoch(j2) = tphys0 + dtm - aj(2)
700 ELSEIF(kstar(j2).GE.10)
THEN
705 IF(dm2.LT.dm1) supedd = .true.
712 IF(.NOT.novae) dm22 = dm2
714 IF(kst.GE.10.AND.kst.LE.12)
THEN
715 mt2 = mass(2) + km*(dm22 - dms(2))
716 IF(kstar(j1).LE.10.AND.kst.EQ.10.AND.mt2.GE.0.7)
THEN
721 mass(1) = mass(1) - km*(dm1 + dms(1))
726 ELSEIF(kstar(j1).LE.10.AND.kst.GE.11)
THEN
736 IF((mt2-mass0(2)).GE.0.15)
THEN
738 mass(1) = mass(1) - km*(dm1 + dms(1))
757 IF(kst.EQ.11.AND.dm22.GT.0.4d0*dme/eddfac) kst = 12
758 IF((kst.EQ.10.OR.kst.EQ.11).AND.mt2.GE.mch)
THEN
759 dm1 = mch - mass(2) + km*dms(2)
760 mass(1) = mass(1) - dm1 - km*dms(1)
779 jorb = mass(1)*mass(2)/(mass(1)+mass(2))
780 & *sqrt(1.d0-ecc*ecc)*sep*sep*oorb
784 djorb = ((dmr(1)+q(1)*dma(1))*mass(2)*mass(2) +
785 & (dmr(2)+q(2)*dma(2))*mass(1)*mass(1))*
786 & sep*sep*oorb/(mass(1)+mass(2))**2
798 IF(supedd.OR.novae.OR.gamm1.LT.-1.5d0)
THEN
799 djorb = djorb + (dm1 - dm22)*mass(1)*mass(1)*
800 & sep*sep*oorb/(mass(1)+mass(2))**2
801 ELSEIF(gamm1.GE.0.d0)
THEN
802 djorb = djorb + gamm1*(dm1 - dm2)*sep*sep*oorb
804 djorb = djorb + (dm1 - dm2)*mass(2)*mass(2)*
805 & sep*sep*oorb/(mass(1)+mass(2))**2
811 CALL
grrad(mass(1),mass(2),sep,ecc,jorb,djgr,delet1)
816 IF(sep.LT.1.05*(rad(1) + rad(2)))
THEN
817 IF (mod(igr,10).EQ.0)
WRITE (6,45) mass, sep, djgr, dtm
818 45
FORMAT (
' GR BRAKE M1 M2 SEP DJ DTM ',2f7.3,1p,3e10.2)
823 IF(kstar(j1).LT.10) dms(1) = min(dms(1),mass(1) - massc(1))
825 IF(kstar(j2).LT.10) dms(2) = min(dms(2),mass(2) - massc(2))
829 djspin(1) = (2.d0/3.d0)*(dmr(1)*radx(1)*radx(1)*ospin(1) -
830 & xi*dma(1)*radx(2)*radx(2)*ospin(2))*dtm0
831 djspin(2) = (2.d0/3.d0)*(dmr(2)*radx(2)*radx(2)*ospin(2) -
832 & xi*dma(2)*radx(1)*radx(1)*ospin(1))*dtm0
833 IF(kstar(j1).LT.10.AND.mass(1).GE.0.35)
THEN
834 CALL
magbrk(kstar(j1),mass(1),menv(1),rad(1),ospin(1),djmb)
835 djspin(1) = djspin(1) + djmb*dtm0
837 IF(jspin(1).GT.0.d0)
THEN
838 IF(imb.LT.2.OR.abs(djmb)/jspin(1).GT.0.03)
THEN
839 WRITE (6,40) mass, sep, djmb, dtm
840 40
FORMAT (
' MB BRAKE M1 M2 SEP DJSPN DTM ',
845 IF(kstar(j2).LT.10.AND.mass(2).GE.0.35)
THEN
846 CALL
magbrk(kstar(j2),mass(2),menv(2),rad(2),ospin(2),djmb)
847 djspin(2) = djspin(2) + djmb*dtm0
849 IF(jspin(2).GT.0.d0)
THEN
850 IF(imb.LT.10.OR.abs(djmb)/jspin(2).GT.0.001)
THEN
851 WRITE (6,40) mass, sep, djmb, dtm
859 djt = dm1*radx(1)*radx(1)*ospin(1)
860 djspin(1) = djspin(1) + djt
868 djt = dm2*twopi*aursun*sqrt(aursun*mass(2)*radx(2))
869 djspin(2) = djspin(2) - djt
880 djt = dm2*twopi*aursun*sqrt(aursun*mass(2)*rdisk)
881 djspin(2) = djspin(2) - djt
889 djt = (dm2 - dm22)*radx(2)*radx(2)*ospin(2)
890 djspin(2) = djspin(2) + djt
898 IF((kstar(j).LE.9.AND.rad(k).GE.0.01d0*rol(k)).OR.
899 & (kstar(j).GE.10.AND.j.EQ.j1))
THEN
901 CALL
bsetid(kstar(j),mass(k),massc(k),menv(k),radx(k),
902 & radc(k),renv(k),zlmsty(j),ospin(k),k2str(k),
903 & q(3-k),sep,ecc,oorb,delet1,dspin,eqspin,djt)
905 delet = delet + delet1*dtm0
906 IF(dtm0.GT.0.d0.AND.abs(dspin).GE.tiny)
THEN
908 IF(dspin.GE.0.d0)
THEN
909 dspin = min(dtm0*dspin,eqspin-ospin(k))/dtm0
911 dspin = max(dtm0*dspin,eqspin-ospin(k))/dtm0
913 djt = djt*dspin/dspin0
917 djorb = djorb + djt*dtm0
918 djspin(k) = djspin(k) - djt*dtm0
928 mass(1) = mass(1) - dm1 - dms(1)
929 IF(kstar(j1).LE.1.OR.kstar(j1).EQ.7) mass0(1) = mass(1)
930 mass(2) = mass(2) + dm22 - dms(2)
931 IF(kstar(j2).LE.1.OR.kstar(j2).EQ.7) mass0(2) = mass(2)
938 jspin(k) = max(jspin(k) - djspin(k),1.0d-10)
939 ospbru = twopi*sqrt(mass(k)*aursun**3/radx(k)**3)
940 jspbru = (k2str(k)*(mass(k)-massc(k))*radx(k)*radx(k) +
941 & k3*massc(k)*radc(k)*radc(k))*ospbru
942 IF(jspin(k).GT.jspbru)
THEN
943 djorb = djorb - (jspin(k) - jspbru)
946 IF(kstar(j).EQ.2.AND.mass0(k).LE.zpars(3))
THEN
949 CALL
star(kstar(j),mass0(k),mass(k),tmsnew,tn,tscls,
951 IF(gb(9).LT.massc(k)) mass0(k) = m01
958 dms(2) = dms(2) + dm1 - dm22
962 ecc = max(ecc - delet,0.001d0)
963 jorb = max(jorb - djorb,0.d0)
964 sep = (mass(1) + mass(2))*jorb*jorb/
965 & ((mass(1)*mass(2)*twopi)**2*aursun**3*(1.d0-ecc*ecc))
966 sep = max(sep,rad(2))
985 IF(kstar(j1).LE.2.OR.kstar(j1).EQ.7)
THEN
986 CALL
star(kstar(j1),mass0(1),mass(1),tm,tn,
987 & tscls,lums,gb,zpars)
988 IF(kstar(j1).EQ.2)
THEN
989 aj(1) = tm + (tscls(1)-tm)*(aj(1)-tms(1))/(tbgb(1)-tms(1))
991 aj(1) = tm/tms(1)*aj(1)
993 epoch(j1) = tphys0 - aj(1)
996 IF(kstar(j2).LE.2.OR.kstar(j2).EQ.7)
THEN
997 CALL
star(kstar(j2),mass0(2),mass(2),tm,tn,
998 & tscls,lums,gb,zpars)
999 IF(kstar(j2).EQ.2)
THEN
1000 aj(2) = tm + (tscls(1)-tm)*(aj(2)-tms(2))/(tbgb(2)-tms(2))
1001 ELSEIF((mass(2).LT.0.35.OR.mass(2).GT.1.25).AND.
1002 & kstar(j2).NE.7)
THEN
1003 aj(2) = tm/tms(2)*aj(2)*(mass(2) - dm22)/mass(2)
1005 aj(2) = tm/tms(2)*aj(2)
1007 epoch(j2) = tphys0 - aj(2)
1010 IF(kstar(j2).LE.1)
THEN
1011 IF(tms(2).GT.tphys.AND.tm.LT.tphys)
THEN
1013 WRITE(6,48)name(j2),mass(2),dm2,semi*su,tm,tphys,
1015 48
FORMAT (
' NEW BR NAM M2 DM2 A TM TP KW1 ',
1016 & i6,2f7.3,3f8.1,i4)
1021 tphys0 = tphys0 + dtm
1025 50 zmsy = zmsy + dms(1) + dms(2)
1028 body(j1) = mass(1)/zmbar
1029 body(j2) = mass(2)/zmbar
1030 body0(j1) = mass0(1)/zmbar
1031 body0(j2) = mass0(2)/zmbar
1034 dmt = dms(1) + dms(2)
1036 body(i) = body(i) - dmt
1037 h(ipair) = -0.5d0*body(i)/semi
1041 IF (dmt.GT.0.0)
THEN
1042 dt2 = min(dt2,0.02d0*body(j1)*dtm/(dmt*tstar))
1055 IF (dmt*smu.LT.0.05)
THEN
1061 ELSE IF (abs(semi - semi0).GT.1.0d-10*semi)
THEN
1067 zmu = body(j1)*body(j2)/body(i)
1068 emdot = emdot + zmu0*hi - zmu*h(ipair)
1069 egrav = egrav + zmu0*hi - zmu*h(ipair)
1070 de = zmu0*hi - zmu*h(ipair)
1076 tb = yrs*semi*sqrt(semi/body(i))
1081 tphys = (time+toff)*tstar
1082 body0(j1) = mass0(1)/zmbar
1083 body0(j2) = mass0(2)/zmbar
1084 spin(j1) = jspin(1)/spnfac
1085 spin(j2) = jspin(2)/spnfac
1091 IF(mass(1).EQ.0.0.AND.mass(2).NE.0.0)
THEN
1096 tev(j1) = tphys0/tstar
1099 WRITE(85,95)name(j1),name(j2),kw1,kw2,kstar(i),
1100 & tphys,aj(k),tk,mass0(k),mass0(3-k),
1101 & mass(k),tk,zmet,ecc,tk,jspin(k),tk,ch5
1103 CALL
coal(ipair,kw1,kw2,mass)
1112 age = tphys0 - epoch(j)
1117 CALL
star(kw,m01,m1,tm,tn,tscls,lums,gb,zpars)
1118 CALL
hrdiag(m01,age,m1,tm,tn,tscls,lums,gb,zpars,
1119 & r1,lum,kw,mc,rcc,m1ce,rce,k2)
1120 CALL
trdot2(kw,age,tm,tn,tscls,dtmi(k),dtr)
1121 IF(k.EQ.1) dtmax = dtr/tstar
1125 tev(j) = tphys0/tstar
1132 IF((kstar(j).LT.13.AND.kw.GE.13).OR.
1133 & (kstar(j).LT.10.AND.kw.GE.10.AND.kw.LE.12))
THEN
1135 body0(j) = mass0(k)/zmbar
1136 body(j) = mass(k)/zmbar
1137 spin(j) = jspin(k)/spnfac
1146 IF(kw.NE.kstar(j))
THEN
1147 epoch(j) = tphys0 - age
1150 body0(j) = mass0(k)/zmbar
1152 body(j) = mass(k)/zmbar
1164 q(k) = mass(k)/mass(3-k)
1165 rol(k) =
rl(q(k))*sep
1168 radx(k) = min(radx(k),rol(k))
1169 radx(k) = max(rcc,radx(k))
1171 ospin(k) = jspin(k)/(k2*radx(k)*radx(k)*(m1-mc) +
1173 spin(j) = jspin(k)/spnfac
1181 kstar(i) = kstar(i) + 1
1183 WRITE(85,95)name(j1),name(j2),kstar(j1),kstar(j2),kstar(i),
1184 & tphys,aj(1),aj(2),mass0(1),mass0(2),
1185 & mass(1),mass(2),zmet,ecc,tk,jspin(1),jspin(2),ch5
1188 ELSE IF(iq.GT.0)
THEN
1190 tev(j1) = tphys0/tstar
1192 kstar(i) = kstar(i) + 1
1195 WRITE(85,95)name(j1),name(j2),kstar(j1),kstar(j2),kstar(i),
1196 & tphys,aj(1),aj(2),mass0(1),mass0(2),
1197 & mass(1),mass(2),zmet,ecc,tk,jspin(1),jspin(2),ch5
1198 WRITE (6,71) name(iq), name(j1), name(j2), kstar(j1),
1199 & kstar(j2), kw1, mass(1), mass(2), rad(1), rol(1)
1200 71
FORMAT (
' ROCHE TERM NAM K* KW M R1 RL1 ',
1201 & 3i6,3i4,2f7.3,2f8.2)
1206 IF(iter.EQ.0.AND.inew.EQ.1)
THEN
1215 fac0 = ospin(1)/oorb
1221 IF(fac.GT.1.d0) fac = 1.d0/fac
1223 IF((ecc-0.001d0).GT.tiny.OR.fac.LT.0.98d0)
THEN
1230 IF((kstar(j).LE.9.AND.rad(k).GE.0.01d0*rol(k)).OR.
1231 & (kstar(j).GE.10.AND.j.EQ.j1))
THEN
1233 CALL
bsetid(kstar(j),mass(k),massc(k),menv(k),radx(k),
1234 & radc(k),renv(k),zlmsty(j),ospin(k),k2str(k),
1235 & q(3-k),sep,ecc,oorb,delet1,dspin,eqspin,djt)
1237 delet = delet + delet1
1244 CALL
grrad(mass(1),mass(2),sep,ecc,jorb,djgr,delet1)
1245 delet = delet + delet1
1247 CALL
magbrk(kstar(j1),mass(1),menv(1),rad(1),ospin(1),djmb)
1248 djspin(1) = djtk(1) + djmb
1253 IF(ecc.GT.0.001d0)
THEN
1254 IF(abs(delet).GT.1.0d-14)
THEN
1256 dtm0 = max(0.1d0*ecc,0.0005d0)/abs(delet)
1257 dtmmin = min(0.01d0,ecc-0.001d0)/abs(delet)
1264 sep = jorb*(mass(1)+mass(2))/(mass(1)*mass(2)*oorb)
1266 tb = (sep/aursun)*sqrt(sep/(aursun*(mass(1)+mass(2))))
1273 IF(abs(djspin(1)).GT.1.0d-14)
THEN
1274 IF(abs(dspink(1)).GT.1.0d-20)
THEN
1275 tsyn = abs(oorb-ospin(1))/abs(dspink(1))
1276 dtm0 = min(dtm0,0.3d0*tsyn)
1278 ttid = min(ttid,tsyn)
1281 dtm0 = min(dtm0,0.5d0*jspin(1)/abs(djspin(1)))
1285 IF(iterb.EQ.0.AND.nwarn.LT.50)
THEN
1286 WRITE(6,710)name(j1),kstar(j1),kstar(j2),ecc0,fac0,
1288 710
FORMAT(
' CIRC & SYNCH NM K* ECC0 SPIN1/OORB TC TSYN ',
1289 & i7,2i4,f7.4,f9.3,1p,2e10.2)
1293 IF(ttid.LT.min(tphys,10.d0))
THEN
1295 dtm0 = max(dtm0,dtmmin)
1297 81 djorb = djgr*dtm0
1299 djspin(1) = djmb*dtm0
1300 CALL
magbrk(kstar(j2),mass(2),menv(2),rad(2),ospin(2),
1302 djspin(2) = djmb*dtm0
1305 IF(dspink(k).GT.1.0d-10)
THEN
1306 dspin0 = min(dtm0*dspink(k),eqspin-ospin(k))/dtm0
1307 djtk(k) = dspin0*djtk(k)/dspink(k)
1308 ELSEIF(dspink(k).LT.-1.0d-10)
THEN
1309 dspin0 = max(dtm0*dspink(k),eqspin-ospin(k))/dtm0
1310 djtk(k) = dspin0*djtk(k)/dspink(k)
1314 djorb = djorb + djtk(k)*dtm0
1315 djspin(k) = djspin(k) - djtk(k)*dtm0
1319 jspin(k) = max(jspin(k) - djspin(k),1.0d-10)
1320 ospbru = twopi*sqrt(mass(k)*aursun**3/radx(k)**3)
1321 jspbru = (k2str(k)*(mass(k)-massc(k))*radx(k)*radx(k)
1322 & + k3*massc(k)*radc(k)*radc(k))*ospbru
1323 IF(jspin(k).GT.jspbru)
THEN
1324 djorb = djorb - (jspin(k) - jspbru)
1327 ospin(k) = jspin(k)/
1328 & (k2str(k)*radx(k)*radx(k)*(mass(k)-massc(k))
1329 & + k3*radc(k)*radc(k)*massc(k))
1332 IF (abs(djorb).GT.0.1*jorb.AND.itro.LE.5)
THEN
1333 dtm0 = 0.1*jorb*dtm0/abs(djorb)
1334 delet = 0.1*jorb*delet/abs(djorb)
1336 IF (jorb.GT.0.0d0)
WRITE (6,83) djorb/jorb, jorb
1337 83
FORMAT (
' ROCHE LIMIT DJO/JORB JORB ',1p,2e10.2)
1341 ecc = max(ecc - delet,0.001d0)
1342 jorb = max(jorb - djorb,0.d0)
1344 sep = (mass(1) + mass(2))*jorb*jorb/
1345 & ((mass(1)*mass(2)*twopi)**2*aursun**3*(1.d0-ecc*ecc))
1346 sep = max(sep,rad(2))
1348 IF (rad(1)+rad(2).LT.sep)
THEN
1353 rol(k) =
rl(q(k))*sep
1355 radx(1) = min(rad(1),rol(1))
1356 radx(1) = max(radc(1),radx(1))
1358 tb = (sep/aursun)*sqrt(sep/(aursun*(mass(1)+mass(2))))
1362 IF(iterb.LE.100) goto 80
1364 IF(ecc.GT.0.02d0)
THEN
1365 WRITE(6,*)
' WARNING: will not circularize'
1367 IF(fac.LT.0.98d0.AND.kstar(j1).LT.10)
THEN
1368 WRITE(6,*)
' WARNING: will not synchronize'
1374 WRITE(6,711)ecc,ospin(1)/oorb,sep,tk,rad(1),rol(1)
1375 711
FORMAT(
' NEW PARAMS ECC SPIN1/OORB A P R1 RL1 ',
1376 & f7.4,f9.3,f8.2,1p,3e10.2)
1377 spin(j1) = jspin(1)/spnfac
1378 spin(j2) = jspin(2)/spnfac
1383 h(ipair) = -0.5d0*body(i)/semi
1389 CALL
deform(ipair,ecc0,ecc)
1390 zmu = body(j1)*body(j2)/body(i)
1391 emdot = emdot + zmu*(hi - h(ipair))
1392 egrav = egrav + zmu*(hi - h(ipair))
1399 IF(tev(j).GE.tplot.AND..NOT.isave)
THEN
1404 IF(name(j1).EQ.namer(1,k)) ii = name(j1)
1405 IF(name(j1).EQ.namer(2,k)) ii = name(j1)
1409 IF(nrsave.GT.mmax)
THEN
1411 IF (iwarn.LT.20)
THEN
1412 WRITE(6,*)
' ROCHE WARNING: NRSAVE > MMAX'
1416 namer(1,nrsave) = name(j1)
1417 namer(2,nrsave) = name(j2)
1418 kstarr(1,nrsave) = kstar(i)
1419 kstarr(2,nrsave) = kstar(j1)
1420 kstarr(3,nrsave) = kstar(j2)
1421 cmrch(1,nrsave) = semi
1423 cmrch(k+1,nrsave) = x(k,i)
1424 cmrch(k+4,nrsave) = xdot(k,i)
1426 cmrch(8,nrsave) = body0(j1)
1427 cmrch(9,nrsave) = body(j1)
1428 cmrch(10,nrsave) = epoch(j1)
1429 cmrch(11,nrsave) = body0(j2)
1430 cmrch(12,nrsave) = body(j2)
1431 cmrch(13,nrsave) = epoch(j2)
1437 IF(rad(1).GT.rol(1))
THEN
1441 IF (rad(2).GT.rol(2).AND.iter.GT.0)
THEN
1443 WRITE (6,72) mass(1), mass(2), kstar(j1), kstar(j2), sep
1444 72
FORMAT (
' CONTACT M1 M2 KW1 KW2 A ',2f7.3,2i3,f8.3)
1452 IF (iwarn.LT.100.AND.rad(1).GT.2.0*rol(1))
THEN
1454 WRITE (6,73) kstar(j1), kstar(j2), mass(1), mass(2),
1455 & rad(1), rol(1), dm1, dm2, dtm
1456 73
FORMAT (
' BIG ROCHE K12 M12 R1 RL1 DM12 DT ',
1457 & 2i3,2f7.3,2f8.3,1p,3e10.2)
1461 IF (iter.EQ.1.AND.inew.GT.0.AND.kstar(j2).GE.10)
THEN
1462 IF (abs(dtm).GT.1.0d-20)
THEN
1463 pd = days*semi*sqrt(semi/body(i))
1464 WRITE (22,58) name(j1), name(j2),
1465 & kstar(j1), kstar(j2),
1466 & mass(1), mass(2), tphys, semi*su, pd,
1467 & dm1/dtm/1.0e+06, dm2/dtm/1.0e+06
1468 58
FORMAT (
' DEGEN ROCHE NAM K* M TP A P M1D M2D ',
1469 & 2i6,2i4,2f6.2,f8.1,2f7.1,1p,2e9.1)
1475 IF(tev0(i).LT.time) goto 10
1476 IF (iter.EQ.1.AND.gamma(ipair).LT.gmin) go to 10
1478 WRITE (6,76) kstar(j1), kstar(j2), mass(1),
1479 & mass(2),rad(1), rol(1), dm1, dm2, dtm
1480 76
FORMAT(
' END ROCHE K12 M12 R1 RL1 DM DT ',
1481 & 2i3,2f7.3,2f8.2,2f8.3,1p,e10.2)
1483 IF(max(kstar(j1),kstar(j2)).GE.10)
THEN
1485 CALL
degen(ipair,ipair,4)
1490 IF (kstar(j1).GE.10.AND.kstar(j1).LE.12) nwd = nwd + 1
1492 kstar(i) = kstar(i) + 1
1495 IF (kz(8).GT.3)
THEN
1499 WRITE(85,95)name(j1),name(j2),kstar(j1),kstar(j2),kstar(i),
1500 & tphys,aj(1),aj(2),mass0(1),mass0(2),
1501 & mass(1),mass(2),zmet,ecc,tk,jspin(1),jspin(2),ch5
1506 IF(iter.EQ.0) goto 150
1510 IF (mod(kstar(i),2).EQ.1.AND.iq.EQ.0)
THEN
1511 tev(i) = tphys0/tstar
1513 IF(list(1,i1).GT.0)
THEN
1514 dtmax = min(dtmax,50.d0*dt1)
1516 dtmax = min(dtmax,10.d0*dt1)
1518 dtmax = min(dtmax,dt2)
1520 tev(i) = tev(i) + max(dtmax,1.0d-07)
1521 tev(j1) = tev(i) + 2.0*stepx + step(i1)
1523 tmdot = min(tmdot,tev(i))
1524 z = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(body(i)*semi)
1526 IF (ecc.GT.0.01)
THEN
1527 qp = semi*(1.0 - ecc)
1529 CALL
tcirc(qp,ecc,i1,i2,icirc,tc)
1530 WRITE (6,142) time+toff, name(j1), kstar(j1), kstar(j2),
1531 & list(1,i1), mass(1), mass(2), ecc,
1533 142
FORMAT (
' ECCENTRIC ROCHE T NM K* NP M E A TC ',
1534 & f8.1,i6,3i4,3f6.2,2f7.1)
1540 CALL
trdot(j1,dtm,mass(1))
1541 tev(j1) = tev(j1) + dtm
1542 CALL
trdot(j2,dtm,mass(2))
1543 tev(j2) = min(tev(j1),tev(j2) + dtm)
1546 kw = min(kstar(j1),kstar(j2))
1547 IF(kw.GT.6) tev(j2) = min(tev(j2),time+0.1d0)
1553 tphys = (time+toff)*tstar
1556 dm = (body(j1) + body(j2)) - body(i)
1557 IF(abs(dm).GT.0.0001*body(i))
THEN
1558 WRITE (6,145) time+toff, body(j1), body(j2), body(i)
1559 145
FORMAT (
' DANGER! ROCHE T M ',f10.3,1p,3e12.4)
1560 body(i) = body(i) + dm
1565 150
IF(iphase.GE.0) goto 140
1566 160 tphys = (time+toff)*tstar
1571 WRITE(85,95)name(j1),name(j2),kstar(j1),kstar(j2),kstar(i),
1572 & tphys,aj(1),aj(2),mass0(1),mass0(2),
1573 & mass(1),mass(2),zmet,ecc,tk,jspin(1),jspin(2),ch5
1574 IF(time-t0(i).LE.step(i))
THEN