Merge branch 'main' into feature/pointwisePolytrope
This commit is contained in:
@@ -11,7 +11,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, config_dep],
|
||||
dependencies: [gtest_dep, config_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/config/public'),
|
||||
link_with: libconst, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
|
||||
@@ -11,7 +11,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, const_dep],
|
||||
dependencies: [gtest_dep, const_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/const/public'),
|
||||
link_with: libconst, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
|
||||
@@ -13,7 +13,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: gtest_dep,
|
||||
dependencies: [gtest_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/dobj/public'),
|
||||
link_with: libdobj, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
|
||||
85
tests/eos/eosTest.cpp
Normal file
85
tests/eos/eosTest.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include "helm.h"
|
||||
|
||||
/**
|
||||
* @file constTest.cpp
|
||||
* @brief Unit tests for the const class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test suite for the const class.
|
||||
*/
|
||||
class eosTest : public ::testing::Test {};
|
||||
|
||||
std::string HELM_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/assets/eos/helm_table.dat";
|
||||
/**
|
||||
* @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);
|
||||
// Capture the << operator output as a string
|
||||
std::stringstream ss;
|
||||
ss << table;
|
||||
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");
|
||||
}
|
||||
|
||||
TEST_F(eosTest, get_helm_EOS) {
|
||||
using namespace helmholtz;
|
||||
|
||||
const int nel=3;
|
||||
double xmass[nel], aion[nel], zion[nel];
|
||||
EOSInput 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;
|
||||
xmass[2] = 0.02; aion[2] = 12.0; zion[2] = 6.0;
|
||||
|
||||
eos1.T = 1.0e8;
|
||||
eos1.rho = 1.0e6;
|
||||
|
||||
double asum = 0.0;
|
||||
double zsum = 0.0;
|
||||
for (int i=0; i<nel; i++) {
|
||||
asum += xmass[i]/aion[i];
|
||||
zsum += xmass[i]*zion[i]/aion[i];
|
||||
}
|
||||
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;
|
||||
|
||||
//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);
|
||||
}
|
||||
23
tests/eos/meson.build
Normal file
23
tests/eos/meson.build
Normal file
@@ -0,0 +1,23 @@
|
||||
# Test files for const
|
||||
test_sources = [
|
||||
'eosTest.cpp',
|
||||
]
|
||||
|
||||
foreach test_file : test_sources
|
||||
exe_name = test_file.split('.')[0]
|
||||
message('Building test: ' + exe_name)
|
||||
|
||||
# Create an executable target for each test
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, eos_dep, gtest_main],
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
# Add the executable as a test
|
||||
test(
|
||||
exe_name,
|
||||
test_exe,
|
||||
env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()])
|
||||
endforeach
|
||||
@@ -11,7 +11,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, mfem_dep],
|
||||
dependencies: [gtest_dep, mfem_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/meshIO/public'),
|
||||
link_with: libmeshIO, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Google Test dependency
|
||||
gtest_dep = dependency('gtest', main: true, required : true)
|
||||
gtest_main = dependency('gtest_main', required: true)
|
||||
gtest_nomain_dep = dependency('gtest', main: false, required : true)
|
||||
|
||||
# Subdirectories for unit and integration tests
|
||||
@@ -8,8 +9,9 @@ subdir('const')
|
||||
subdir('opatIO')
|
||||
subdir('meshIO')
|
||||
subdir('probe')
|
||||
subdir('poly')
|
||||
subdir('config')
|
||||
subdir('eos')
|
||||
subdir('poly')
|
||||
|
||||
# Subdirectories for sandbox tests
|
||||
subdir('dobj_sandbox')
|
||||
|
||||
@@ -13,7 +13,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, picosha2_dep],
|
||||
dependencies: [gtest_dep, picosha2_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/opatIO/public'),
|
||||
link_with: libopatIO, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
|
||||
@@ -11,7 +11,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, probe_dep, mfem_dep, quill_dep],
|
||||
dependencies: [gtest_dep, probe_dep, mfem_dep, quill_dep, gtest_main],
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user