Skip to content

Commit

Permalink
renaming variable
Browse files Browse the repository at this point in the history
  • Loading branch information
K20shores committed Oct 3, 2024
1 parent 3170f52 commit fd97908
Showing 1 changed file with 43 additions and 57 deletions.
100 changes: 43 additions & 57 deletions test/integration/analytical_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ template<class BuilderPolicy, class StateType>
void test_simple_system(
const std::string& test_label,
BuilderPolicy builder,
double relative_tolerance,
std::vector<double> absolute_tolerances,
double absolute_tolerances,
std::function<double(double temperature, double pressure, double air_density)> calculate_k1,
std::function<double(double temperature, double pressure, double air_density)> calculate_k2,
std::function<void(StateType&)> prepare_for_solve,
Expand Down Expand Up @@ -212,8 +211,8 @@ void test_simple_system(
EXPECT_EQ(result.state_, (micm::SolverState::Converged));
for (std::size_t i = 0; i < NUM_CELLS; ++i)
{
EXPECT_NEAR(k1[i], state.rate_constants_[i][0], relative_tolerance);
EXPECT_NEAR(k2[i], state.rate_constants_[i][1], relative_tolerance);
EXPECT_NEAR(k1[i], state.rate_constants_[i][0], absolute_tolerances);
EXPECT_NEAR(k2[i], state.rate_constants_[i][1], absolute_tolerances);
model_concentrations[i_time][i][idx_A] = state.variables_[i][_a];
model_concentrations[i_time][i][idx_B] = state.variables_[i][_b];
model_concentrations[i_time][i][idx_C] = state.variables_[i][_c];
Expand Down Expand Up @@ -246,17 +245,17 @@ void test_simple_system(
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_A],
analytical_concentrations[i_time][i_cell][idx_A],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 0 << ") for " << test_label;
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_B],
analytical_concentrations[i_time][i_cell][idx_B],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 1 << ") for " << test_label;
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_C],
analytical_concentrations[i_time][i_cell][idx_C],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 2 << ") for " << test_label;
}
}
Expand All @@ -267,8 +266,7 @@ template<class BuilderPolicy, class StateType>
void test_simple_stiff_system(
const std::string& test_label,
BuilderPolicy builder,
double relative_tolerance,
std::vector<double> absolute_tolerances,
double absolute_tolerances,
std::function<double(double temperature, double pressure, double air_density)> calculate_k1,
std::function<double(double temperature, double pressure, double air_density)> calculate_k2,
std::function<void(StateType&)> prepare_for_solve,
Expand Down Expand Up @@ -368,17 +366,17 @@ void test_simple_stiff_system(
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_A],
analytical_concentrations[i_time][i_cell][idx_A],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 0 << ") for " << test_label;
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_B],
analytical_concentrations[i_time][i_cell][idx_B],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 1 << ") for " << test_label;
EXPECT_NEAR(
model_concentrations[i_time][i_cell][idx_C],
analytical_concentrations[i_time][i_cell][idx_C],
relative_tolerance)
absolute_tolerances)
<< "Arrays differ at index (" << i_time << ", " << i_cell << ", " << 2 << ") for " << test_label;
}
}
Expand All @@ -391,7 +389,7 @@ void test_simple_stiff_system(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_troe(
BuilderPolicy builder,
double tolerance = 1e-10,
double absolute_tolerances = 1e-10,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -433,8 +431,7 @@ void test_analytical_troe(
test_simple_system<BuilderPolicy, StateType>(
"troe",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -458,7 +455,7 @@ void test_analytical_troe(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_troe(
BuilderPolicy builder,
double tolerance = 1e-5,
double absolute_tolerances = 1e-5,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -521,8 +518,7 @@ void test_analytical_stiff_troe(
test_simple_stiff_system<BuilderPolicy, StateType>(
"troe",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -546,7 +542,7 @@ void test_analytical_stiff_troe(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_photolysis(
BuilderPolicy builder,
double tolerance = 2e-6,
double absolute_tolerances = 2e-6,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -585,8 +581,7 @@ void test_analytical_photolysis(
test_simple_system<BuilderPolicy, StateType>(
"photolysis",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -605,7 +600,7 @@ void test_analytical_photolysis(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_photolysis(
BuilderPolicy builder,
double tolerance = 2e-5,
double absolute_tolerances = 2e-5,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -667,8 +662,7 @@ void test_analytical_stiff_photolysis(
test_simple_stiff_system<BuilderPolicy, StateType>(
"photolysis",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -687,7 +681,7 @@ void test_analytical_stiff_photolysis(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_ternary_chemical_activation(
BuilderPolicy builder,
double tolerance = 1e-08,
double absolute_tolerances = 1e-08,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -730,8 +724,7 @@ void test_analytical_ternary_chemical_activation(
test_simple_system<BuilderPolicy, StateType>(
"ternary_chemical_activation",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -755,7 +748,7 @@ void test_analytical_ternary_chemical_activation(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_ternary_chemical_activation(
BuilderPolicy builder,
double tolerance = 1e-6,
double absolute_tolerances = 1e-6,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -818,8 +811,7 @@ void test_analytical_stiff_ternary_chemical_activation(
test_simple_stiff_system<BuilderPolicy, StateType>(
"ternary_chemical_activation",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -843,7 +835,7 @@ void test_analytical_stiff_ternary_chemical_activation(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_tunneling(
BuilderPolicy builder,
double tolerance = 1e-8,
double absolute_tolerances = 1e-8,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -879,8 +871,7 @@ void test_analytical_tunneling(
test_simple_system<BuilderPolicy, StateType>(
"tunneling",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -900,7 +891,7 @@ void test_analytical_tunneling(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_tunneling(
BuilderPolicy builder,
double tolerance = 1e-6,
double absolute_tolerances = 1e-6,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -956,8 +947,7 @@ void test_analytical_stiff_tunneling(
test_simple_stiff_system<BuilderPolicy, StateType>(
"tunneling",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -977,7 +967,7 @@ void test_analytical_stiff_tunneling(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_arrhenius(
BuilderPolicy builder,
double tolerance = 1e-9,
double absolute_tolerances = 1e-9,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -1012,8 +1002,7 @@ void test_analytical_arrhenius(
test_simple_system<BuilderPolicy, StateType>(
"arrhenius",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -1033,7 +1022,7 @@ void test_analytical_arrhenius(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_arrhenius(
BuilderPolicy builder,
double tolerance = 1e-6,
double absolute_tolerances = 1e-6,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -1090,8 +1079,7 @@ void test_analytical_stiff_arrhenius(
test_simple_stiff_system<BuilderPolicy, StateType>(
"arrhenius",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand All @@ -1111,7 +1099,7 @@ void test_analytical_stiff_arrhenius(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_branched(
BuilderPolicy builder,
double tolerance = 1e-13,
double absolute_tolerances = 1e-13,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -1156,8 +1144,7 @@ void test_analytical_branched(
test_simple_system<BuilderPolicy, StateType>(
"branched",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand Down Expand Up @@ -1195,7 +1182,7 @@ void test_analytical_branched(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_stiff_branched(
BuilderPolicy builder,
double tolerance = 1e-6,
double absolute_tolerances = 1e-6,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -1266,8 +1253,7 @@ void test_analytical_stiff_branched(
test_simple_stiff_system<BuilderPolicy, StateType>(
"branched",
builder,
tolerance,
{ 1e-7, 1e-7, 1e-7 },
absolute_tolerances,
[](double temperature, double pressure, double air_density)
{
// A->B reaction rate
Expand Down Expand Up @@ -1625,7 +1611,7 @@ void test_analytical_oregonator(
template<class BuilderPolicy, class StateType = micm::State<>>
void test_analytical_hires(
BuilderPolicy builder,
double tolerance = 1e-8,
double absolute_tolerance = 1e-8,
std::function<void(StateType&)> prepare_for_solve = [](StateType& state) {},
std::function<void(StateType&)> postpare_for_solve = [](StateType& state) {})
{
Expand Down Expand Up @@ -1797,21 +1783,21 @@ void test_analytical_hires(

for (size_t i = 1; i < model_concentrations.size(); ++i)
{
EXPECT_NEAR(model_concentrations[i][_y0], analytical_concentrations[i][0], tolerance)
EXPECT_NEAR(model_concentrations[i][_y0], analytical_concentrations[i][0], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 0 << ")";
EXPECT_NEAR(model_concentrations[i][_y1], analytical_concentrations[i][1], tolerance)
EXPECT_NEAR(model_concentrations[i][_y1], analytical_concentrations[i][1], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 1 << ")";
EXPECT_NEAR(model_concentrations[i][_y2], analytical_concentrations[i][2], tolerance)
EXPECT_NEAR(model_concentrations[i][_y2], analytical_concentrations[i][2], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 2 << ")";
EXPECT_NEAR(model_concentrations[i][_y3], analytical_concentrations[i][3], tolerance)
EXPECT_NEAR(model_concentrations[i][_y3], analytical_concentrations[i][3], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 3 << ")";
EXPECT_NEAR(model_concentrations[i][_y4], analytical_concentrations[i][4], tolerance)
EXPECT_NEAR(model_concentrations[i][_y4], analytical_concentrations[i][4], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 4 << ")";
EXPECT_NEAR(model_concentrations[i][_y5], analytical_concentrations[i][5], tolerance)
EXPECT_NEAR(model_concentrations[i][_y5], analytical_concentrations[i][5], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 5 << ")";
EXPECT_NEAR(model_concentrations[i][_y6], analytical_concentrations[i][6], tolerance)
EXPECT_NEAR(model_concentrations[i][_y6], analytical_concentrations[i][6], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 6 << ")";
EXPECT_NEAR(model_concentrations[i][_y7], analytical_concentrations[i][7], tolerance)
EXPECT_NEAR(model_concentrations[i][_y7], analytical_concentrations[i][7], absolute_tolerance)
<< "Arrays differ at index (" << i << ", " << 7 << ")";
}
}
Expand Down

0 comments on commit fd97908

Please sign in to comment.