Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahm-LANL committed Dec 2, 2024
1 parent 6b2c05c commit 2b7d0b5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_eos_ideal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <test/eos_unit_test_helpers.hpp>

using singularity::IdealGas;
using singularity::MeanAtomicProperties;
using EOS = singularity::Variant<IdealGas>;

SCENARIO("Ideal gas entropy", "[IdealGas][Entropy][GibbsFreeEnergy]") {
Expand Down Expand Up @@ -80,6 +81,40 @@ SCENARIO("Ideal gas entropy", "[IdealGas][Entropy][GibbsFreeEnergy]") {
}
}

SCENARIO("Ideal gas mean atomic properties", "[IdealGas][MeanAtomicMass][MeanAtomicNumber]") {
constexpr Real Cv = 5.0;
constexpr Real gm1 = 0.4;
constexpr Real Abar = 4.0; // Helium
constexpr Real Zbar = 2.0;
const MeanAtomicProperties azbar(Abar, Zbar);
GIVEN("An ideal gas initialized with mean atomic poroperties") {
EOS host_eos = IdealGas(gm1, Cv, azbar);
WHEN("We evaluate it on host") {
Real Ab_eval = host_eos.MeanAtomicMass();
Real Zb_eval = host_eos.MeanAtomicNumber();
THEN("We get the right answer") {
REQUIRE( isClose(Ab_eval, Abar, 1e-12) );
REQUIRE( isClose(Zb_eval, Zbar, 1e-12) );
}
}
WHEN("We evaluate it on device, using a loop") {
constexpr int N = 100;
auto device_eos = host_eos.GetOnDevice();
int nwrong = 0;
portableReduce("Check mean atomic number", 0, N, PORTABLE_LAMBDA(const int i, int &nw) {
double rho = i;
double T = 100.0*i;
double Ab_eval = device_eos.MeanAtomicMassFromDensityTemperature(rho, T);
double Zb_eval = device_eos.MeanAtomicNumberFromDensityTemperature(rho, T);
nw += !(isClose(Ab_eval, Abar, 1e-12)) + !(isClose(Zb_eval, Zbar, 1e-12));
}, nwrong);
REQUIRE(nwrong == 0);
device_eos.Finalize();
}
host_eos.Finalize();
}
}

// A non-standard pattern where we do a reduction
class CheckPofRE {
public:
Expand Down

0 comments on commit 2b7d0b5

Please sign in to comment.