1C
2C
3C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
4C LIRATE88
5C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
6 SUBROUTINE LIRATE88(HCOMP,HD,HT,M,J)
7C 10/15/26 MHP via Claude
8C code changed to take JSON from DIMENSIONS_MOD instead of declaring
9C PARAMETER(JSON=5000) here.
10 USE DIMENSIONS_MOD
11C 10/14/26 MHP via Claude
12C code changed to convert COMMON/OLDRAT/ into OLDRAT_MOD.
13 USE OLDRAT_MOD
14C 10/14/26 MHP via Claude
15C code changed to convert COMMON/OLDMOD/ into OLDMOD_MOD.
16 USE OLDMOD_MOD
17C 10/14/26 MHP via Claude
18C code changed to convert COMMON/NEWRAT/ into NEWRAT_MOD.
19 USE NEWRAT_MOD
20C 10/14/26 MHP via Claude
21C code changed to convert COMMON/NMLPAR/ into NMLPAR_MOD.
22 USE NMLPAR_MOD
23C 10/14/26 MHP via Claude
24C code changed to convert COMMON/CONSTANTS/ into CONSTANTS_MOD.
25 USE CONSTANTS_MOD
26C 10/20/26 MHP via Claude
27C code changed to replace implicit typing with IMPLICIT NONE and
28C explicit declarations.
29 IMPLICIT NONE
30 REAL*8 C56,EX,FBE91,FBE92,FBE93,FLI6,FLI7,FSBE9,FX,HCOMP,HD,HT,
31 * * RHOX,T9,T913,T923,T932,T934,T943,T953,T9A,TLIM
32 INTEGER I,J,K,M
33
34C 9/25/26 MHP via Claude
35C code changed to merge COMMON/CONST/, COMMON/CONST1/, COMMON/CONST2/,
36C and COMMON/CONST3/ into a single COMMON/CONSTANTS/
37C 10/12/26 MHP via Claude
38C code changed to extend COMMON/NMLPAR/ to 234 members, adding the
39C namelist variables that the physics routines read from 27 COMMON
40C blocks which also held derived or working members. Those blocks keep
41C only their non-namelist members; five of them -- NEWMX, VMULT,
42C PMMWIND, CCOUT1 and ENVGEN -- had nothing left and are gone.
43C Derivation-only namelist variables from the same blocks went to
44C COMMON/NMLBYPASS/ instead, not here.
45C
46C Declared identically in all 121 files that hold any of these members.
47C Generated from one member list, so every copy is byte-identical; the
48C linker's 'size of symbol changed' warning is the check that they are.
49C G Somers END
50 DIMENSION HCOMP(15,JSON),HD(JSON),HT(JSON)
51 DATA TLIM/6.0D0/
52 SAVE
53
54C THIS ROUTINE COMPUTES THE BURNING RATES FOR LI6,LI7,BE9 AT THE
55C BEGINNING AND END OF A TIMESTEP AND STORES THEM IN COMMON BLOCKS
56C NEWRAT AND OLDRAT.
57C J = 1: rates of the model passed in (HCOMP, HD, HT), stored as the
58C end-of-step set RLI6, RLI7, RBE9 (NEWRAT).
59C J = 2: rates of the saved start-of-step model (HCOMPP, HDO, HTO),
60C stored as RLI60, RLI70, RBE90 (OLDRAT).
61C
62C BURNING RATES FROM CAUGHLIN AND FOWLER (1988).
63C
64 DO 100 I = 1,M
65 IF(HT(I).LT.TLIM.AND.HTO(I).LT.TLIM)GOTO 110
66 IF(J.EQ.1)THEN
67 RHOX = EXP(CLN*HD(I))*HCOMP(1,I)
68 T9=EXP(CLN*(HT(I)-9.0D0))
69 ELSE
70 RHOX = EXP(CLN*HDO(I))*HCOMPP(1,I)
71 T9=EXP(CLN*(HTO(I)-9.0D0))
72 ENDIF
73 T913=T9**CC13
74 T923=T913*T913
75 T943=T923*T923
76C MHP 10/91 ADDED DEFINITION
77 T953 = T943*T913
78 T932=T9**1.5D0
79 T934=T9**7.5D-1
80C
81C LI6(P,HE3)ALPHA
82C
83C FLI6=3.73D10/T923*EXP(-8.413/T913-(T9/5.50)**2)*
84C 1 (1.+%TYPO%0.50*T913-0.061*T923-0.021*T9+0.006*T943+0.006*T953)
85C 2 +1.33D10/T932*EXP(-17.763/T9)+1.29D9/T9*EXP(-21.820/T9)
86C ***TYPO IN OLD RATE***
87 FLI6=3.73D10/T923*EXP(-8.413D0/T913-(T9/5.50D0)**2)*
88 1 1 (1.D0+0.050D0*T913-0.061D0*T923-0.021D0*T9+0.006D0*T943
89 2 2 +0.005D0*T953)+1.33D10/T932*EXP(-17.763D0/T9)
90 3 3 +1.29D9/T9*EXP(-21.820D0/T9)
91C
92C LI7(P,ALFA)HE4
93C
94C FLI7=8.04D08/T923*EXP(-8.471/T913-(T9/30.068)**2)*
95C 1 (1.+0.049*T913+0.230*T923+0.079*T9-0.027*T943-0.023*T953)
96C 2 +1.54D06/T932*EXP(-4.479/T9)+1.07D10/T932*EXP(-30.443/T9)
97 T9A = T9/(1.0D0+0.759D0*T9)
98 C56 = 1.25D0*CC23
99 FLI7=1.096D9/T923*EXP(-8.472D0/T913)-4.830D8*T9A**C56/
100 1 1 T932*EXP(-8.472D0/T9A**CC13)+1.06D10/T932*EXP(-30.442D0/T9)
101C
102C BE9(P,GAMMA)B10
103C
104 FBE91=1.33D+07/T923*EXP(-10.359D0/T913-(T9/0.846D0)**2)
105 1 1 *(1.0D0+4.0D-2*T913+1.52D0*T923+4.28D-1*T9+2.15D0*T943+
106 2 2 1.54D0*T953) + 9.64D+4/T932*EXP(-3.445D0/T9) +
107 3 3 2.72D+6/T932*EXP(-10.62D0/T9)
108C 3 2.76D+6/T932*EXP(-10.62D0/T9) %OLD LAST LINE%
109C
110C BE9(P,D)2HE4 - UNCHANGED.
111C
112 FX=2.11D+11/T923*EXP(-10.359D0/T913-(T9/5.2D-1)**2)
113 1 1 *(1.0D0+4.0D-2*T913+1.09D0*T923+3.07D-1*T9+3.21D0*T943
114 2 2 +2.3D0*T953)
115 EX = EXP(-3.046D0/T9)/T9
116 FBE92=FX+5.79D+8*EX+8.5D+8/T934*EXP(-5.8D0/T9)
117C
118C BE9(P,ALPHA)LI6
119C
120 FBE93=FX+4.51D+8*EX+6.7D+8/T934*EXP(-5.16D0/T9)
121C G Somers 6/14, SCALE BY THE NEW CROSS SECTIONS
122 FLI6=SLI6*FLI6
123 FLI7=SLI7*FLI7
124 FBE91=SBE91*FBE91
125 FBE92=SBE92*FBE92
126 FBE93=SBE93*FBE93
127C G Somers END
128C SUM RATES
129 FSBE9 = FBE91 + FBE92 + FBE93
130 IF(J.EQ.1)THEN
131 RLI6(I) = FLI6*RHOX
132 RLI7(I) = FLI7*RHOX
133 RBE9(I) = FSBE9*RHOX
134 ELSE
135 RLI60(I) = FLI6*RHOX
136 RLI70(I) = FLI7*RHOX
137 RBE90(I) = FSBE9*RHOX
138 ENDIF
139 100 100 CONTINUE
140 110 110 CONTINUE
141C 10/29/26 MHP via Claude
142C code changed to clear only the set this call fills. Clearing both
143C sets let an end-of-step call (J=1) zero start-of-step rates stored
144C earlier in the step, and the reverse, whenever the cool cutoff moved.
145 DO 120 K = I,M
146 IF(J.EQ.1)THEN
147 RLI6(K)=0.0D0
148 RLI7(K)=0.0D0
149 RBE9(K)=0.0D0
150 ELSE
151 RLI60(K)=0.0D0
152 RLI70(K)=0.0D0
153 RBE90(K)=0.0D0
154 ENDIF
155 120 120 CONTINUE
156 RETURN
157 END
1"""Python version of lirate88.f (YREC development, 7be4133)."""
2
3import math
4import numpy as np
5
6from pyrec import constants_mod
7from pyrec import dimensions_mod # noqa: F401 (JSON, the declared size)
8from pyrec import newrat_mod
9from pyrec import nmlpar_mod
10from pyrec import oldmod_mod
11from pyrec import oldrat_mod
12
13# DATA TLIM (Fortran line 51).
14# Question (see the page): hard-coded cut in log T.
15TLIM = 6.0
16
17
18def lirate88(hcomp: np.ndarray, hd: np.ndarray, ht: np.ndarray, m: int, j: int) -> None:
19 """Proton-burning rates of Li6, Li7 and Be9 (Caughlan & Fowler 1988).
20
21 Each rate is the Caughlan-Fowler fit times its user scale factor and
22 rho X. With ``j`` = 1 the rates come from the arguments (the model
23 passed in) and fill the end-of-step set in ``newrat_mod``; with ``j`` =
24 2 from the saved start-of-step model in ``oldmod_mod`` and fill the
25 start-of-step set in ``oldrat_mod``. From the first point outward where
26 both the new and old log T are below TLIM, the set being filled is
27 zeroed.
28
29 Translates: lirate88.f#LIRATE88 (7be4133)
30
31 Parameters
32 ----------
33 hcomp : ndarray, shape (16, JSON + 1)
34 Composition, ``hcomp[1, i]`` = X (used with ``j`` = 1).
35 hd, ht : ndarray
36 log rho and log T at each point, 1..m (with ``j`` = 2, ``ht``
37 serves only for the cut).
38 m : int
39 Number of points.
40 j : int
41 1 for the model passed in (end of step), 2 for the saved
42 start-of-step model.
43
44 Sets ``newrat_mod.rli6, rli7, rbe9`` or ``oldrat_mod.rli60, rli70,
45 rbe90``. Nothing is returned.
46
47 """
48
49 # Module data (Fortran lines 10–25).
50 cln = constants_mod.cln
51 cc13 = constants_mod.cc13
52 cc23 = constants_mod.cc23
53 rli6 = newrat_mod.rli6
54 rli7 = newrat_mod.rli7
55 rbe9 = newrat_mod.rbe9
56 rli60 = oldrat_mod.rli60
57 rli70 = oldrat_mod.rli70
58 rbe90 = oldrat_mod.rbe90
59 hto = oldmod_mod.hto
60
61 # The rates at each point out to the cut (loop 100, Fortran lines
62 # 64–139).
63 i = m + 1 # the Fortran's I after loop 100 runs to its end
64 for ii in range(1, m + 1): # loop 100
65 if ht[ii] < TLIM and hto[ii] < TLIM:
66 i = ii
67 break # to label 110
68
69 # rho X and T9 of the model passed in (j = 1) or of the saved
70 # start-of-step model (j = 2) (Fortran lines 66–72).
71 if j == 1:
72 rhox = math.exp(cln * hd[ii]) * hcomp[1, ii]
73 t9 = math.exp(cln * (ht[ii] - 9.0))
74 else:
75 rhox = math.exp(cln * oldmod_mod.hdo[ii]) * oldmod_mod.hcompp[1, ii]
76 t9 = math.exp(cln * (hto[ii] - 9.0))
77
78 # Powers of T9 (Fortran lines 73–79).
79 t913 = t9 ** cc13
80 t923 = t913 * t913
81 t943 = t923 * t923
82 t953 = t943 * t913
83 t932 = t9 ** 1.5
84 t934 = t9 ** 7.5e-1
85
86 # Li6(p,He3)alpha (Fortran lines 81–90).
87 # Question (see the page): the old-typo notes in the Fortran's
88 # comments on these coefficients.
89 fli6 = (3.73e10 / t923 * math.exp(-8.413 / t913 - (t9 / 5.50) ** 2)
90 * (1.0 + 0.050 * t913 - 0.061 * t923 - 0.021 * t9
91 + 0.006 * t943 + 0.005 * t953)
92 + 1.33e10 / t932 * math.exp(-17.763 / t9)
93 + 1.29e9 / t9 * math.exp(-21.820 / t9))
94
95 # Li7(p,alpha)He4 (Fortran lines 92–100).
96 t9a = t9 / (1.0 + 0.759 * t9)
97 c56 = 1.25 * cc23
98 fli7 = (1.096e9 / t923 * math.exp(-8.472 / t913)
99 - 4.830e8 * t9a ** c56 / t932 * math.exp(-8.472 / t9a ** cc13)
100 + 1.06e10 / t932 * math.exp(-30.442 / t9))
101
102 # Be9(p,gamma)B10 (Fortran lines 102–108).
103 fbe91 = (1.33e+07 / t923 * math.exp(-10.359 / t913 - (t9 / 0.846) ** 2)
104 * (1.0 + 4.0e-2 * t913 + 1.52 * t923 + 4.28e-1 * t9
105 + 2.15 * t943 + 1.54 * t953)
106 + 9.64e+4 / t932 * math.exp(-3.445 / t9)
107 + 2.72e+6 / t932 * math.exp(-10.62 / t9))
108
109 # Be9(p,d)2He4 and Be9(p,alpha)Li6 (Fortran lines 110–120).
110 fx = (2.11e+11 / t923 * math.exp(-10.359 / t913 - (t9 / 5.2e-1) ** 2)
111 * (1.0 + 4.0e-2 * t913 + 1.09 * t923 + 3.07e-1 * t9
112 + 3.21 * t943 + 2.3 * t953))
113 ex = math.exp(-3.046 / t9) / t9
114 fbe92 = fx + 5.79e+8 * ex + 8.5e+8 / t934 * math.exp(-5.8 / t9)
115 fbe93 = fx + 4.51e+8 * ex + 6.7e+8 / t934 * math.exp(-5.16 / t9)
116
117 # The user's scale factors, and the sum for Be9 (Fortran lines
118 # 121–129).
119 fli6 = nmlpar_mod.sli6 * fli6
120 fli7 = nmlpar_mod.sli7 * fli7
121 fbe91 = nmlpar_mod.sbe91 * fbe91
122 fbe92 = nmlpar_mod.sbe92 * fbe92
123 fbe93 = nmlpar_mod.sbe93 * fbe93
124 fsbe9 = fbe91 + fbe92 + fbe93
125
126 # Times rho X, into the set this call fills (Fortran lines 130–138).
127 if j == 1:
128 rli6[ii] = fli6 * rhox
129 rli7[ii] = fli7 * rhox
130 rbe9[ii] = fsbe9 * rhox
131 else:
132 rli60[ii] = fli6 * rhox
133 rli70[ii] = fli7 * rhox
134 rbe90[ii] = fsbe9 * rhox
135
136 # label 110: zero the set this call fills, from the cut outward
137 # (Fortran lines 140–155).
138 for k in range(i, m + 1): # loop 120
139 if j == 1:
140 rli6[k] = 0.0
141 rli7[k] = 0.0
142 rbe9[k] = 0.0
143 else:
144 rli60[k] = 0.0
145 rli70[k] = 0.0
146 rbe90[k] = 0.0