Skip to content

Commit

Permalink
Remove hardcoded charge balance in primordial chemistry (#1646)
Browse files Browse the repository at this point in the history
We now use a function that does the charge balance for primordial chemistry, similar to that done for metal chemistry in #1642
  • Loading branch information
psharda authored Aug 29, 2024
1 parent 3cfd7e2 commit fb8b008
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
set(primordial_chem_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/eos_data.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/network_initialization.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/primordial_chem/actual_eos_data.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/primordial_chem/actual_network_data.cpp
${output_dir}/extern_parameters.cpp PARENT_SCOPE)


Expand Down
3 changes: 3 additions & 0 deletions networks/primordial_chem/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <fundamental_constants.H>
#include <network_properties.H>
#include <burn_type.H>

using namespace amrex;

Expand All @@ -26,4 +27,6 @@ namespace Rates

}

void balance_charge(burn_t& state);

#endif
9 changes: 9 additions & 0 deletions networks/primordial_chem/actual_network_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ void actual_network_init()
{

}

void balance_charge(burn_t& state)
{

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

}
4 changes: 2 additions & 2 deletions unit_test/burn_cell_primordial_chem/burn_cell.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <eos.H>
#include <extern_parameters.H>
#include <network.H>
#include <actual_network.H>

amrex::Real grav_constant = 6.674e-8;

Expand Down Expand Up @@ -209,8 +210,7 @@ auto burn_cell_c() -> int {
}

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

// reconserve mass fractions post charge conservation
insum = 0;
Expand Down

0 comments on commit fb8b008

Please sign in to comment.