CoolProp 8.0.0
An open-source fluid property and humid air property database
CoolProp-Tests-AirMelting.cpp
Go to the documentation of this file.
1// Tests for the air (pseudo-pure) melting line (bd CoolProp-r1w7 Tier 3).
2//
3// Air lacked a melting line, so its high-pressure P+{H,S,U} consistency points
4// failed ("Inputs in Brent [...] do not bracket the root"): the HSU_P flash
5// floored its T-search at the EOS triple temperature and probed the cold dense
6// region. The melting line of Lemmon et al. (2000) -- the same paper as air's
7// EOS, ported from REFPROP's AIR.PPF -- is added so the flash floors the search
8// at Tmelt(p). Run explicitly: ./CatchTestRunner "[melting]"
9
10#if defined(ENABLE_CATCH)
11
12# include <catch2/catch_all.hpp>
13
14# include <memory>
15
18
19// Check values pinning the air melting line (Simon form, reproduces REFPROP's
20// Lemmon-2000 curve to <0.02%). T(p) obtained by inverting the fitted curve.
21TEST_CASE("Air melting line check values (Lemmon-2000)", "[melting]") {
22 auto AS = std::shared_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", "Air"));
23 CHECK(AS->melting_line(CoolProp::iT, CoolProp::iP, 1.0e8) == Catch::Approx(75.920).epsilon(1e-4));
24 CHECK(AS->melting_line(CoolProp::iT, CoolProp::iP, 1.0e9) == Catch::Approx(167.875).epsilon(1e-4));
25}
26
27// Regression: a genuine fluid state (T > Tmelt(p)) at p ~ 1 GPa that previously
28// failed the P+{H,S,U} flash now round-trips, because the melting line floors
29// the HSU_P T-search above the cold dense region.
30TEST_CASE("Air high-pressure P+X reliability (was failing)", "[melting]") {
31 const double T = 210.01538461538462; // K (> Tmelt(1.035 GPa) ~ 170 K)
32 const double p = 1035411979.2369467; // Pa
33 auto ref = std::shared_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", "Air"));
34 auto wrk = std::shared_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", "Air"));
35 REQUIRE_NOTHROW(ref->update(CoolProp::PT_INPUTS, p, T));
36 const double h = ref->hmolar(), s = ref->smolar(), u = ref->umolar(), rho = ref->rhomolar();
37
38 SECTION("PH") {
39 REQUIRE_NOTHROW(wrk->update(CoolProp::HmolarP_INPUTS, h, p));
40 CHECK(wrk->T() == Catch::Approx(T).epsilon(1e-5));
41 CHECK(wrk->rhomolar() == Catch::Approx(rho).epsilon(1e-5));
42 }
43 SECTION("PS") {
44 REQUIRE_NOTHROW(wrk->update(CoolProp::PSmolar_INPUTS, p, s));
45 CHECK(wrk->T() == Catch::Approx(T).epsilon(1e-5));
46 }
47 SECTION("PU") {
48 REQUIRE_NOTHROW(wrk->update(CoolProp::PUmolar_INPUTS, p, u));
49 CHECK(wrk->T() == Catch::Approx(T).epsilon(1e-5));
50 }
51}
52
53#endif // ENABLE_CATCH