Skip to content

Commit fb8b008

Browse files
authored
Remove hardcoded charge balance in primordial chemistry (AMReX-Astro#1646)
We now use a function that does the charge balance for primordial chemistry, similar to that done for metal chemistry in AMReX-Astro#1642
1 parent 3cfd7e2 commit fb8b008

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
8585
set(primordial_chem_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/eos_data.cpp
8686
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/network_initialization.cpp
8787
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/primordial_chem/actual_eos_data.cpp
88+
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/primordial_chem/actual_network_data.cpp
8889
${output_dir}/extern_parameters.cpp PARENT_SCOPE)
8990

9091

networks/primordial_chem/actual_network.H

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <fundamental_constants.H>
88
#include <network_properties.H>
9+
#include <burn_type.H>
910

1011
using namespace amrex;
1112

@@ -26,4 +27,6 @@ namespace Rates
2627

2728
}
2829

30+
void balance_charge(burn_t& state);
31+
2932
#endif

networks/primordial_chem/actual_network_data.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ void actual_network_init()
1010
{
1111

1212
}
13+
14+
void balance_charge(burn_t& state)
15+
{
16+
17+
// update the number density of electrons due to charge conservation
18+
state.xn[0] = -state.xn[3] - state.xn[7] + state.xn[1] + state.xn[12] +
19+
state.xn[6] + state.xn[4] + state.xn[9] + 2.0 * state.xn[11];
20+
21+
}

unit_test/burn_cell_primordial_chem/burn_cell.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <eos.H>
99
#include <extern_parameters.H>
1010
#include <network.H>
11+
#include <actual_network.H>
1112

1213
amrex::Real grav_constant = 6.674e-8;
1314

@@ -209,8 +210,7 @@ auto burn_cell_c() -> int {
209210
}
210211

211212
// update the number density of electrons due to charge conservation
212-
state.xn[0] = -state.xn[3] - state.xn[7] + state.xn[1] + state.xn[12] +
213-
state.xn[6] + state.xn[4] + state.xn[9] + 2.0 * state.xn[11];
213+
balance_charge(state);
214214

215215
// reconserve mass fractions post charge conservation
216216
insum = 0;

0 commit comments

Comments
 (0)