From da7f5e5022484103f258e6f4972db591a6d22cd9 Mon Sep 17 00:00:00 2001 From: Aaron Dotter Date: Thu, 6 Mar 2025 14:36:07 -0500 Subject: [PATCH] adding more quantities to the eos test, including derivatives --- src/eos/public/helm.h | 33 ++++++++++++++++++++------------- tests/eos/eosTest.cpp | 25 ++++++++++++++++++++----- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/eos/public/helm.h b/src/eos/public/helm.h index 0c9654a..5c3c90c 100644 --- a/src/eos/public/helm.h +++ b/src/eos/public/helm.h @@ -13,6 +13,7 @@ #include #include #include +#include /** * @brief 2D array template alias. @@ -193,18 +194,24 @@ namespace helmholtz friend std::ostream& operator<<(std::ostream& os, const helmholtz::EOS& eos) { os << "EOS Data:\n" << std::setw(20) << std::left; - os << " Electron Fraction: " << eos.ye << "\n"; - os << " Electron Chemical Potential: " << eos.etaele << "\n"; - os << " Electron Number Density: " << eos.xnefer << "\n"; - os << " Total Pressure: " << eos.ptot << "\n"; - os << " Gas Pressure: " << eos.pgas << "\n"; - os << " Radiation Pressure: " << eos.prad << "\n"; - os << " Total Energy: " << eos.etot << "\n"; - os << " Gas Energy: " << eos.egas << "\n"; - os << " Radiation Energy: " << eos.erad << "\n"; - os << " Total Entropy: " << eos.stot << "\n"; - os << " Gas Entropy: " << eos.sgas << "\n"; - os << " Radiation Entropy: " << eos.srad; + os << " Electron Fraction: " << std::format("{0:24.16e}",eos.ye) << "\n"; + os << " Electron Chemical Potential: " << std::format("{0:24.16e}",eos.etaele) << "\n"; + os << " Electron Number Density: " << std::format("{0:24.16e}",eos.xnefer) << "\n"; + os << " Total Pressure: " << std::format("{0:24.16e}",eos.ptot) << "\n"; + os << " dPres/dRho: " << std::format("{0:24.16e}",eos.dpresdd) << "\n"; + os << " dPres/dT: " << std::format("{0:24.16e}",eos.dpresdt) << "\n"; + os << " Gas Pressure: " << std::format("{0:24.16e}",eos.pgas) << "\n"; + os << " Radiation Pressure: " << std::format("{0:24.16e}",eos.prad) << "\n"; + os << " Total Energy: " << std::format("{0:24.16e}",eos.etot) << "\n"; + os << " dEner/dRho: " << std::format("{0:24.16e}",eos.denerdd) << "\n"; + os << " dEner/dT: " << std::format("{0:24.16e}",eos.denerdt) << "\n"; + os << " Gas Energy: " << std::format("{0:24.16e}",eos.egas) << "\n"; + os << " Radiation Energy: " << std::format("{0:24.16e}",eos.erad) << "\n"; + os << " Total Entropy: " << std::format("{0:24.16e}",eos.stot) << "\n"; + os << " dEntr/dRho: " << std::format("{0:24.16e}",eos.dentrdd) << "\n"; + os << " dEntr/dT: " << std::format("{0:24.16e}",eos.dentrdt) << "\n"; + os << " Gas Entropy: " << std::format("{0:24.16e}",eos.sgas) << "\n"; + os << " Radiation Entropy: " << std::format("{0:24.16e}",eos.srad); return os; } }; @@ -356,4 +363,4 @@ namespace helmholtz } -#endif // HELM_H \ No newline at end of file +#endif // HELM_H diff --git a/tests/eos/eosTest.cpp b/tests/eos/eosTest.cpp index d9f9317..2ff0be7 100644 --- a/tests/eos/eosTest.cpp +++ b/tests/eos/eosTest.cpp @@ -62,9 +62,24 @@ TEST_F(eosTest, get_helm_EOS) { EOS eos = get_helm_EOS(eos1, table); // std::cout << eos << std::endl; - EXPECT_DOUBLE_EQ(eos.ye, 0.875); - EXPECT_DOUBLE_EQ(eos.etaele, 23.04334823102155); - // TODO: Add more tests for more values + //Check composition info + EXPECT_DOUBLE_EQ( eos.ye, 8.75e-01); + + //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); + + 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); } - -