1C
2C
3C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
4C XTIME
5C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
6 SUBROUTINE XTIME(HD,HCOMP,HL,HS1,HS2,HT,HYDLUM,JCORE,JXMID,M,
7 * * DELTSH,HR1,HR2,HR3,HR4,HR5,HR6,HR7,HR8,HR9,HR10,HR11,HR12,
8C * HR13,HF1,HF2,JXBEG) ! KC 2025-05-31
9 * * HR13,HF1,HF2)
10C 10/15/26 MHP via Claude
11C code changed to take JSON from DIMENSIONS_MOD instead of declaring
12C PARAMETER(JSON=5000) here.
13 USE DIMENSIONS_MOD
14C 10/14/26 MHP via Claude
15C code changed to convert COMMON/NMLPAR/ into NMLPAR_MOD.
16 USE NMLPAR_MOD
17C 10/14/26 MHP via Claude
18C code changed to convert COMMON/CONSTANTS/ into CONSTANTS_MOD.
19 USE CONSTANTS_MOD
20C 10/20/26 MHP via Claude
21C code changed to replace implicit typing with IMPLICIT NONE and
22C explicit declarations.
23 IMPLICIT NONE
24 REAL*8 DCDT,DELTSH,DELTSH2,DL,DODT,DX,DXDT,DYDT,HCOMP,HD,HF1,HF2,
25 * * HL,HR1,HR10,HR11,HR12,HR13,HR2,HR3,HR4,HR5,HR6,HR7,HR8,HR9,
26 * * HS1,HS2,HT,HYDLUM,TL,X,XBE9,XC12,XC13,XH2,XHE3,XLI6,XLI7,
27 * * XN14,XN15,XO16,XO17,XO18,Y,Z
28 INTEGER IBEGIN,IEND,JCORE,JXMID,M
29C 10/12/26 MHP via Claude
30C code changed to extend COMMON/NMLPAR/ to 234 members, adding the
31C namelist variables that the physics routines read from 27 COMMON
32C blocks which also held derived or working members. Those blocks keep
33C only their non-namelist members; five of them -- NEWMX, VMULT,
34C PMMWIND, CCOUT1 and ENVGEN -- had nothing left and are gone.
35C Derivation-only namelist variables from the same blocks went to
36C COMMON/NMLBYPASS/ instead, not here.
37C
38C Declared identically in all 121 files that hold any of these members.
39C Generated from one member list, so every copy is byte-identical; the
40C linker's 'size of symbol changed' warning is the check that they are.
41C 10/13/26 MHP via Claude
42C code changed to drop COMMON/CTLIM/, declared here but never used.
43C 9/25/26 MHP via Claude
44C code changed to merge COMMON/CONST/, COMMON/CONST1/, COMMON/CONST2/,
45C and COMMON/CONST3/ into a single COMMON/CONSTANTS/
46C MHP 10/02 ADDED MISSING DIMENSION STATEMENTS!
47 DIMENSION HCOMP(15,JSON),HL(JSON),HS1(JSON),HT(JSON),HS2(JSON),
48 * * HR1(JSON),HR2(JSON),HR3(JSON),HR4(JSON),HR5(JSON),HR6(JSON),
49 * * HR7(JSON),HR8(JSON),HR9(JSON),HR10(JSON),HR11(JSON),HR12(JSON),
50 * * HR13(JSON),HF1(JSON),HF2(JSON),HD(JSON)
51 SAVE
52C THIS SR FINDS THE TIMESTEP BASED ON HYDROGEN BURNING.
53C FOR STARS WITH CENTRAL X > ATIME(1) THE TIMESTEP
54C IS THE TIME NEEDED TO BURN THE MINIMUM OF ATIME(2) OF
55C X AT THE CENTER OR THE FRACTION ATIME(3) OF THE CENTRAL X.
56C STARS WITH CENTRAL X < ATIME(1) ARE CONSIDERED BY THE PROGRAM
57C TO HAVE A HYDROGEN SHELL BURNING SOURCE. THE TIMESTEP IS THE
58C MINIMUM OF THE TIME REQUIRED TO BURN ATIME(7) OF X AT THE SHELL
59C MIDPOINT OR TO BURN THE MASS FRACTION ATIME(6) OF X IN THE
60C ENTIRE STAR.
61C H-CORE BURNING TIME CRITERION
62C **NOTE THAT FOR A CONVECTIVE CORE, THE TIMESTEP IS BASED ON THE TIME
63C NEEDED TO BURN THE GIVEN FRACTION OF HYDROGEN IN THE CORE AND NOT
64C JUST IN THE CENTRAL SHELL.
65 IF(HCOMP(1,1).GE.ATIME(1)) THEN
66 DX = MIN(ATIME(2),ATIME(3)*HCOMP(1,JCORE))
67 DELTSH =(6.00D18/CLSUN)*(HS1(JCORE)/HL(JCORE))*DX
68 RETURN
69 ENDIF
70C H-SHELL BURNING CRITERION
71C LIMIT TOTAL MASS OF HYDROGEN BURNED.
72C DX = ATIME(6)*HCOMP(1,M)*(CMSUN/CLSUN)
73 DX = ATIME(6)*HCOMP(1,M)*(CMSUN/CLSUN)
74 DELTSH = 6.00D18*DX/HYDLUM
75C LIMIT X-DEPLETION AT SHELL MID-POINT.
76C CALL NUCLEAR REACTION SR'S TO FIND DXDT AT THE SHELL MIDPOINT.
77 IBEGIN=JXMID
78 IEND=JXMID
79 DL = HD(IEND)
80 TL = HT(IEND)
81 X = HCOMP(1,IEND)
82 Y = HCOMP(2,IEND)
83 Z = HCOMP(3,IEND)
84 XHE3 = HCOMP(4,IEND)
85 XC12 = HCOMP(5,IEND)
86 XC13 = HCOMP(6,IEND)
87 XN14 = HCOMP(7,IEND)
88 XN15 = HCOMP(8,IEND)
89 XO16 = HCOMP(9,IEND)
90 XO17 = HCOMP(10,IEND)
91 XO18 = HCOMP(11,IEND)
92 XH2 = HCOMP(12,IEND)
93 XLI6 = HCOMP(13,IEND)
94 XLI7 = HCOMP(14,IEND)
95 XBE9 = HCOMP(15,IEND)
96C SETUP NUCLEAR ENERGY TERMS
97C CALL RATES(DL,TL,X,Y,Z,XHE3,XC12,XC13,XN14,XN15,
98C * XO16,XO17,XO18,XH2,XLI6,XLI7,XBE9,IEND,HR1,HR2,HR3,HR4, ! KC 2025-05-31
99 CALL RATES(DL,TL,X,Y,XHE3,XC12,XC13,XN14,
100 * * XO16,XO18,IEND,HR1,HR2,HR3,HR4,
101 * * HR5,HR6,HR7,HR8,HR9,HR10,HR11,HR12,HR13,HF1,HF2)
102C CALL EQBURN(HF1,HR1,HR2,HR3,HR4,HR5,HR6,HR7,HR8,HR9,HR10,HR11, ! KC 2025-05-31
103 CALL EQBURN(HR1,HR2,HR3,HR4,HR5,HR6,HR7,HR10,
104 * * HR12,HS2,HT,IBEGIN,IEND,DCDT,DODT,DXDT,DYDT,XC12,XO16,X,Z)
105 IF(DXDT.LT.0.0D0 .AND. ATIME(7).GT.0.0D0) THEN
106 DELTSH2 = ABS(CSECYR*1.0D9*ATIME(7)/DXDT)
107 DELTSH = MIN(DELTSH,DELTSH2)
108 ENDIF
109 RETURN
110 END
1"""Python version of xtime.f (YREC 7be4133): the time step allowed by
2hydrogen burning."""
3
4from pyrec import constants_mod
5import numpy as np
6from pyrec import nmlpar_mod
7from pyrec.eqburn import eqburn
8from pyrec.rates import rates
9
10
11def xtime(hd: np.ndarray, hcomp: np.ndarray, hl: np.ndarray, hs1: np.ndarray, hs2: np.ndarray, ht: np.ndarray,
12 hydlum: float, jcore: int, jxmid: int, m: int, deltsh: float, hr1: np.ndarray, hr2: np.ndarray,
13 hr3: np.ndarray, hr4: np.ndarray, hr5: np.ndarray, hr6: np.ndarray, hr7: np.ndarray, hr8: np.ndarray,
14 hr9: np.ndarray, hr10: np.ndarray, hr11: np.ndarray, hr12: np.ndarray, hr13: np.ndarray, hf1: np.ndarray,
15 hf2: np.ndarray) -> float:
16 """The hydrogen-burning time step: while the central X is at least
17 atime(1), the time to burn a given amount of the core's hydrogen;
18 afterwards the time to burn a fraction atime(6) of the hydrogen, and,
19 if X falls at the shell's midpoint jxmid, at most the time to deplete
20 atime(7) of X there.
21
22 Translates: xtime.f#XTIME (7be4133)
23
24 Arguments: the model hd, hcomp[species, shell], hl, hs1, hs2, ht
25 (index 0 unused); the hydrogen-burning luminosity hydlum; jcore, the
26 convective core's edge; jxmid, the shell's midpoint; m, the number of
27 shells; deltsh is passed in with any value; hr1..hr13, hf1, hf2, the
28 rate arrays that rates fills (at element jxmid).
29
30 Returns deltsh (s).
31
32 """
33
34 atime = nmlpar_mod.atime
35 c = constants_mod
36
37 # Core burning: the time to burn a given amount of the core's hydrogen
38 # (Fortran lines 65–69).
39 if hcomp[1, 1] >= atime[1]:
40 dx = min(atime[2], atime[3] * hcomp[1, jcore])
41 deltsh = (6.00e18 / c.clsun) * (hs1[jcore] / hl[jcore]) * dx
42 return deltsh
43
44 # Shell burning: the hydrogen of atime[6] solar masses of matter at the
45 # surface X (Fortran lines 73–74).
46 dx = atime[6] * hcomp[1, m] * (c.cmsun / c.clsun)
47 deltsh = 6.00e18 * dx / hydlum
48
49 # The composition at the shell's midpoint (Fortran lines 77–95).
50 ibegin = jxmid
51 iend = jxmid
52 dl = hd[iend]
53 tl = ht[iend]
54 x = hcomp[1, iend]
55 y = hcomp[2, iend]
56 z = hcomp[3, iend]
57 xhe3 = hcomp[4, iend]
58 xc12 = hcomp[5, iend]
59 xc13 = hcomp[6, iend]
60 xn14 = hcomp[7, iend]
61 xo16 = hcomp[9, iend]
62 xo18 = hcomp[11, iend]
63 # (HCOMP 8, 10, 12-15 are read into XN15, XO17, XH2, XLI6, XLI7, XBE9
64 # in the Fortran, but not used.)
65
66 # dX/dt there, from RATES and EQBURN (Fortran lines 99–104).
67 rates(dl, tl, x, y, xhe3, xc12, xc13, xn14, xo16, xo18, iend,
68 hr1, hr2, hr3, hr4, hr5, hr6, hr7, hr8, hr9, hr10, hr11, hr12,
69 hr13, hf1, hf2)
70 dcdt = dodt = dxdt = dydt = 0.0
71 dcdt, dodt, dxdt, dydt, xc12, xo16, x, z = eqburn(
72 hr1, hr2, hr3, hr4, hr5, hr6, hr7, hr10, hr12, hs2, ht, ibegin,
73 iend, dcdt, dodt, dxdt, dydt, xc12, xo16, x, z)
74
75 # At most the time to deplete atime[7] of X there; dX/dt is per Gyr
76 # (Fortran lines 105–108).
77 if dxdt < 0.0 and atime[7] > 0.0:
78 deltsh2 = abs(c.csecyr * 1.0e9 * atime[7] / dxdt)
79 deltsh = min(deltsh, deltsh2)
80
81 return deltsh