Skip to content

Commit bf679dd

Browse files
committed
update nets
1 parent dc52bc6 commit bf679dd

File tree

119 files changed

+3604
-4738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3604
-4738
lines changed

networks/CNO_extras/Make.package

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ifeq ($(USE_REACT),TRUE)
44
CEXE_sources += actual_network_data.cpp
55
CEXE_headers += actual_network.H
66
CEXE_headers += tfactors.H
7+
CEXE_headers += interp_tools.H
78
CEXE_headers += partition_functions.H
89
CEXE_sources += partition_functions_data.cpp
910
CEXE_headers += actual_rhs.H

networks/CNO_extras/actual_network.H

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,6 @@ namespace Rates
285285
NumRates = k_He4_He4_He4_to_C12
286286
};
287287

288-
// number of reaclib rates
289-
290-
const int NrateReaclib = 67;
291-
292-
// number of tabular rates
293-
294-
const int NrateTabular = 0;
295-
296288
// rate names -- note: the rates are 1-based, not zero-based, so we pad
297289
// this vector with rate_names[0] = "" so the indices line up with the
298290
// NetworkRates enum
@@ -381,7 +373,7 @@ namespace NSE_INDEX
381373
// First 3 row indices for reactants, followed by 3 product indices
382374
// last index is the corresponding reverse rate index.
383375

384-
extern AMREX_GPU_MANAGED amrex::Array2D<int, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices;
376+
extern AMREX_GPU_MANAGED amrex::Array2D<std::int8_t, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices;
385377
}
386378
#endif
387379

networks/CNO_extras/actual_network_data.cpp

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,74 @@
44
#ifdef NSE_NET
55
namespace NSE_INDEX
66
{
7-
AMREX_GPU_MANAGED amrex::Array2D<int, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices {
8-
-1, -1, 4, -1, -1, 3, -1,
9-
-1, -1, 7, -1, -1, 5, -1,
10-
-1, -1, 8, -1, -1, 6, -1,
11-
-1, -1, 12, -1, -1, 10, -1,
12-
-1, -1, 13, -1, -1, 11, -1,
13-
-1, -1, 15, -1, -1, 13, -1,
14-
-1, -1, 16, -1, -1, 14, -1,
15-
-1, -1, 4, -1, 0, 2, -1,
16-
-1, -1, 5, -1, 0, 3, -1,
17-
-1, -1, 7, -1, 0, 4, -1,
18-
-1, -1, 8, -1, 0, 5, -1,
19-
-1, -1, 9, -1, 0, 6, -1,
20-
-1, -1, 9, -1, 1, 2, -1,
21-
-1, -1, 12, -1, 0, 9, -1,
22-
-1, -1, 13, -1, 0, 10, -1,
23-
-1, -1, 13, -1, 1, 5, -1,
24-
-1, -1, 14, -1, 0, 11, -1,
25-
-1, -1, 14, -1, 1, 6, -1,
26-
-1, -1, 15, -1, 0, 12, -1,
27-
-1, -1, 15, -1, 1, 7, -1,
28-
-1, -1, 16, -1, 0, 13, -1,
29-
-1, -1, 16, -1, 1, 8, -1,
30-
-1, -1, 17, -1, 0, 14, -1,
31-
-1, -1, 17, -1, 1, 9, -1,
32-
-1, -1, 18, -1, 1, 15, -1,
33-
-1, -1, 19, -1, 1, 17, -1,
34-
-1, -1, 2, 1, 1, 1, -1,
35-
-1, 0, 2, -1, -1, 4, 8,
36-
-1, 1, 2, -1, -1, 9, 13,
37-
-1, 0, 3, -1, -1, 5, 9,
38-
-1, 0, 4, -1, -1, 7, 10,
39-
-1, 0, 5, -1, -1, 8, 11,
40-
-1, 1, 5, -1, -1, 13, 16,
41-
-1, 0, 6, -1, -1, 9, 12,
42-
-1, 1, 6, -1, -1, 14, 18,
43-
-1, 1, 7, -1, -1, 15, 20,
44-
-1, 1, 8, -1, -1, 16, 22,
45-
-1, 0, 9, -1, -1, 12, 14,
46-
-1, 1, 9, -1, -1, 17, 24,
47-
-1, 0, 10, -1, -1, 13, 15,
48-
-1, 0, 11, -1, -1, 14, 17,
49-
-1, 0, 12, -1, -1, 15, 19,
50-
-1, 0, 13, -1, -1, 16, 21,
51-
-1, 0, 14, -1, -1, 17, 23,
52-
-1, 1, 15, -1, -1, 18, 25,
53-
-1, 1, 17, -1, -1, 19, 26,
54-
-1, 1, 2, -1, 0, 6, -1,
55-
-1, 2, 2, -1, 1, 17, 65,
56-
-1, 1, 4, -1, 0, 9, 55,
57-
-1, 1, 5, -1, 0, 10, -1,
58-
-1, 0, 6, -1, 1, 2, 47,
59-
-1, 1, 6, -1, 0, 11, -1,
60-
-1, 1, 7, -1, 0, 12, 60,
61-
-1, 1, 8, -1, 0, 13, -1,
62-
-1, 0, 9, -1, 1, 4, -1,
63-
-1, 1, 9, -1, 0, 14, -1,
64-
-1, 2, 9, -1, 1, 19, 66,
65-
-1, 0, 10, -1, 1, 5, 50,
66-
-1, 0, 11, -1, 1, 6, 52,
67-
-1, 0, 12, -1, 1, 7, -1,
68-
-1, 1, 12, -1, 0, 17, 64,
69-
-1, 0, 13, -1, 1, 8, 54,
70-
-1, 0, 14, -1, 1, 9, 56,
71-
-1, 0, 17, -1, 1, 12, -1,
72-
-1, 1, 17, -1, 2, 2, -1,
73-
-1, 1, 19, -1, 2, 9, -1,
74-
1, 1, 1, -1, -1, 2, 27
7+
AMREX_GPU_MANAGED amrex::Array2D<std::int8_t, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices {
8+
-1, -1, 4, -1, -1, 3, -1, // N13_to_C13_weak_wc12
9+
-1, -1, 7, -1, -1, 5, -1, // O14_to_N14_weak_wc12
10+
-1, -1, 8, -1, -1, 6, -1, // O15_to_N15_weak_wc12
11+
-1, -1, 12, -1, -1, 10, -1, // F17_to_O17_weak_wc12
12+
-1, -1, 13, -1, -1, 11, -1, // F18_to_O18_weak_wc12
13+
-1, -1, 15, -1, -1, 13, -1, // Ne18_to_F18_weak_wc12
14+
-1, -1, 16, -1, -1, 14, -1, // Ne19_to_F19_weak_wc12
15+
-1, -1, 4, -1, 0, 2, -1, // N13_to_p_C12
16+
-1, -1, 5, -1, 0, 3, -1, // N14_to_p_C13
17+
-1, -1, 7, -1, 0, 4, -1, // O14_to_p_N13
18+
-1, -1, 8, -1, 0, 5, -1, // O15_to_p_N14
19+
-1, -1, 9, -1, 0, 6, -1, // O16_to_p_N15
20+
-1, -1, 9, -1, 1, 2, -1, // O16_to_He4_C12
21+
-1, -1, 12, -1, 0, 9, -1, // F17_to_p_O16
22+
-1, -1, 13, -1, 0, 10, -1, // F18_to_p_O17
23+
-1, -1, 13, -1, 1, 5, -1, // F18_to_He4_N14
24+
-1, -1, 14, -1, 0, 11, -1, // F19_to_p_O18
25+
-1, -1, 14, -1, 1, 6, -1, // F19_to_He4_N15
26+
-1, -1, 15, -1, 0, 12, -1, // Ne18_to_p_F17
27+
-1, -1, 15, -1, 1, 7, -1, // Ne18_to_He4_O14
28+
-1, -1, 16, -1, 0, 13, -1, // Ne19_to_p_F18
29+
-1, -1, 16, -1, 1, 8, -1, // Ne19_to_He4_O15
30+
-1, -1, 17, -1, 0, 14, -1, // Ne20_to_p_F19
31+
-1, -1, 17, -1, 1, 9, -1, // Ne20_to_He4_O16
32+
-1, -1, 18, -1, 1, 15, -1, // Mg22_to_He4_Ne18
33+
-1, -1, 19, -1, 1, 17, -1, // Mg24_to_He4_Ne20
34+
-1, -1, 2, 1, 1, 1, -1, // C12_to_He4_He4_He4
35+
-1, 0, 2, -1, -1, 4, 8, // p_C12_to_N13
36+
-1, 1, 2, -1, -1, 9, 13, // He4_C12_to_O16
37+
-1, 0, 3, -1, -1, 5, 9, // p_C13_to_N14
38+
-1, 0, 4, -1, -1, 7, 10, // p_N13_to_O14
39+
-1, 0, 5, -1, -1, 8, 11, // p_N14_to_O15
40+
-1, 1, 5, -1, -1, 13, 16, // He4_N14_to_F18
41+
-1, 0, 6, -1, -1, 9, 12, // p_N15_to_O16
42+
-1, 1, 6, -1, -1, 14, 18, // He4_N15_to_F19
43+
-1, 1, 7, -1, -1, 15, 20, // He4_O14_to_Ne18
44+
-1, 1, 8, -1, -1, 16, 22, // He4_O15_to_Ne19
45+
-1, 0, 9, -1, -1, 12, 14, // p_O16_to_F17
46+
-1, 1, 9, -1, -1, 17, 24, // He4_O16_to_Ne20
47+
-1, 0, 10, -1, -1, 13, 15, // p_O17_to_F18
48+
-1, 0, 11, -1, -1, 14, 17, // p_O18_to_F19
49+
-1, 0, 12, -1, -1, 15, 19, // p_F17_to_Ne18
50+
-1, 0, 13, -1, -1, 16, 21, // p_F18_to_Ne19
51+
-1, 0, 14, -1, -1, 17, 23, // p_F19_to_Ne20
52+
-1, 1, 15, -1, -1, 18, 25, // He4_Ne18_to_Mg22
53+
-1, 1, 17, -1, -1, 19, 26, // He4_Ne20_to_Mg24
54+
-1, 1, 2, -1, 0, 6, -1, // He4_C12_to_p_N15
55+
-1, 2, 2, -1, 1, 17, 65, // C12_C12_to_He4_Ne20
56+
-1, 1, 4, -1, 0, 9, 55, // He4_N13_to_p_O16
57+
-1, 1, 5, -1, 0, 10, -1, // He4_N14_to_p_O17
58+
-1, 0, 6, -1, 1, 2, 47, // p_N15_to_He4_C12
59+
-1, 1, 6, -1, 0, 11, -1, // He4_N15_to_p_O18
60+
-1, 1, 7, -1, 0, 12, 60, // He4_O14_to_p_F17
61+
-1, 1, 8, -1, 0, 13, -1, // He4_O15_to_p_F18
62+
-1, 0, 9, -1, 1, 4, -1, // p_O16_to_He4_N13
63+
-1, 1, 9, -1, 0, 14, -1, // He4_O16_to_p_F19
64+
-1, 2, 9, -1, 1, 19, 66, // C12_O16_to_He4_Mg24
65+
-1, 0, 10, -1, 1, 5, 50, // p_O17_to_He4_N14
66+
-1, 0, 11, -1, 1, 6, 52, // p_O18_to_He4_N15
67+
-1, 0, 12, -1, 1, 7, -1, // p_F17_to_He4_O14
68+
-1, 1, 12, -1, 0, 17, 64, // He4_F17_to_p_Ne20
69+
-1, 0, 13, -1, 1, 8, 54, // p_F18_to_He4_O15
70+
-1, 0, 14, -1, 1, 9, 56, // p_F19_to_He4_O16
71+
-1, 0, 17, -1, 1, 12, -1, // p_Ne20_to_He4_F17
72+
-1, 1, 17, -1, 2, 2, -1, // He4_Ne20_to_C12_C12
73+
-1, 1, 19, -1, 2, 9, -1, // He4_Mg24_to_C12_O16
74+
1, 1, 1, -1, -1, 2, 27 // He4_He4_He4_to_C12
7575
};
7676
}
7777
#endif

networks/CNO_extras/actual_rhs.H

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ void ener_gener_rate(T const& dydt, amrex::Real& enuc)
3838

3939
enuc = 0.0_rt;
4040

41-
for (int n = 1; n <= NumSpec; ++n) {
42-
enuc += dydt(n) * network::mion(n);
43-
}
41+
amrex::constexpr_for<1, NumSpec+1>([&] (auto n)
42+
{
43+
enuc += dydt(n) * network::mion<n>();
44+
});
4445

4546
enuc *= C::enuc_conv2;
4647
}

networks/CNO_extras/partition_functions.H

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,14 @@
77
#include <tfactors.H>
88
#include <fundamental_constants.H>
99
#include <network_properties.H>
10+
#include <interp_tools.H>
1011

1112
using namespace amrex::literals;
1213
using namespace Species;
1314

1415
namespace part_fun {
1516

1617

17-
18-
// index locator
19-
20-
template <typename T>
21-
AMREX_GPU_HOST_DEVICE AMREX_INLINE
22-
int
23-
index_pf(const amrex::Real t9, const T& temp_array) {
24-
25-
int left = temp_array.lo();
26-
int right = temp_array.hi();
27-
28-
int idx = -1;
29-
30-
if (t9 >= temp_array(left) && t9 < temp_array(right)) {
31-
32-
// find the largest temperature element <= t9 using a
33-
// binary search
34-
35-
while (left < right) {
36-
int mid = (left + right) / 2;
37-
if (temp_array(mid) > t9) {
38-
right = mid;
39-
} else {
40-
left = mid + 1;
41-
}
42-
}
43-
44-
idx = right - 1;
45-
}
46-
47-
return idx;
48-
}
49-
5018
// interpolation routine
5119

5220
template <typename T>
@@ -58,7 +26,7 @@ namespace part_fun {
5826
// if the index is -1, we are either outside of the bounds or
5927
// we never computed it. try recomputing here
6028
if (idx == -1) {
61-
idx = index_pf(t9, temp_array);
29+
idx = interp_net::find_index(t9, temp_array);
6230
}
6331

6432
// if the index is still -1, then we are out-of-bounds, so
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pynucastro version: 2.8.0-6-g7d01fa58a
1+
pynucastro version: 2.8.0-39-gcd1ab9edf

networks/CNO_extras/table_rates.H

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <AMReX_Array.H>
1010

11+
#include <interp_tools.H>
12+
1113
using namespace amrex::literals;
1214

1315
void init_tabular();
@@ -101,42 +103,6 @@ void init_tab_info(const table_t& tf, const std::string& file, R& log_rhoy_table
101103
}
102104

103105

104-
template <typename V>
105-
AMREX_INLINE AMREX_GPU_HOST_DEVICE
106-
int vector_index_lu(const int vlen, const V& vector, const amrex::Real fvar)
107-
{
108-
109-
// Returns the greatest index of vector for which vector(index) < fvar.
110-
// Return 1 if fvar < vector(1)
111-
// Return size(vector)-1 if fvar > vector(size(vector))
112-
// The interval [index, index+1] brackets fvar for fvar within the range of vector.
113-
114-
int index;
115-
116-
if (fvar < vector(1)) {
117-
index = 1;
118-
} else if (fvar > vector(vlen)) {
119-
index = vlen - 1;
120-
} else {
121-
int nup = vlen;
122-
int ndn = 1;
123-
for (int i = 1; i <= vlen; ++i) {
124-
int j = ndn + (nup - ndn)/2;
125-
if (fvar < vector(j)) {
126-
nup = j;
127-
} else {
128-
ndn = j;
129-
}
130-
if ((nup - ndn) == 1) {
131-
break;
132-
}
133-
}
134-
index = ndn;
135-
}
136-
return index;
137-
}
138-
139-
140106
AMREX_INLINE AMREX_GPU_HOST_DEVICE
141107
amrex::Real
142108
evaluate_linear_1d(const amrex::Real fhi, const amrex::Real flo, const amrex::Real xhi, const amrex::Real xlo, const amrex::Real x)
@@ -205,7 +171,7 @@ evaluate_vars(const int irhoy_lo, const int jtemp_lo,
205171
amrex::Real fip1jp1 = data(jtemp_hi, irhoy_hi, component);
206172

207173
amrex::Real r = evaluate_linear_2d(fip1jp1, fip1j, fijp1, fij,
208-
rhoy_hi, rhoy_lo, t_hi, t_lo, log_rhoy, log_temp);
174+
rhoy_hi, rhoy_lo, t_hi, t_lo, log_rhoy, log_temp);
209175

210176
return r;
211177
}
@@ -387,21 +353,18 @@ AMREX_INLINE AMREX_GPU_HOST_DEVICE
387353
void
388354
tabular_evaluate(const table_t& table_meta,
389355
const R& log_rhoy_table, const T& log_temp_table, const D& data,
390-
const amrex::Real rhoy, const amrex::Real temp,
356+
const amrex::Real log_rhoy, const amrex::Real log_temp, const amrex::Real temp,
391357
amrex::Real& rate, amrex::Real& drate_dt, amrex::Real& edot_nu, amrex::Real& edot_gamma)
392358
{
393359
amrex::Array1D<amrex::Real, 1, num_vars+add_vars> entries;
394360

395361
// Get the table entries at this rhoy, temp
396362

397-
const amrex::Real log_rhoy = std::log10(rhoy);
398-
const amrex::Real log_temp = std::log10(temp);
399-
400363
// get the index into the table -- all components are
401364
// stored with the same indices
402365

403-
int irhoy_lo = vector_index_lu(table_meta.nrhoy, log_rhoy_table, log_rhoy);
404-
int jtemp_lo = vector_index_lu(table_meta.ntemp, log_temp_table, log_temp);
366+
const int irhoy_lo = interp_net::find_index_extrap(log_rhoy, log_rhoy_table);
367+
const int jtemp_lo = interp_net::find_index_extrap(log_temp, log_temp_table);
405368

406369
get_entries(irhoy_lo, jtemp_lo,
407370
table_meta, log_rhoy_table, log_temp_table, data,

networks/ECSN/Make.package

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ifeq ($(USE_REACT),TRUE)
44
CEXE_sources += actual_network_data.cpp
55
CEXE_headers += actual_network.H
66
CEXE_headers += tfactors.H
7+
CEXE_headers += interp_tools.H
78
CEXE_headers += partition_functions.H
89
CEXE_sources += partition_functions_data.cpp
910
CEXE_headers += actual_rhs.H

networks/ECSN/actual_network.H

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,6 @@ namespace Rates
176176
NumRates = k_O20_to_F20
177177
};
178178

179-
// number of reaclib rates
180-
181-
const int NrateReaclib = 14;
182-
183-
// number of tabular rates
184-
185-
const int NrateTabular = 4;
186-
187179
// rate names -- note: the rates are 1-based, not zero-based, so we pad
188180
// this vector with rate_names[0] = "" so the indices line up with the
189181
// NetworkRates enum
@@ -223,7 +215,7 @@ namespace NSE_INDEX
223215
// First 3 row indices for reactants, followed by 3 product indices
224216
// last index is the corresponding reverse rate index.
225217

226-
extern AMREX_GPU_MANAGED amrex::Array2D<int, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices;
218+
extern AMREX_GPU_MANAGED amrex::Array2D<std::int8_t, 1, Rates::NumRates, 1, 7, amrex::Order::C> rate_indices;
227219
}
228220
#endif
229221

0 commit comments

Comments
 (0)