Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template rate indices and corresponding changes for NSE_NET #1269

Merged
merged 49 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
278114e
temp save
zhichen3 May 30, 2023
f33268e
initial commit
zhichen3 May 31, 2023
9beea45
Merge branch 'development' into simplified_sdc_ase
zhichen3 May 31, 2023
dd5b960
fix typo
zhichen3 May 31, 2023
80d8908
fix another composition
zhichen3 May 31, 2023
2a94b31
simplify
zhichen3 May 31, 2023
88ddf97
change to rho instead of SRHO
zhichen3 Jun 1, 2023
a34b37b
more simplification
zhichen3 Jun 1, 2023
14ab6c2
add rhoX when use nse_state
zhichen3 Jun 1, 2023
8e00d8c
Merge branch 'development' into simplified_sdc_ase
zhichen3 Jun 1, 2023
a6c3785
Merge branch 'development' into simplified_sdc_ase
zingale Jun 2, 2023
bc44fff
Merge branch 'development' into simplified_sdc_ase
zingale Jun 3, 2023
571667d
update burn_to_eos
zhichen3 Jun 5, 2023
a61becd
update and simplify ase network
zhichen3 Jun 5, 2023
d2c4bfd
update
zhichen3 Jun 5, 2023
f6e452e
Merge branch 'development' into nse_neutron
zhichen3 Jun 6, 2023
fea0d26
Merge branch 'development' into update_nse_files
zhichen3 Jun 6, 2023
93e92ca
Merge branch 'development' into simplified_sdc_ase
zhichen3 Jun 6, 2023
d0326b8
Merge branch 'update_nse_files' into nse_neutron
zhichen3 Jun 6, 2023
4475c05
Merge branch 'simplified_sdc_ase' into nse_neutron
zhichen3 Jun 6, 2023
077d0fa
Merge branch 'ase_remove_neutron' into nse_neutron
zhichen3 Jun 6, 2023
48196c1
update
zhichen3 Jun 6, 2023
7cd960c
include additional rates
zhichen3 Jun 7, 2023
c795cc0
Merge branch 'development' into ase_remove_neutron
zhichen3 Jun 7, 2023
64825cc
Merge branch 'ase_remove_neutron' into nse_neutron
zhichen3 Jun 7, 2023
8d0d4a3
update namespace
zhichen3 Jun 7, 2023
72b8804
update nse_check
zhichen3 Jun 17, 2023
55bc3fa
Merge branch 'development' into nse_neutron
zhichen3 Jun 19, 2023
2ab2f6a
add stdouts if nse solver failed
zhichen3 Jun 19, 2023
7be2a8b
change single_group metric for non-neutron network
zhichen3 Jun 19, 2023
fe90094
clean-up
zhichen3 Jun 20, 2023
b926f07
add doc description
zhichen3 Jun 20, 2023
39e9590
remove comment
zhichen3 Jun 20, 2023
24c3375
more clean-up
zhichen3 Jun 20, 2023
bc98b07
more cleanup
zhichen3 Jun 20, 2023
61d2f4f
Merge branch 'development' into nse_neutron
zingale Jun 24, 2023
228284e
Merge branch 'development' into nse_neutron
zhichen3 Jul 5, 2023
02f620d
update checking condition
zhichen3 Jul 6, 2023
f447ae1
update NSE_NET to use templated rate indices
zhichen3 Jul 8, 2023
42d909e
fix typo
zhichen3 Jul 8, 2023
46e31d5
Merge branch 'nse_neutron' into optimize_nse
zhichen3 Jul 8, 2023
17f7803
Merge branch 'development' into nse_neutron
zhichen3 Jul 8, 2023
a5939a2
Merge branch 'nse_neutron' into optimize_nse
zhichen3 Jul 8, 2023
d9d5f78
update y_e warning message
zhichen3 Jul 10, 2023
ad8dd9b
update ye warning message
zhichen3 Jul 10, 2023
202479b
Merge branch 'development' into optimize_nse
zhichen3 Jul 10, 2023
7e3fe94
use constexpr
zhichen3 Jul 10, 2023
28f5aa8
update files for ignition_simple
zhichen3 Jul 11, 2023
fa939d9
Merge branch 'development' into optimize_nse
zhichen3 Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions networks/aprox13/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ namespace network
extern AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
// p_index is for photoionization proton
constexpr int p_index= -1;
constexpr int h1_index = -1;
constexpr int n_index = -1;
constexpr int he4_index = 0;
extern AMREX_GPU_MANAGED bool initialized;
}
#endif

namespace Rates {
enum NetworkRates {
He4_He4_He4_to_C12 = 1,
Expand Down
7 changes: 7 additions & 0 deletions networks/aprox13/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace network
AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
AMREX_GPU_MANAGED bool initialized = false;
}
#endif

void actual_network_init()
{
using namespace Species;
Expand Down
11 changes: 11 additions & 0 deletions networks/aprox19/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ namespace table

}

#ifdef NSE_NET
namespace NSE_INDEX
{
// p_index is for photoionization proton
constexpr int p_index = 18;
constexpr int h1_index = 0;
constexpr int n_index = 17;
constexpr int he4_index = 2;
extern AMREX_GPU_MANAGED bool initialized;
}
#endif

namespace Rates {
enum NetworkRates {
Expand Down
7 changes: 7 additions & 0 deletions networks/aprox19/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ namespace table
}
#endif

#ifdef NSE_NET
namespace NSE_INDEX
{
AMREX_GPU_MANAGED bool initialized = false;
}
#endif

void actual_network_init()
{
using namespace Species;
Expand Down
11 changes: 11 additions & 0 deletions networks/aprox21/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ namespace network
extern AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
// p_index is for photoionization proton
constexpr int p_index = 20;
constexpr int h1_index = 0;
constexpr int n_index = 19;
constexpr int he4_index = 2;
extern AMREX_GPU_MANAGED bool initialized;
}
#endif

namespace Rates {
enum NetworkRates {
Expand Down
7 changes: 7 additions & 0 deletions networks/aprox21/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace network
AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
AMREX_GPU_MANAGED bool initialized = false;
}
#endif

void actual_network_init()
{
using namespace Species;
Expand Down
12 changes: 12 additions & 0 deletions networks/ignition_simple/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ namespace network
extern AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
// p_index is for photoionization proton
constexpr int p_index= -1;
constexpr int h1_index = -1;
constexpr int n_index = -1;
constexpr int he4_index = -1;
extern AMREX_GPU_MANAGED bool initialized;
}
#endif

namespace Rates
{
enum NetworkRates
Expand Down
7 changes: 7 additions & 0 deletions networks/ignition_simple/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ namespace network
AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> mion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
AMREX_GPU_MANAGED bool initialized = false;
}
#endif

void actual_network_init()
{
using namespace Species;
Expand Down
12 changes: 12 additions & 0 deletions networks/iso7/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ namespace network
extern AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> wion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
// p_index is for photoionization proton
constexpr int p_index = -1;
constexpr int h1_index = -1;
constexpr int n_index = -1;
constexpr int he4_index = 0;
extern AMREX_GPU_MANAGED bool initialized;
}
#endif

namespace Rates {
enum NetworkRates {
C12_He4_to_O16 = 1,
Expand Down
7 changes: 7 additions & 0 deletions networks/iso7/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ namespace network
AMREX_GPU_MANAGED amrex::Array1D<amrex::Real, 1, NumSpec> wion;
}

#ifdef NSE_NET
namespace NSE_INDEX
{
AMREX_GPU_MANAGED bool initialized = false;
}
#endif

void actual_network_init()
{
using namespace Species;
Expand Down
3 changes: 0 additions & 3 deletions nse_solver/Make.package
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
ifeq ($(USE_NSE_NET), TRUE)
CEXE_headers += nse_solver.H
CEXE_headers += nse_check.H
CEXE_headers += nse_index.H

CEXE_sources += nse_index.cpp
endif
73 changes: 12 additions & 61 deletions nse_solver/nse_check.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <actual_network.H>
#include <eos_composition.H>
#include <microphysics_sort.H>
#include <nse_index.H>
#include <nse_solver.H>

// Currently doesn't support aprox networks, only networks produced by pynucastro
Expand All @@ -33,7 +32,7 @@ void check_nse_molar(burn_t& state, const burn_t& nse_state, bool& nse_check) {

// raise error if no proton or helium-4 in the network.

if (NSE_INDEX::p_index == -1 || NSE_INDEX::he4_index == -1) {
if (NSE_INDEX::h1_index == -1 || NSE_INDEX::he4_index == -1) {
amrex::Error("Need proton and helium-4 in the network for NSE_NET to work");
}

Expand All @@ -44,7 +43,7 @@ void check_nse_molar(burn_t& state, const burn_t& nse_state, bool& nse_check) {

for (int n = 0; n < NumSpec; ++n) {

if (n == NSE_INDEX::p_index || n == NSE_INDEX::n_index) {
if (n == NSE_INDEX::h1_index || n == NSE_INDEX::n_index) {
r /= state.xn[n] * state.xn[n] * aion_inv[n] * aion_inv[n];
r_nse /= nse_state.xn[n] * nse_state.xn[n] * aion_inv[n] * aion_inv[n];
}
Expand Down Expand Up @@ -428,7 +427,7 @@ void find_fast_reaction_cycle(const int current_nuc_ind, const amrex::Array1D<am
reaction_scratch(3) = -1;

product_scratch(1) = reactions(i+1, k);
product_scratch(2) = NSE_INDEX::p_index;
product_scratch(2) = NSE_INDEX::h1_index;
product_scratch(3) = -1;

get_rate_by_nuc(rate_index, reaction_scratch, product_scratch);
Expand All @@ -446,10 +445,10 @@ void find_fast_reaction_cycle(const int current_nuc_ind, const amrex::Array1D<am
continue;
}

b_r = screened_rates(rate_index) * Y(reactions(i+1, k) + 1) * Y(NSE_INDEX::p_index + 1) * state.rho;
b_r = screened_rates(rate_index) * Y(reactions(i+1, k) + 1) * Y(NSE_INDEX::h1_index + 1) * state.rho;

Y_i(1) = Y(NSE_INDEX::he4_index + 1);
Y_i(2) = Y(NSE_INDEX::p_index + 1);
Y_i(2) = Y(NSE_INDEX::h1_index + 1);
}

else if (aion[reactions(i, j)] == aion[reactions(i+1, k)] + 1 &&
Expand Down Expand Up @@ -496,7 +495,7 @@ void find_fast_reaction_cycle(const int current_nuc_ind, const amrex::Array1D<am
reaction_scratch(3) = -1;

product_scratch(1) = reactions(i+1, k);
product_scratch(2) = NSE_INDEX::p_index;
product_scratch(2) = NSE_INDEX::h1_index;
product_scratch(3) = -1;

get_rate_by_nuc(rate_index, reaction_scratch, product_scratch);
Expand All @@ -514,9 +513,9 @@ void find_fast_reaction_cycle(const int current_nuc_ind, const amrex::Array1D<am
continue;
}

b_r = screened_rates(rate_index) * Y(reactions(i+1, k) + 1) * Y(NSE_INDEX::p_index + 1) * state.rho;
b_r = screened_rates(rate_index) * Y(reactions(i+1, k) + 1) * Y(NSE_INDEX::h1_index + 1) * state.rho;

Y_i(1) = Y(NSE_INDEX::p_index + 1);
Y_i(1) = Y(NSE_INDEX::h1_index + 1);
Y_i(2) = 0.0_rt;
}

Expand Down Expand Up @@ -651,54 +650,6 @@ void nse_union(const int nuc_ind_a, const int nuc_ind_b, amrex::Array1D<int, 1,
}
}


AMREX_GPU_HOST_DEVICE AMREX_INLINE
int get_pair_rate_index(const int& rate_index) {

// This function finds the pair rate index given a rate.
// For example given forward rate index, return reverse rate index, vice versa

int pair_rate_index = -1;
bool found_reverse_rate = false;
bool valid_rate = false;

// if all -1 then return, since its an invalid rate

for (int n = 1; n <= 6; ++n) {
if (NSE_INDEX::rate_indices(rate_index, n) != -1) {
valid_rate = true;
break;
}
}

if (!valid_rate) {
return pair_rate_index;
}


for (int n = 1; n <= Rates::NumRates; ++n) {
for (int i = 1; i <= 3; ++i) {
if (NSE_INDEX::rate_indices(n, i) == NSE_INDEX::rate_indices(rate_index, i+3)
&& NSE_INDEX::rate_indices(n, i+3) == NSE_INDEX::rate_indices(rate_index, i)
) {
found_reverse_rate = true;
}
else {
found_reverse_rate = false;
break;
}
}

if (found_reverse_rate) {
pair_rate_index = n;
break;
}
}

return pair_rate_index;
}


AMREX_GPU_HOST_DEVICE AMREX_INLINE
bool in_single_group(const amrex::Array1D<int, 1, NumSpec>& group_ind) {

Expand Down Expand Up @@ -810,7 +761,7 @@ void is_fastest_rate(amrex::Array1D<int, 1, 2>& merge_indices,

// find the reverse rate index of the current rate

int pair_rate_index = get_pair_rate_index(current_rate);
int pair_rate_index = NSE_INDEX::rate_indices(current_rate, 7);

// Check if there are > 2 isotopes or 0 isotopes in LIG (light isotope group) in this reaction

Expand Down Expand Up @@ -868,7 +819,7 @@ void is_fastest_rate(amrex::Array1D<int, 1, 2>& merge_indices,

// Find indices that are non n,p,a

if (NSE_INDEX::rate_indices(current_rate, k) != NSE_INDEX::p_index
if (NSE_INDEX::rate_indices(current_rate, k) != NSE_INDEX::h1_index
&& NSE_INDEX::rate_indices(current_rate, k) != NSE_INDEX::n_index
&& NSE_INDEX::rate_indices(current_rate, k) != NSE_INDEX::he4_index
) {
Expand Down Expand Up @@ -983,7 +934,7 @@ void nse_grouping(amrex::Array1D<int, 1, NumSpec>& group_ind, const burn_t& stat

// let n,p,a form the same group (LIG) initially, let 1 be index of LIG

if (i == NSE_INDEX::p_index + 1 || i == NSE_INDEX::n_index + 1
if (i == NSE_INDEX::h1_index + 1 || i == NSE_INDEX::n_index + 1
|| i == NSE_INDEX::he4_index + 1) {

// group_ind(i) = NSE_INDEX::he4_index;
Expand All @@ -994,7 +945,7 @@ void nse_grouping(amrex::Array1D<int, 1, NumSpec>& group_ind, const burn_t& stat

amrex::Array1D<int, 1, 2> merge_indices;
amrex::Real fastest_t;

// Go through each reaction and perform grouping

while(true) {
Expand Down
24 changes: 0 additions & 24 deletions nse_solver/nse_index.H

This file was deleted.

10 changes: 0 additions & 10 deletions nse_solver/nse_index.cpp

This file was deleted.

Loading