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:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,16 @@ test_sources = [
|
||||
'eosTest.cpp',
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
gtest_dep,
|
||||
eos_dep,
|
||||
gtest_main,
|
||||
resourceManager_dep,
|
||||
config_dep,
|
||||
composition_dep,
|
||||
]
|
||||
|
||||
|
||||
foreach test_file : test_sources
|
||||
exe_name = test_file.split('.')[0]
|
||||
message('Building test: ' + exe_name)
|
||||
@@ -11,7 +21,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, eos_dep, gtest_main, resourceManager_dep, config_dep],
|
||||
dependencies: dependencies,
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_F(resourceManagerTest, getResource) {
|
||||
const serif::resource::types::Resource &r = rm.getResource(name);
|
||||
// BREAKPOINT();
|
||||
const auto &eos = std::get<std::unique_ptr<serif::eos::EOSio>>(r);
|
||||
EXPECT_EQ("helm", eos->getFormat());
|
||||
EXPECT_EQ("Helmholtz", eos->getFormatName());
|
||||
serif::eos::EOSTable &table = eos->getTable();
|
||||
|
||||
// -- Extract the Helm table from the EOSTable
|
||||
|
||||
Reference in New Issue
Block a user