Skip to content

Commit

Permalink
Fix the test_react unit test (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
biboyd authored Sep 14, 2023
1 parent 2d0c580 commit 4a30297
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 37 deletions.
3 changes: 3 additions & 0 deletions Exec/unit_tests/test_react/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ USE_REACT = TRUE
# define the location of the MAESTROEX home directory
MAESTROEX_HOME := ../../..

MAX_ZONES := 4096

DEFINES += -DN_XN_ZONES=$(MAX_ZONES)

# define the physics packages to build this problem
EOS_DIR := helmholtz
Expand Down
13 changes: 11 additions & 2 deletions Exec/unit_tests/test_react/MaestroEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ using namespace problem_rp;

// advance solution to final time
void Maestro::Evolve() {

if (fixed_dt != -1.0) {
dt = fixed_dt;
if (maestro_verbose > 0) {
Print() << "Setting fixed dt = " << dt;
}
}

Vector<MultiFab> rho_omegadot(finest_level + 1);
Vector<MultiFab> rho_Hnuc(finest_level + 1);
Vector<MultiFab> rho_Hext(finest_level + 1);
Expand Down Expand Up @@ -60,13 +68,14 @@ void Maestro::Evolve() {
WritePlotFile(-4, t_new, dt, dummy, dummy, dummy, dummy, rho_omegadot,
rho_Hnuc, rho_Hext);

// Explore ten orders of magnitude of the time domain using user inputs.
// Explore orders of magnitude of the time domain using user inputs.
do_burning = dbo;
do_heating = dho;

dt = min_time_step;
for (auto i = 0; i < react_its; ++i) {
React(sold, snew, rho_Hext, rho_omegadot, rho_Hnuc, p0_old, dt, t_old);
WritePlotFile(i, t_new, dt, dummy, dummy, dummy, dummy, rho_omegadot,
rho_Hnuc, rho_Hext);
dt*=10._rt;
}
}
44 changes: 39 additions & 5 deletions Exec/unit_tests/test_react/MaestroInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,43 @@ void Maestro::MakeNewLevelFromScratch(int lev, Real time, const BoxArray& ba,
const auto temp_min_l = temp_min;
const auto dens_min_l = dens_min;

GpuArray<Real, NumSpec> xn_zone;
// FIXME: need to allocate the xns here

//read in composition
Array2D<Real, 0, N_XN_ZONES, 0, NumSpec> xn_zone;
if (xin_file == "uniform"){
for (auto k = 0; k < xn_hi; ++k){
for (auto comp = 0; comp < NumSpec; ++comp) {
xn_zone(k, comp) = 1./NumSpec;
}
}
}
else {
// open the file
std::ifstream xn_file_s(xin_file);
Print() << " xin file = " << xin_file << std::endl;

if (!xn_file_s.is_open()) {
Abort("Could not open xin file!");
}

// start reading in the data
int comp = 0;
std::string line;
while (std::getline(xn_file_s, line)) {
//skip comments w/ nuc name
if (line.at(0) != '#'){
std::istringstream iss(line);
for (auto k = 0; k < xn_hi; ++k) {
iss >> xn_zone(k, comp);
}
++comp;
}
}
xn_file_s.close();
if (comp != NumSpec){
Abort("Number of species in xinfile does not match number in Network");
}
}

// Loop over boxes (make sure mfi takes a cell-centered multifab as an argument)
#ifdef _OPENMP
#pragma omp parallel
Expand All @@ -133,7 +167,7 @@ void Maestro::MakeNewLevelFromScratch(int lev, Real time, const BoxArray& ba,
eos_state.T = temp_zone;
eos_state.rho = dens_zone;
for (auto comp = 0; comp < NumSpec; ++comp) {
eos_state.xn[comp] = xn_zone[comp];
eos_state.xn[comp] = xn_zone(k, comp);
}

eos(eos_input_rt, eos_state);
Expand All @@ -143,7 +177,7 @@ void Maestro::MakeNewLevelFromScratch(int lev, Real time, const BoxArray& ba,
scal(i, j, k, RhoH) = dens_zone * eos_state.h;
scal(i, j, k, Temp) = temp_zone;
for (auto comp = 0; comp < NumSpec; ++comp) {
scal(i, j, k, FirstSpec + comp) = dens_zone * xn_zone[comp];
scal(i, j, k, FirstSpec + comp) = dens_zone * xn_zone(k, comp);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_3alpha
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_aprox13
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_ignition
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_mesa_carbon
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_reaclib_cburn
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = true
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_reaclib_ctest
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_reaclib_urca
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_react
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_rprox
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down
6 changes: 3 additions & 3 deletions Exec/unit_tests/test_react/inputs_xrb_simple
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ maestro.hi_bc = 0 0 0
geometry.is_periodic = 1 1 1

# VERBOSITY
maestro.v = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 0
maestro.cg_verbose = 0

# DIFFUSION parameters
maestro.do_heating = false
Expand Down

0 comments on commit 4a30297

Please sign in to comment.