test(tests/eos): added test for the new composition version of EOS

note that this test is currently minimal and should be expanded
This commit is contained in:
2025-06-16 15:01:05 -04:00
parent cf25c54cda
commit 9100af3fc5
3 changed files with 38 additions and 4 deletions

View File

@@ -7,6 +7,8 @@
#include "helm.h"
#include "resourceManager.h"
#include "config.h"
#include "composition.h"
#include "EOS.h"
/**
* @file constTest.cpp
@@ -39,7 +41,7 @@ TEST_F(eosTest, get_helm_EOS) {
const int nel=3;
double xmass[nel], aion[nel], zion[nel];
serif::eos::helmholtz::EOSInput eos1;
serif::eos::helmholtz::HELMEOSInput eos1;
xmass[0] = 0.75; aion[0] = 1.0; zion[0] = 1.0;
xmass[1] = 0.23; aion[1] = 4.0; zion[1] = 2.0;
@@ -61,7 +63,7 @@ TEST_F(eosTest, get_helm_EOS) {
auto& eos = std::get<std::unique_ptr<serif::eos::EOSio>>(rm.getResource("eos:helm"));
auto& table = eos->getTable();
auto& helmTable = *std::get<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(table);
serif::eos::helmholtz::EOS helmEos = get_helm_EOS(eos1, helmTable);
serif::eos::helmholtz::HELMEOSOutput helmEos = get_helm_EOS(eos1, helmTable);
const double absErr = 1e-12;
@@ -85,3 +87,25 @@ TEST_F(eosTest, get_helm_EOS) {
EXPECT_NEAR( helmEos.dpe, 0, absErr);
EXPECT_NEAR( helmEos.dsp, 0, absErr);
}
TEST_F(eosTest, eos_using_composition) {
serif::composition::Composition composition;
composition.registerSymbol({"H-1", "He-4", "C-12"}, true);
composition.setMassFraction("H-1", 0.75);
composition.setMassFraction("He-4", 0.23);
composition.setMassFraction("C-12", 0.02);
composition.finalize();
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
auto& EOSio = std::get<std::unique_ptr<serif::eos::EOSio>>(rm.getResource("eos:helm"));
serif::eos::EOS EOS(*EOSio);
serif::eos::EOSInput eosInput;
eosInput.temperature = 1.0e8; // Temperature in K
eosInput.density = 1.0e6; // Density in g/cm^3
eosInput.composition = composition; // Set the composition
serif::eos::EOSOutput eosOutput;
EXPECT_NO_THROW(eosOutput = EOS.get(eosInput));
}