forked from ahwkuepper/mcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrdiag.f
789 lines (789 loc) · 23 KB
/
hrdiag.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
***
SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars,
& r,lum,kw,mc,rc,menv,renv,k2)
*
*
* H-R diagram for population I stars.
* -----------------------------------
*
* Computes the new mass, luminosity, radius & stellar type.
* Input (MASS, AJ, TM, TN, LUMS & TSCLS) supplied by routine STAR.
* Ref: P.P. Eggleton, M.J. Fitchett & C.A. Tout (1989) Ap.J. 347, 998.
*
* Revised 27th March 1995 by C. A. Tout;
* 24th October 1995 to include metallicity;
* 14th November 1996 to include naked helium stars;
* 28th February 1997 to allow accretion induced supernovae.
*
* Revised 5th April 1997 by J. R. Hurley
* to include Z=0.001 as well as Z=0.02, convective overshooting,
* MS hook and more elaborate CHeB
*
implicit none
*
integer kw,kwp
INTEGER ceflag,tflag,ifflag,nsflag,wdflag
COMMON /FLAGS/ ceflag,tflag,ifflag,nsflag,wdflag
*
real*8 mass,aj,mt,tm,tn,tscls(20),lums(10),GB(10),zpars(20)
real*8 r,lum,mc,rc,menv,renv,k2
real*8 mch,mlp,tiny
parameter(mch=1.44d0,mlp=12.d0,tiny=1.0d-14)
real*8 mass0,mt0,mtc
REAL*8 neta,bwind,hewind,mxns
COMMON /VALUE1/ neta,bwind,hewind,mxns
*
real*8 thook,thg,tbagb,tau,tloop,taul,tauh,tau1,tau2,dtau,texp
real*8 lx,ly,dell,alpha,beta,eta
real*8 rx,ry,delr,rzams,rtms,gamma,rmin,taumin,rg
parameter(taumin=5.0d-08)
real*8 mcmax,mcx,mcy,mcbagb,lambda
real*8 am,xx,fac,rdgen,mew,lum0,kap,zeta,ahe,aco
parameter(lum0=7.0d+04,kap=-0.5d0,ahe=4.d0,aco=16.d0)
*
real*8 thookf,tblf
real*8 lalphf,lbetaf,lnetaf,lhookf,lgbtf,lmcgbf,lzhef,lpertf
real*8 rzamsf,rtmsf,ralphf,rbetaf,rgammf,rhookf
real*8 rgbf,rminf,ragbf,rzahbf,rzhef,rhehgf,rhegbf,rpertf
real*8 mctmsf,mcgbtf,mcgbf,mcheif,mcagbf,lzahbf
external thookf,tblf
external lalphf,lbetaf,lnetaf,lhookf,lgbtf,lmcgbf,lzhef,lpertf
external rzamsf,rtmsf,ralphf,rbetaf,rgammf,rhookf
external rgbf,rminf,ragbf,rzahbf,rzhef,rhehgf,rhegbf,rpertf
external mctmsf,mcgbtf,mcgbf,mcheif,mcagbf,lzahbf
*
*
* ---------------------------------------------------------------------
* MASS Stellar mass in solar units (input: old; output: new value).
* AJ Current age in Myr.
* MT Current mass in solar units (used for R).
* TM Main sequence time.
* TN Nuclear burning time.
* TSCLS Time scale for different stages.
* LUMS Characteristic luminosity.
* GB Giant Branch parameters
* ZPARS Parameters for distinguishing various mass intervals.
* R Stellar radius in solar units.
* TE Effective temperature (suppressed).
* KW Classification type (0 - 15).
* MC Core mass.
* ---------------------------------------------------------------------
*
*
* Make evolutionary changes to stars that have not reached KW > 5.
*
mass0 = mass
if(mass0.gt.100.d0) mass = 100.d0
mt0 = mt
if(mt0.gt.100.d0) mt = 100.d0
*
if(kw.gt.6) goto 90
*
tbagb = tscls(2) + tscls(3)
thg = tscls(1) - tm
*
rzams = rzamsf(mass)
rtms = rtmsf(mass)
*
if(aj.lt.tscls(1))then
*
* Either on MS or HG
*
rg = rgbf(mt,lums(3))
*
if(aj.lt.tm)then
*
* Main sequence star.
*
mc = 0.d0
tau = aj/tm
thook = thookf(mass)*tscls(1)
zeta = 0.01d0
tau1 = MIN(1.d0,aj/thook)
tau2 = MAX(0.d0,
& MIN(1.d0,(aj-(1.d0-zeta)*thook)/(zeta*thook)))
*
dell = lhookf(mass,zpars(1))
dtau = tau1**2 - tau2**2
alpha = lalphf(mass)
beta = lbetaf(mass)
eta = lnetaf(mass)
lx = LOG10(lums(2)/lums(1))
if(tau.gt.taumin)then
xx = alpha*tau + beta*tau**eta +
& (lx - alpha - beta)*tau**2 - dell*dtau
else
xx = alpha*tau + (lx - alpha)*tau**2 - dell*dtau
endif
lum = lums(1)*10.d0**xx
*
delr = rhookf(mass,zpars(1))
dtau = tau1**3 - tau2**3
alpha = ralphf(mass)
beta = rbetaf(mass)
gamma = rgammf(mass)
rx = LOG10(rtms/rzams)
* Note that the use of taumin is a slightly pedantic attempt to
* avoid floating point underflow. It IS overkill!
if(tau.gt.taumin)then
xx = alpha*tau + beta*tau**10 + gamma*tau**40 +
& (rx - alpha - beta - gamma)*tau**3 - delr*dtau
else
xx = alpha*tau + (rx - alpha)*tau**3 - delr*dtau
endif
r = rzams*10.d0**xx
*
if(mass.lt.(zpars(1)-0.3d0))then
kw = 0
* This following is given by Chris for low mass MS stars which will be
* substantially degenerate. We need the Hydrogen abundance, X, which we
* calculate from Z assuming that the helium abundance, Y, is calculated
* according to Y = 0.24 + 2*Z
rdgen = 0.0258d0*((1.d0+zpars(11))**(5.d0/3.d0))*
& (mass**(-1.d0/3.d0))
r = MAX(rdgen,r)
else
kw = 1
endif
*
else
*
* Star is on the HG
*
mcx = mc
if(mass.le.zpars(2))then
mc = mcgbf(lums(3),GB,lums(6))
elseif(mass.le.zpars(3))then
mc = mcheif(mass,zpars(2),zpars(9))
else
mc = mcheif(mass,zpars(2),zpars(10))
endif
eta = mctmsf(mass)
tau = (aj - tm)/thg
mc = ((1.d0 - tau)*eta + tau)*mc
mc = MAX(mc,mcx)
*
* Test whether core mass has reached total mass.
*
if(mc.ge.mt)then
aj = 0.d0
if(mass.gt.zpars(2))then
*
* Zero-age helium star
*
mc = 0.d0
mass = mt
kw = 7
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
else
*
* Zero-age helium white dwarf.
*
mc = mt
mass = mt
kw = 10
endif
else
lum = lums(2)*(lums(3)/lums(2))**tau
if(mass.le.zpars(3))then
rx = rg
else
* He-ignition and end of HG occur at Rmin
rmin = rminf(mass)
ry = ragbf(mt,lums(4),zpars(2))
rx = MIN(rmin,ry)
if(mass.le.mlp)then
texp = log(mass/mlp)/log(zpars(3)/mlp)
rx = rg
rx = rmin*(rx/rmin)**texp
endif
tau2 = tblf(mass,zpars(2),zpars(3))
if(tau2.lt.tiny) rx = ry
endif
r = rtms*(rx/rtms)**tau
kw = 2
endif
*
endif
*
* Now the GB, CHeB and AGB evolution.
*
elseif(aj.lt.tscls(2))then
*
* Red Giant.
*
kw = 3
lum = lgbtf(aj,GB(1),GB,tscls(4),tscls(5),tscls(6))
if(mass.le.zpars(2))then
* Star has a degenerate He core which grows on the GB
mc = mcgbf(lum,GB,lums(6))
else
* Star has a non-degenerate He core which may grow, but
* only slightly, on the GB
tau = (aj - tscls(1))/(tscls(2) - tscls(1))
mcx = mcheif(mass,zpars(2),zpars(9))
mcy = mcheif(mass,zpars(2),zpars(10))
mc = mcx + (mcy - mcx)*tau
endif
r = rgbf(mt,lum)
rg = r
if(mc.ge.mt)then
aj = 0.d0
if(mass.gt.zpars(2))then
*
* Zero-age helium star
*
mc = 0.d0
mass = mt
kw = 7
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
else
*
* Zero-age helium white dwarf.
*
mc = mt
mass = mt
kw = 10
endif
endif
*
elseif(aj.lt.tbagb)then
*
* Core helium burning star.
*
if(kw.eq.3.and.mass.le.zpars(2))then
mass = mt
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
aj = tscls(2)
endif
if(mass.le.zpars(2))then
mcx = mcgbf(lums(4),GB,lums(6))
else
mcx = mcheif(mass,zpars(2),zpars(10))
endif
tau = (aj - tscls(2))/tscls(3)
mc = mcx + (mcagbf(mass) - mcx)*tau
*
if(mass.le.zpars(2))then
lx = lums(5)
ly = lums(7)
rx = rzahbf(mt,mc,zpars(2))
rg = rgbf(mt,lx)
rmin = rg*zpars(13)**(mass/zpars(2))
texp = MIN(MAX(0.4d0,rmin/rx),2.5d0)
ry = ragbf(mt,ly,zpars(2))
if(rmin.lt.rx)then
taul = (log(rx/rmin))**(1.d0/3.d0)
else
rmin = rx
taul = 0.d0
endif
tauh = (log(ry/rmin))**(1.d0/3.d0)
tau2 = taul*(tau - 1.d0) + tauh*tau
r = rmin*exp(abs(tau2)**3)
rg = rg + tau*(ry - rg)
lum = lx*(ly/lx)**(tau**texp)
elseif(mass.gt.zpars(3))then
*
* For HM stars He-ignition takes place at Rmin in the HG, and CHeB
* consists of a blue phase (before tloop) and a RG phase (after tloop).
*
tau2 = tblf(mass,zpars(2),zpars(3))
tloop = tscls(2) + tau2*tscls(3)
rmin = rminf(mass)
rg = rgbf(mt,lums(4))
rx = ragbf(mt,lums(4),zpars(2))
rmin = MIN(rmin, rx)
if(mass.le.mlp) then
texp = log(mass/mlp)/log(zpars(3)/mlp)
rx = rg
rx = rmin*(rx/rmin)**texp
else
rx = rmin
end if
texp = MIN(MAX(0.4d0,rmin/rx),2.5d0)
lum = lums(4)*(lums(7)/lums(4))**(tau**texp)
if(aj.lt.tloop)then
ly = lums(4)*(lums(7)/lums(4))**(tau2**texp)
ry = ragbf(mt,ly,zpars(2))
taul = 0.d0
if(ABS(rmin-rx).gt.tiny)then
taul = (log(rx/rmin))**(1.d0/3.d0)
endif
tauh = 0.d0
if(ry.gt.rmin) tauh = (log(ry/rmin))**(1.d0/3.d0)
tau = (aj - tscls(2))/(tau2*tscls(3))
tau2 = taul*(tau - 1.d0) + tauh*tau
r = rmin*exp(abs(tau2)**3)
rg = rg + tau*(ry - rg)
else
r = ragbf(mt,lum,zpars(2))
rg = r
end if
else
*
* For IM stars CHeB consists of a RG phase (before tloop) and a blue
* loop (after tloop).
*
tau2 = 1.d0 - tblf(mass,zpars(2),zpars(3))
tloop = tscls(2) + tau2*tscls(3)
if(aj.lt.tloop)then
tau = (tloop - aj)/(tau2*tscls(3))
lum = lums(5)*(lums(4)/lums(5))**(tau**3)
r = rgbf(mt,lum)
rg = r
else
lx = lums(5)
ly = lums(7)
rx = rgbf(mt,lx)
rmin = rminf(mt)
texp = MIN(MAX(0.4d0,rmin/rx),2.5d0)
ry = ragbf(mt,ly,zpars(2))
if(rmin.lt.rx)then
taul = (log(rx/rmin))**(1.d0/3.d0)
else
rmin = rx
taul = 0.d0
endif
tauh = (log(ry/rmin))**(1.d0/3.d0)
tau = (aj - tloop)/(tscls(3) - (tloop - tscls(2)))
tau2 = taul*(tau - 1.d0) + tauh*tau
r = rmin*exp(abs(tau2)**3)
rg = rx + tau*(ry - rx)
lum = lx*(ly/lx)**(tau**texp)
endif
endif
*
* Test whether core mass exceeds total mass.
*
if(mc.ge.mt)then
*
* Evolved MS naked helium star.
*
kw = 7
xx = (aj - tscls(2))/tscls(3)
mass = mt
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
aj = xx*tm
else
kw = 4
endif
*
else
*
* Asymptotic Red Giant.
*
* On the AGB the He core mass remains constant until at Ltp it
* is caught by the C core mass and they grow together.
*
mcbagb = mcagbf(mass)
mcx = mcgbtf(tbagb,GB(8),GB,tscls(7),tscls(8),tscls(9))
mcmax = MAX(MAX(mch,0.773d0*mcbagb-0.35d0),1.05d0*mcx)
*
if(aj.lt.tscls(13))then
mcx = mcgbtf(aj,GB(8),GB,tscls(7),tscls(8),tscls(9))
mc = mcbagb
lum = lmcgbf(mcx,GB)
if(mt.le.mc)then
*
* Evolved naked helium star as the envelope is lost but the
* star has not completed its interior burning. The star becomes
* a post-HeMS star.
*
kw = 9
mt = mc
mass = mt
mc = mcx
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
if(mc.le.GB(7))then
aj = tscls(4) - (1.d0/((GB(5)-1.d0)*GB(8)*GB(4)))*
& (mc**(1.d0-GB(5)))
else
aj = tscls(5) - (1.d0/((GB(6)-1.d0)*GB(8)*GB(3)))*
& (mc**(1.d0-GB(6)))
endif
aj = MAX(aj,tm)
goto 90
else
kw = 5
endif
else
kw = 6
mc = mcgbtf(aj,GB(2),GB,tscls(10),tscls(11),tscls(12))
lum = lmcgbf(mc,GB)
*
* Approximate 3rd Dredge-up on AGB by limiting Mc.
*
lambda = MIN(0.9d0,0.3d0+0.001d0*mass**5)
tau = tscls(13)
mcx = mcgbtf(tau,GB(2),GB,tscls(10),tscls(11),tscls(12))
mcy = mc
mc = mc - lambda*(mcy-mcx)
mcx = mc
mcmax = MIN(mt,mcmax)
endif
r = ragbf(mt,lum,zpars(2))
rg = r
*
* Mc,x represents the C core mass and we now test whether it
* exceeds either the total mass or the maximum allowed core mass.
*
if(mcmax-mcx.lt.tiny)then
aj = 0.d0
mc = mcmax
if(mc.lt.mch)then
if(ifflag.ge.1)then
*
* Invoke WD IFMR from HPE, 1995, MNRAS, 272, 800.
*
if(zpars(14).ge.1.0d-08)then
mc = MIN(0.36d0+0.104d0*mass,0.58d0+0.061d0*mass)
mc = MAX(0.54d0+0.042d0*mass,mc)
if(mass.lt.1.d0) mc = 0.46d0
else
mc = MIN(0.29d0+0.178d0*mass,0.65d0+0.062d0*mass)
mc = MAX(0.54d0+0.073d0*mass,mc)
endif
mc = MIN(mch,mc)
endif
*
mt = mc
if(mcbagb.lt.1.6d0)then
*
* Zero-age Carbon/Oxygen White Dwarf
*
kw = 11
else
*
* Zero-age Oxygen/Neon White Dwarf
*
kw = 12
endif
mass = mt
*
else
if(mcbagb.lt.1.6d0)then
*
* Star is not massive enough to ignite C burning.
* so no remnant is left after the SN
*
kw = 15
aj = 0.d0
mt = 0.d0
lum = 1.0d-10
r = 1.0d-10
else
if(nsflag.eq.0)then
mt = 1.17d0 + 0.09d0*mc
elseif(nsflag.ge.1)then
*
* Use NS/BH mass given by Belczynski et al. 2002, ApJ, 572, 407.
*
if(mc.lt.2.5d0)then
mcx = 0.161767d0*mc + 1.067055d0
else
mcx = 0.314154d0*mc + 0.686088d0
endif
if(mc.le.5.d0)then
mt = mcx
elseif(mc.lt.7.6d0)then
mt = mcx + (mc - 5.d0)*(mt - mcx)/2.6d0
endif
endif
mc = mt
if(mt.le.mxns)then
*
* Zero-age Neutron star
*
kw = 13
else
*
* Zero-age Black hole
*
kw = 14
endif
endif
endif
endif
*
endif
*
90 continue
*
if(kw.ge.7.and.kw.le.9)then
*
* Naked Helium Star
*
rzams = rzhef(mt)
rx = rzams
if(aj.lt.tm)then
*
* Main Sequence
*
kw = 7
tau = aj/tm
am = MAX(0.d0,0.85d0-0.08d0*mass)
lum = lums(1)*(1.d0+0.45d0*tau+am*tau**2)
am = MAX(0.d0,0.4d0-0.22d0*LOG10(mt))
r = rx*(1.d0+am*(tau-tau**6))
rg = rx
* Star has no core mass and hence no memory of its past
* which is why we subject mass and mt to mass loss for
* this phase.
mc = 0.d0
if(mt.lt.zpars(10)) kw = 10
else
*
* Helium Shell Burning
*
kw = 8
lum = lgbtf(aj,GB(8),GB,tscls(4),tscls(5),tscls(6))
r = rhehgf(mt,lum,rx,lums(2))
rg = rhegbf(lum)
if(r.ge.rg)then
kw = 9
r = rg
endif
mc = mcgbf(lum,GB,lums(6))
mtc = MIN(mt,1.45d0*mt-0.31d0)
mcmax = MIN(mtc,MAX(mch,0.773d0*mass-0.35d0))
if(mcmax-mc.lt.tiny)then
aj = 0.d0
mc = mcmax
if(mc.lt.mch)then
if(mass.lt.1.6d0)then
*
* Zero-age Carbon/Oxygen White Dwarf
*
mt = MAX(mc,(mc+0.31d0)/1.45d0)
kw = 11
else
*
* Zero-age Oxygen/Neon White Dwarf
*
mt = mc
kw = 12
endif
mass = mt
else
if(mass.lt.1.6d0)then
*
* Star is not massive enough to ignite C burning.
* so no remnant is left after the SN
*
kw = 15
aj = 0.d0
mt = 0.d0
lum = 1.0d-10
r = 1.0d-10
else
if(nsflag.eq.0)then
mt = 1.17d0 + 0.09d0*mc
elseif(nsflag.ge.1)then
if(mc.lt.2.5d0)then
mcx = 0.161767d0*mc + 1.067055d0
else
mcx = 0.314154d0*mc + 0.686088d0
endif
if(mc.le.5.d0)then
mt = mcx
elseif(mc.lt.7.6d0)then
mt = mcx + (mc - 5.d0)*(mt - mcx)/2.6d0
endif
endif
mc = mt
if(mt.le.mxns)then
*
* Zero-age Neutron star
*
kw = 13
else
*
* Zero-age Black hole
*
kw = 14
endif
endif
endif
endif
endif
endif
*
if(kw.ge.10.and.kw.le.12)then
*
* White dwarf.
*
mc = mt
if(mc.ge.mch)then
*
* Accretion induced supernova with no remnant
* unless WD is ONe in which case we assume a NS
* of minimum mass is the remnant.
*
if(kw.eq.12)then
kw = 13
aj = 0.d0
mt = 1.3d0
else
kw = 15
aj = 0.d0
mt = 0.d0
lum = 1.0d-10
r = 1.0d-10
endif
else
*
if(kw.eq.10)then
xx = ahe
else
xx = aco
endif
*
if(wdflag.eq.0)then
*
* Mestel cooling
*
lum = 635.d0*mt*zpars(14)/(xx*(aj+0.1d0))**1.4d0
*
elseif(wdflag.ge.1)then
*
* modified-Mestel cooling
*
if(aj.lt.9000.0)then
lum = 300.d0*mt*zpars(14)/(xx*(aj+0.1d0))**1.18d0
else
fac = (9000.1d0*xx)**5.3d0
lum = 300.d0*fac*mt*zpars(14)/(xx*(aj+0.1d0))**6.48d0
endif
*
endif
*
r = 0.0115d0*SQRT(MAX(1.48204d-06,(mch/mt)**(2.d0/3.d0)
& - (mt/mch)**(2.d0/3.d0)))
r = MIN(0.1d0,r)
if(mt.lt.0.0005d0) r = 0.09d0
if(mt.lt.0.000005d0) r = 0.009d0
*
endif
endif
*
if(kw.eq.13)then
*
* Neutron Star.
*
mc = mt
if(mc.gt.mxns)then
*
* Accretion induced Black Hole?
*
kw = 14
aj = 0.d0
else
lum = 0.02d0*(mt**0.67d0)/(MAX(aj,0.1d0))**2
r = 1.4d-05
endif
endif
*
if(kw.eq.14)then
*
* Black hole
*
mc = mt
lum = 1.0d-10
r = 4.24d-06*mt
endif
*
* Calculate the core radius and the luminosity and radius of the
* remnant that the star will become.
*
tau = 0.d0
if(kw.le.1.or.kw.eq.7)then
rc = 0.d0
elseif(kw.le.3)then
if(mass.gt.zpars(2))then
lx = lzhef(mc)
rx = rzhef(mc)
rc = rx
else
if(wdflag.eq.0)then
lx = 635.d0*mc*zpars(14)/((ahe*0.1d0)**1.4d0)
elseif(wdflag.ge.1)then
lx = 300.d0*mc*zpars(14)/((ahe*0.1d0)**1.18d0)
endif
rx = 0.0115d0*SQRT(MAX(1.48204d-06,
& (mch/mc)**(2.d0/3.d0)-(mc/mch)**(2.d0/3.d0)))
rc = 5.d0*rx
endif
elseif(kw.eq.4)then
tau = (aj - tscls(2))/tscls(3)
kwp = 7
CALL star(kwp,mc,mc,tm,tn,tscls,lums,GB,zpars)
am = MAX(0.d0,0.85d0-0.08d0*mc)
lx = lums(1)*(1.d0+0.45d0*tau+am*tau**2)
rx = rzhef(mc)
am = MAX(0.d0,0.4d0-0.22d0*LOG10(mc))
rx = rx*(1.d0+am*(tau-tau**6))
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
rc = rx
elseif(kw.eq.5)then
kwp = 9
if(tn.gt.tbagb) tau = 3.d0*(aj-tbagb)/(tn-tbagb)
CALL star(kwp,mc,mc,tm,tn,tscls,lums,GB,zpars)
lx = lmcgbf(mcx,GB)
if(tau.lt.1.d0) lx = lums(2)*(lx/lums(2))**tau
rx = rzhef(mc)
rx = MIN(rhehgf(mc,lx,rx,lums(2)),rhegbf(lx))
CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars)
rc = rx
elseif(kw.le.9)then
if(wdflag.eq.0)then
lx = 635.d0*mc*zpars(14)/((aco*0.1d0)**1.4d0)
elseif(wdflag.ge.1)then
lx = 300.d0*mc*zpars(14)/((aco*0.1d0)**1.18d0)
endif
rx = 0.0115d0*SQRT(MAX(1.48204d-06,
& (mch/mc)**(2.d0/3.d0) - (mc/mch)**(2.d0/3.d0)))
rc = 5.d0*rx
else
rc = r
menv = 1.0d-10
renv = 1.0d-10
k2 = 0.21d0
endif
*
* Perturb the luminosity and radius due to small envelope mass.
*
if(kw.ge.2.and.kw.le.9.and.kw.ne.7)then
mew = ((mt-mc)/mt)*MIN(5.d0,MAX(1.2d0,(lum/lum0)**kap))
if(kw.ge.8) mew = ((mtc-mc)/mtc)*5.d0
if(mew.lt.1.d0)then
xx = lpertf(mt,mew)
lum = lx*(lum/lx)**xx
if(r.le.rx)then
xx = 0.d0
else
xx = rpertf(mt,mew,r,rx)
endif
r = rx*(r/rx)**xx
endif
rc = MIN(rc,r)
endif
*
* Calculate mass and radius of convective envelope, and envelope
* gyration radius.
*
if(kw.lt.10)then
CALL mrenv(kw,mass,mt,mc,lum,r,rc,aj,tm,lums(2),lums(3),
& lums(4),rzams,rtms,rg,menv,renv,k2)
endif
*
if(mass.gt.99.99d0)then
mass = mass0
endif
if(mt.gt.99.99d0)then
mt = mt0
endif
*
return
end
***