diff --git a/tests/eos/eosTest.cpp b/tests/eos/eosTest.cpp index 2ff0be7..2db0d8a 100644 --- a/tests/eos/eosTest.cpp +++ b/tests/eos/eosTest.cpp @@ -1,11 +1,12 @@ #include #include +#include #include -#include -#include #include #include "helm.h" +#include "resourceManager.h" +#include "config.h" /** * @file constTest.cpp @@ -17,21 +18,21 @@ */ class eosTest : public ::testing::Test {}; -std::string HELM_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/assets/eos/helm_table.dat"; +std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml"; + /** * @test Verify default constructor initializes correctly. */ -TEST_F(eosTest, constructor) { - using namespace helmholtz; - EXPECT_NO_THROW(HELMTable table = read_helm_table(HELM_FILENAME)); -} TEST_F(eosTest, read_helm_table) { - using namespace helmholtz; - HELMTable table = read_helm_table(HELM_FILENAME); + Config::getInstance().loadConfig(TEST_CONFIG); // Capture the << operator output as a string + ResourceManager& rm = ResourceManager::getInstance(); + auto& eos = std::get>(rm.getResource("eos:helm")); + auto& table = eos->getTable(); + auto& helmTable = *std::get>(table); std::stringstream ss; - ss << table; + ss << helmTable; EXPECT_EQ(ss.str(), "HELMTable Data:\n imax: 541, jmax: 201\n Temperature Range: [1000, 1e+13]\n Density Range: [1e-12, 1e+15]\n"); } @@ -58,28 +59,31 @@ TEST_F(eosTest, get_helm_EOS) { eos1.abar = 1.0/asum; eos1.zbar = eos1.abar*zsum; - HELMTable table = read_helm_table(HELM_FILENAME); - EOS eos = get_helm_EOS(eos1, table); - // std::cout << eos << std::endl; + ResourceManager& rm = ResourceManager::getInstance(); + auto& eos = std::get>(rm.getResource("eos:helm")); + auto& table = eos->getTable(); + auto& helmTable = *std::get>(table); + EOS helmEos = get_helm_EOS(eos1, helmTable); + + const double absErr = 1e-12; //Check composition info - EXPECT_DOUBLE_EQ( eos.ye, 8.75e-01); + EXPECT_NEAR( helmEos.ye, 8.75e-01, absErr); //Check E, P, S and derivatives of each wrt Rho and T - EXPECT_DOUBLE_EQ( eos.etaele, 2.3043348231021554e+01); - EXPECT_DOUBLE_EQ( eos.etot, 1.1586558190936826e+17); - EXPECT_DOUBLE_EQ(eos.denerdd, 6.1893000468285858e+10); - EXPECT_DOUBLE_EQ(eos.denerdt, 1.2129708972542575e+08); - EXPECT_DOUBLE_EQ( eos.ptot, 6.9610135220017030e+22); - EXPECT_DOUBLE_EQ(eos.dpresdd, 1.0296440482849070e+17); - EXPECT_DOUBLE_EQ(eos.dpresdt, 7.7171347517311625e+13); - EXPECT_DOUBLE_EQ( eos.stot, 6.0647461970567346e+08); - EXPECT_DOUBLE_EQ(eos.dentrdd,-7.7171347517311645e+01); - EXPECT_DOUBLE_EQ(eos.dentrdt, 1.2129708972542577e+00); + EXPECT_NEAR( helmEos.etaele, 2.3043348231021554e+01, absErr); + EXPECT_NEAR( helmEos.etot, 1.1586558190936826e+17, 1e3); + EXPECT_NEAR(helmEos.denerdd, 6.1893000468285858e+10, 1e-2); + EXPECT_NEAR(helmEos.denerdt, 1.2129708972542575e+08, 1e-7); + EXPECT_NEAR( helmEos.ptot, 6.9610135220017030e+22, 1e10); + EXPECT_NEAR(helmEos.dpresdd, 1.0296440482849070e+17, 1e3); + EXPECT_NEAR(helmEos.dpresdt, 7.7171347517311625e+13, 1.0); + EXPECT_NEAR( helmEos.stot, 6.0647461970567346e+08, 1e-7); + EXPECT_NEAR(helmEos.dentrdd,-7.7171347517311645e+01, absErr); + EXPECT_NEAR(helmEos.dentrdt, 1.2129708972542577e+00, absErr); - const double abs_err = 1.0e-12; // Maxwell relations, should always be zero - EXPECT_NEAR( eos.dse, 0, abs_err); - EXPECT_NEAR( eos.dpe, 0, abs_err); - EXPECT_NEAR( eos.dsp, 0, abs_err); + EXPECT_NEAR( helmEos.dse, 0, absErr); + EXPECT_NEAR( helmEos.dpe, 0, absErr); + EXPECT_NEAR( helmEos.dsp, 0, absErr); } diff --git a/tests/eos/meson.build b/tests/eos/meson.build index 05d2f83..d8154e6 100644 --- a/tests/eos/meson.build +++ b/tests/eos/meson.build @@ -11,7 +11,7 @@ foreach test_file : test_sources test_exe = executable( exe_name, test_file, - dependencies: [gtest_dep, eos_dep, gtest_main], + dependencies: [gtest_dep, eos_dep, gtest_main, resourceManager_dep, config_dep], install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly )