Skip to content

Commit bb8d2a2

Browse files
authored
update ECSN with latest pynucastro (#1320)
this will help us with the diffs in the pynucastro C++ CI
1 parent 5825917 commit bb8d2a2

File tree

6 files changed

+43
-54
lines changed

6 files changed

+43
-54
lines changed

networks/ECSN/actual_network.H

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ namespace NSE_INDEX
9393
// last index is the corresponding reverse rate index.
9494

9595
extern AMREX_GPU_MANAGED amrex::Array2D<int, 1, Rates::NumRates, 1, 7, Order::C> rate_indices;
96-
extern AMREX_GPU_MANAGED bool initialized;
9796
}
9897
#endif
9998

networks/ECSN/actual_network_data.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace NSE_INDEX
3030
-1, -1, 3, -1, -1, 4, 15,
3131
-1, -1, 4, -1, -1, 5, 16
3232
};
33-
AMREX_GPU_MANAGED bool initialized = false;
3433
}
3534
#endif
3635

networks/ECSN/actual_rhs.H

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void evaluate_rates(const burn_t& state, T& rate_eval) {
7070

7171
Real ratraw, dratraw_dT;
7272
Real scor, dscor_dt;
73-
Real scor2, dscor2_dt;
73+
[[maybe_unused]] Real scor2, dscor2_dt;
7474

7575

7676
{
@@ -411,9 +411,9 @@ void actual_rhs (burn_t& state, Array1D<Real, 1, neqs>& ydot)
411411

412412
// Get the thermal neutrino losses
413413

414-
Real sneut, dsneutdt, dsneutdd, snuda, snudz;
414+
Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz;
415415

416-
sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, snuda, snudz);
416+
sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz);
417417

418418
// Append the energy equation (this is erg/g/s)
419419

@@ -628,11 +628,11 @@ void actual_jac(const burn_t& state, MatrixType& jac)
628628

629629
// Account for the thermal neutrino losses
630630

631-
Real sneut, dsneutdt, dsneutdd, snuda, snudz;
632-
sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, snuda, snudz);
631+
Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz;
632+
sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz);
633633

634634
for (int j = 1; j <= NumSpec; ++j) {
635-
Real b1 = (-state.abar * state.abar * snuda + (zion[j-1] - state.zbar) * state.abar * snudz);
635+
Real b1 = (-state.abar * state.abar * dsnuda + (zion[j-1] - state.zbar) * state.abar * dsnudz);
636636
jac.add(net_ienuc, j, -b1);
637637
}
638638

networks/ECSN/partition_functions.H

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ namespace part_fun {
2222
void interpolate_pf(const Real t9, const Real (&temp_array)[npts], const Real (&pf_array)[npts],
2323
Real& pf, Real& dpf_dT) {
2424

25-
// find the index of the first temperature element we are larger than
25+
if (t9 >= temp_array[0] && t9 < temp_array[npts-1]) {
2626

27-
int idx = -1;
27+
// find the largest temperature element <= t9 using a binary search
2828

29-
for (int i = 0; i < npts-1; ++i) {
30-
if (t9 >= temp_array[i] && t9 < temp_array[i+1]) {
31-
idx = i;
32-
break;
29+
int left = 0;
30+
int right = npts;
31+
32+
while (left < right) {
33+
int mid = (left + right) / 2;
34+
if (temp_array[mid] > t9) {
35+
right = mid;
36+
} else {
37+
left = mid + 1;
38+
}
3339
}
34-
}
3540

36-
if (idx >= 0) {
41+
const int idx = right - 1;
42+
43+
// now we have temp_array[idx] <= t9 < temp_array[idx+1]
3744

3845
// construct the slope -- this is (log10(pf_{i+1}) - log10(pf_i)) / (T_{i+1} - T_i)
3946

@@ -46,12 +53,12 @@ namespace part_fun {
4653

4754
// find the derivative (with respect to T, not T9)
4855

49-
Real dpf_dT9 = pf * std::log(10.0_rt) * slope;
56+
Real dpf_dT9 = pf * M_LN10 * slope;
5057
dpf_dT = dpf_dT9 / 1.e9_rt;
5158

5259
} else {
5360

54-
// T < the smallest T in the partition function table
61+
// T < the smallest T or >= the largest T in the partition function table
5562
pf = 1.0;
5663
dpf_dT = 0.0;
5764

@@ -90,48 +97,27 @@ constexpr Real get_spin_state(const int inuc) {
9097

9198
switch (inuc) {
9299

93-
case H1:
94-
spin = 2;
95-
break;
96-
97100
case He4:
98-
spin = 1;
99-
break;
100-
101101
case O16:
102-
spin = 1;
103-
break;
104-
105102
case O20:
106-
spin = 1;
107-
break;
108-
109-
case F20:
110-
spin = 5;
111-
break;
112-
113103
case Ne20:
114-
spin = 1;
115-
break;
116-
117104
case Mg24:
118-
spin = 1;
119-
break;
120-
121-
case Al27:
122-
spin = 6;
123-
break;
124-
125105
case Si28:
106+
case S32:
126107
spin = 1;
127108
break;
128109

110+
case H1:
129111
case P31:
130112
spin = 2;
131113
break;
132114

133-
case S32:
134-
spin = 1;
115+
case F20:
116+
spin = 5;
117+
break;
118+
119+
case Al27:
120+
spin = 6;
135121
break;
136122

137123

networks/ECSN/reaclib_rates.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,11 @@ fill_reaclib_rates(const tf_t& tfactors, T& rate_eval)
910910
template <int do_T_derivatives, typename T>
911911
AMREX_GPU_HOST_DEVICE AMREX_INLINE
912912
void
913-
fill_approx_rates([[maybe_unused]] const tf_t& tfactors, T& rate_eval)
913+
fill_approx_rates([[maybe_unused]] const tf_t& tfactors, [[maybe_unused]] T& rate_eval)
914914
{
915915

916-
Real rate;
917-
Real drate_dT;
916+
[[maybe_unused]] Real rate{};
917+
[[maybe_unused]] Real drate_dT{};
918918

919919

920920
}

networks/ECSN/table_rates.H

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ void init_tab_info(const table_t& tf, const std::string& file, R& rhoy, T& temp,
112112
}
113113

114114
if (1 == j) {
115+
if (temp(i) > 33.0_rt){
116+
amrex::Error("init_tab_info: Table data needs to be updated");
117+
}
118+
115119
temp(i) = std::pow(10.0_rt, temp(i));
116120
}
117121

@@ -151,11 +155,11 @@ int vector_index_lu(const int vlen, const V& vector, const Real fvar)
151155
} else {
152156
ndn = j;
153157
}
154-
if (((nup - ndn) == 1)) {
155-
index = ndn;
156-
return index;
157-
}
158+
if ((nup - ndn) == 1) {
159+
break;
160+
}
158161
}
162+
index = ndn;
159163
}
160164

161165
return index;
@@ -256,6 +260,7 @@ get_entries(const table_t& table_meta,
256260
data(itemp_hi, irhoy_hi, ivar),
257261
temp);
258262

263+
// NOLINTNEXTLINE(readability-suspicious-call-argument)
259264
entries(ivar) = bl_extrap(rhoy_lo, rhoy_hi, f_i, f_ip1, rhoy);
260265
}
261266

0 commit comments

Comments
 (0)