Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions Docs/source/unit_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ One-zone tests

exercise the partition function interpolation for a few select nuclei.

* ``table_rate_cell``

evaluate a tabular weak rate from a pynucastro network. This is meant to be
used for a direct comparison to pynucastro to make sure the interpolation is
working.

Infrastructure tests
====================
Expand Down
39 changes: 39 additions & 0 deletions unit_test/table_rate_cell/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PRECISION = DOUBLE
PROFILE = FALSE

DEBUG = FALSE

DIM = 3

COMP = gnu

USE_MPI = FALSE
USE_OMP = FALSE

USE_REACT = TRUE

EBASE = main

BL_NO_FORT = TRUE

# define the location of the Microphysics top directory
MICROPHYSICS_HOME := ../..

# This sets the EOS directory
EOS_DIR := helmholtz

# This sets the network directory
NETWORK_DIR := he-burn/ase-iron
SCREEN_METHOD := screen5
CONDUCTIVITY_DIR := stellar

INTEGRATOR_DIR = VODE

EXTERN_SEARCH += . ..

Bpack := ./Make.package
Blocs := .

include $(MICROPHYSICS_HOME)/unit_test/Make.unit_test


2 changes: 2 additions & 0 deletions unit_test/table_rate_cell/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CEXE_sources += main.cpp
CEXE_headers += burn_cell.H
7 changes: 7 additions & 0 deletions unit_test/table_rate_cell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# table_rate_cell

A simple driver to just evaluate a tabulated weak rate from a
pynucastro network.

This is setup for the ``ase-iron`` network and just does the
interpolation and outputs the raw rate.
5 changes: 5 additions & 0 deletions unit_test/table_rate_cell/_parameters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@namespace: unit_test

density real 2.e7

temperature real 4.e9
59 changes: 59 additions & 0 deletions unit_test/table_rate_cell/burn_cell.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef BURN_CELL_H
#define BURN_CELL_H

#include <extern_parameters.H>
#include <eos.H>
#include <network.H>
#include <burner.H>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <react_util.H>

#include <network_properties.H>
#include <table_rates.H>

AMREX_INLINE
void burn_cell_c()
{

amrex::Real massfractions[NumSpec]{};
for (int n = 0; n < NumSpec; ++n) {
massfractions[n] = 1.0_rt / NumSpec;
}



std::cout << std::endl;
std::cout << "State Density (g/cm^3): " << unit_test_rp::density << std::endl;
std::cout << "State Temperature (K): " << unit_test_rp::temperature << std::endl;
std::cout << std::endl;

amrex::Real ye{};
for (int i = 0; i < NumSpec; ++i) {
ye += zion[i] * massfractions[i] / aion[i];
}

std::cout << "Ye = " << ye << std::endl;
std::cout << std::endl;

auto rhoy = unit_test_rp::density * ye;
auto T = unit_test_rp::temperature;

amrex::Real log_temp = std::log10(T);
amrex::Real log_rhoy = std::log10(rhoy);

[[maybe_unused]] amrex::Real rate, drate_dt, edot_nu, edot_gamma;

tabular_evaluate(j_Co56_Fe56_meta, j_Co56_Fe56_rhoy, j_Co56_Fe56_temp, j_Co56_Fe56_data,
log_rhoy, log_temp, T, rate, drate_dt, edot_nu, edot_gamma);

std::cout << "Co56 -> Fe56 rate = " << rate << std::endl;

tabular_evaluate(j_Co56_Ni56_meta, j_Co56_Ni56_rhoy, j_Co56_Ni56_temp, j_Co56_Ni56_data,
log_rhoy, log_temp, T, rate, drate_dt, edot_nu, edot_gamma);

std::cout << "Co56 -> Ni56 rate = " << rate << std::endl;

}
#endif
28 changes: 28 additions & 0 deletions unit_test/table_rate_cell/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>

#include <extern_parameters.H>
#include <eos.H>
#include <network.H>
#include <burn_cell.H>
#include <unit_test.H>

using namespace unit_test_rp;

int main(int argc, char *argv[]) {

amrex::Initialize(argc, argv);

std::cout << "starting the single zone burn..." << std::endl;

init_unit_test();

// C++ EOS initialization (must be done after init_extern_parameters)
eos_init(small_temp, small_dens);

// C++ Network, RHS, screening, rates initialization
network_init();

burn_cell_c();

amrex::Finalize();
}
Loading