test(tests/eos): added eos tests
This commit is contained in:
70
tests/eos/eosTest.cpp
Normal file
70
tests/eos/eosTest.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#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;
|
||||
|
||||
EXPECT_DOUBLE_EQ(eos.ye, 0.875);
|
||||
EXPECT_DOUBLE_EQ(eos.etaele, 23.04334823102155);
|
||||
// TODO: Add more tests for more values
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user