25#if defined(ENABLE_CATCH)
26# include <catch2/catch_all.hpp>
33TEST_CASE(
"Air critical-region round-trip consistency (pseudo-pure)",
"[air_critical][HSU_D]") {
36 auto fwd = std::shared_ptr<AbstractState>(AbstractState::factory(
"HEOS",
"Air"));
37 auto rt = std::shared_ptr<AbstractState>(AbstractState::factory(
"HEOS",
"Air"));
39 const double Tc = fwd->T_critical();
40 const double pc = fwd->p_critical();
45 const double tol = 2e-4;
47 const int NT = 60, NP = 40;
48 std::size_t single_phase = 0, two_phase_skipped = 0;
50 for (
int i = 0; i < NT; ++i) {
51 const double T = (0.96 + (2.0 - 0.96) * i / (NT - 1)) * Tc;
52 for (
int j = 0; j < NP; ++j) {
53 const double p = (0.5 + (5.0 - 0.5) * j / (NP - 1)) * pc;
64 const double rho = fwd->rhomolar();
65 const double h = fwd->hmolar();
66 const double s = fwd->smolar();
67 const double u = fwd->umolar();
80 const std::array<Case, 7> cases = {{
89 for (
const auto& c : cases) {
90 CAPTURE(c.name,
T, p,
T / Tc, p / pc, rho);
93 rt->update(c.pair, c.v1, c.v2);
94 }
catch (
const std::exception& e) {
96 FAIL_CHECK(
"back-flash threw: " << e.what());
101 CHECK(rt->T() == Catch::Approx(
T).epsilon(tol));
102 CHECK(rt->rhomolar() == Catch::Approx(rho).epsilon(tol));
107 std::printf(
"[air_critical] Air: %zu single-phase points round-tripped (x7 back-flashes), %zu two-phase PT points skipped\n", single_phase,
110 CHECK(single_phase > 2000);