Skip to content

Commit

Permalink
add tests with both LU schemes to Rosenbrock and BE integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattldawson committed Dec 5, 2024
1 parent 65a4ac4 commit 0b2b8e5
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/micm/solver/solver_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace micm
/// @tparam SolverParametersPolicy Parameters for the ODE solver
/// @tparam DenseMatrixPolicy Policy for dense matrices
/// @tparam SparseMatrixPolicy Policy for sparse matrices
/// @tparam LuDecompositionPolicy Policy for the LU decomposition
template<
class SolverParametersPolicy,
class DenseMatrixPolicy = Matrix<double>,
Expand Down
61 changes: 61 additions & 0 deletions test/integration/test_analytical_backward_euler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,56 @@ template<std::size_t L>
using VectorStateType =
micm::State<micm::VectorMatrix<double, L>, micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<L>>>;

template<std::size_t L>
using VectorBackwardEulerDoolittle = micm::CpuSolverBuilder<
micm::BackwardEulerSolverParameters,
micm::VectorMatrix<double, L>,
micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<L>>, micm::LuDecompositionDoolittle>;

template<std::size_t L>
using VectorStateTypeDoolittle =
micm::State<micm::VectorMatrix<double, L>, micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<L>>, micm::LuDecompositionDoolittle>;

template<std::size_t L>
using VectorBackwardEulerMozart = micm::CpuSolverBuilder<
micm::BackwardEulerSolverParameters,
micm::VectorMatrix<double, L>,
micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<L>>, micm::LuDecompositionMozart>;

template<std::size_t L>
using VectorStateTypeMozart =
micm::State<micm::VectorMatrix<double, L>, micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<L>>, micm::LuDecompositionMozart>;

auto backward_euler = micm::CpuSolverBuilder<micm::BackwardEulerSolverParameters>(micm::BackwardEulerSolverParameters());
auto backard_euler_vector_1 = VectorBackwardEuler<1>(micm::BackwardEulerSolverParameters());
auto backard_euler_vector_2 = VectorBackwardEuler<2>(micm::BackwardEulerSolverParameters());
auto backard_euler_vector_3 = VectorBackwardEuler<3>(micm::BackwardEulerSolverParameters());
auto backard_euler_vector_4 = VectorBackwardEuler<4>(micm::BackwardEulerSolverParameters());

auto backward_euler_vector_doolittle_1 = VectorBackwardEulerDoolittle<1>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_doolittle_2 = VectorBackwardEulerDoolittle<2>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_doolittle_3 = VectorBackwardEulerDoolittle<3>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_doolittle_4 = VectorBackwardEulerDoolittle<4>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_mozart_1 = VectorBackwardEulerMozart<1>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_mozart_2 = VectorBackwardEulerMozart<2>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_mozart_3 = VectorBackwardEulerMozart<3>(micm::BackwardEulerSolverParameters());
auto backward_euler_vector_mozart_4 = VectorBackwardEulerMozart<4>(micm::BackwardEulerSolverParameters());

TEST(AnalyticalExamples, Troe)
{
test_analytical_troe(backward_euler, 1e-6);
test_analytical_troe<VectorBackwardEuler<1>, VectorStateType<1>>(backard_euler_vector_1, 1e-6);
test_analytical_troe<VectorBackwardEuler<2>, VectorStateType<2>>(backard_euler_vector_2, 1e-6);
test_analytical_troe<VectorBackwardEuler<3>, VectorStateType<3>>(backard_euler_vector_3, 1e-6);
test_analytical_troe<VectorBackwardEuler<4>, VectorStateType<4>>(backard_euler_vector_4, 1e-6);
test_analytical_troe<VectorBackwardEulerDoolittle<1>, VectorStateTypeDoolittle<1>>(backward_euler_vector_doolittle_1, 1e-6);
test_analytical_troe<VectorBackwardEulerDoolittle<2>, VectorStateTypeDoolittle<2>>(backward_euler_vector_doolittle_2, 1e-6);
test_analytical_troe<VectorBackwardEulerDoolittle<3>, VectorStateTypeDoolittle<3>>(backward_euler_vector_doolittle_3, 1e-6);
test_analytical_troe<VectorBackwardEulerDoolittle<4>, VectorStateTypeDoolittle<4>>(backward_euler_vector_doolittle_4, 1e-6);
test_analytical_troe<VectorBackwardEulerMozart<1>, VectorStateTypeMozart<1>>(backward_euler_vector_mozart_1, 1e-6);
test_analytical_troe<VectorBackwardEulerMozart<2>, VectorStateTypeMozart<2>>(backward_euler_vector_mozart_2, 1e-6);
test_analytical_troe<VectorBackwardEulerMozart<3>, VectorStateTypeMozart<3>>(backward_euler_vector_mozart_3, 1e-6);
test_analytical_troe<VectorBackwardEulerMozart<4>, VectorStateTypeMozart<4>>(backward_euler_vector_mozart_4, 1e-6);
}

TEST(AnalyticalExamples, TroeSuperStiffButAnalytical)
Expand Down Expand Up @@ -144,9 +181,33 @@ TEST(AnalyticalExamples, SurfaceRxn)
TEST(AnalyticalExamples, HIRES)
{
test_analytical_hires(backward_euler, 1e-1);
test_analytical_hires<VectorBackwardEuler<1>, VectorStateType<1>>(backard_euler_vector_1, 1e-1);
test_analytical_hires<VectorBackwardEuler<2>, VectorStateType<2>>(backard_euler_vector_2, 1e-1);
test_analytical_hires<VectorBackwardEuler<3>, VectorStateType<3>>(backard_euler_vector_3, 1e-1);
test_analytical_hires<VectorBackwardEuler<4>, VectorStateType<4>>(backard_euler_vector_4, 1e-1);
test_analytical_hires<VectorBackwardEulerDoolittle<1>, VectorStateTypeDoolittle<1>>(backward_euler_vector_doolittle_1, 1e-1);
test_analytical_hires<VectorBackwardEulerDoolittle<2>, VectorStateTypeDoolittle<2>>(backward_euler_vector_doolittle_2, 1e-1);
test_analytical_hires<VectorBackwardEulerDoolittle<3>, VectorStateTypeDoolittle<3>>(backward_euler_vector_doolittle_3, 1e-1);
test_analytical_hires<VectorBackwardEulerDoolittle<4>, VectorStateTypeDoolittle<4>>(backward_euler_vector_doolittle_4, 1e-1);
test_analytical_hires<VectorBackwardEulerMozart<1>, VectorStateTypeMozart<1>>(backward_euler_vector_mozart_1, 1e-1);
test_analytical_hires<VectorBackwardEulerMozart<2>, VectorStateTypeMozart<2>>(backward_euler_vector_mozart_2, 1e-1);
test_analytical_hires<VectorBackwardEulerMozart<3>, VectorStateTypeMozart<3>>(backward_euler_vector_mozart_3, 1e-1);
test_analytical_hires<VectorBackwardEulerMozart<4>, VectorStateTypeMozart<4>>(backward_euler_vector_mozart_4, 1e-1);
}

TEST(AnalyticalExamples, Oregonator)
{
test_analytical_oregonator(backward_euler, 1e-3);
test_analytical_oregonator<VectorBackwardEuler<1>, VectorStateType<1>>(backard_euler_vector_1, 1e-3);
test_analytical_oregonator<VectorBackwardEuler<2>, VectorStateType<2>>(backard_euler_vector_2, 1e-3);
test_analytical_oregonator<VectorBackwardEuler<3>, VectorStateType<3>>(backard_euler_vector_3, 1e-3);
test_analytical_oregonator<VectorBackwardEuler<4>, VectorStateType<4>>(backard_euler_vector_4, 1e-3);
test_analytical_oregonator<VectorBackwardEulerDoolittle<1>, VectorStateTypeDoolittle<1>>(backward_euler_vector_doolittle_1, 1e-3);
test_analytical_oregonator<VectorBackwardEulerDoolittle<2>, VectorStateTypeDoolittle<2>>(backward_euler_vector_doolittle_2, 1e-3);
test_analytical_oregonator<VectorBackwardEulerDoolittle<3>, VectorStateTypeDoolittle<3>>(backward_euler_vector_doolittle_3, 1e-3);
test_analytical_oregonator<VectorBackwardEulerDoolittle<4>, VectorStateTypeDoolittle<4>>(backward_euler_vector_doolittle_4, 1e-3);
test_analytical_oregonator<VectorBackwardEulerMozart<1>, VectorStateTypeMozart<1>>(backward_euler_vector_mozart_1, 1e-3);
test_analytical_oregonator<VectorBackwardEulerMozart<2>, VectorStateTypeMozart<2>>(backward_euler_vector_mozart_2, 1e-3);
test_analytical_oregonator<VectorBackwardEulerMozart<3>, VectorStateTypeMozart<3>>(backward_euler_vector_mozart_3, 1e-3);
test_analytical_oregonator<VectorBackwardEulerMozart<4>, VectorStateTypeMozart<4>>(backward_euler_vector_mozart_4, 1e-3);
}
Loading

0 comments on commit 0b2b8e5

Please sign in to comment.