Short Answer
Property calls that work reliably over most of a fluid’s range can fail abruptly around the saturation curve. A user of CoolProp — the open-source thermophysical property library — may find that PropsSI(‘T’,’P’,136730,’H’,268000,’R1233zd(E)’) returns inf while the same call with an enthalpy of 293,000 J/kg succeeds, or that a pressure recovered from density and internal energy silently fails inside the two-phase dome. These are not signs of a broken installation. They belong to a recognized class of failure: the iterative flash calculations at the heart of every property call are least well behaved precisely at bubble points, dew points, and within the two-phase region. This article explains why those failures occur, then gives a practical debugging sequence built on phase checks, quality-based inputs, imposed phases, and backend choice.
What ‘Near a Phase Boundary’ Means
A phase boundary here means the saturation curve: the set of states where liquid and vapor coexist in equilibrium. The bubble point is the saturated-liquid end at a given pressure (vapor quality Q = 0), and the dew point is the saturated-vapor end (Q = 1). Between them spreads the two-phase region — often drawn as the vapor dome on pressure–enthalpy or temperature–entropy diagrams — in which every state is a mixture whose composition is set by the vapor quality, the mass fraction that is vapor. Inside this region, temperature and pressure are locked together: specifying one fixes the other, while enthalpy, entropy, and density vary with quality according to a lever rule, a weighted average between the saturated-liquid and saturated-vapor values.
CoolProp’s high-level interface centers on the PropsSI function, which takes exactly two input properties (in SI units), a fluid name, and returns the requested output [1]. Given inputs such as pressure and enthalpy, the library must locate the state: first decide which phase the inputs describe, then solve for temperature, density, and the remaining properties. CoolProp offers an optional phase imposition precisely because this phase determination is not always automatic [1].
A Documented Example: R1233zd(E) Just Above the Bubble Point
GitHub issue #2142 shows the pattern in a minimal example for the refrigerant R1233zd(E) at a pressure of 136,730 Pa [2]. A series of calls returning the temperature from pressure and enthalpy produced 296.914485 K at 260,000 J/kg, then 299.609517 K at 263,277.27 J/kg — essentially the bubble-point enthalpy — followed by inf for 263,277.35, 268,000, and 275,000 J/kg, and then 299.609875 K again for 293,000 and 300,000 J/kg. The expected answer for the failing cases was 299.609875 K, the saturation temperature at that pressure: the affected enthalpies lie just inside the two-phase region, a narrow band above the bubble point where the flash failed instead of returning the two-phase temperature. The issue, reported in July 2022, was closed after receiving maintainer attention — one reason to keep the library current.
Why Flash Calculations Struggle at the Edge of the Dome
Every two-input flash is a root-finding problem. For pressure–enthalpy inputs, CoolProp guesses a temperature, evaluates the mixture enthalpy — within the dome, a quality-weighted combination of saturated liquid and vapor values — and iterates until the residual is small. Near the boundary this iteration is fragile for several reasons:
- Flat residuals inside the dome. Within the two-phase region, pressure depends only on temperature and is independent of quality. A solver tuned for smooth single-phase responses can overshoot, oscillate, or stall against a boundary state.
- Phase misdetection. Inputs a fraction of a joule per kilogram from the dome can be classified on either side. If a slightly two-phase state is treated as single-phase liquid or vapor, the single-phase equation-of-state iteration may have no valid solution and diverge, surfacing as an exception or a non-finite result.
- Solver step limits. Iterative solvers carry finite iteration budgets. Issue #2157 documents inverse flashes — pressure computed from density and internal energy — inside the two-phase region for R1233zd(E) and R32, where the secant residual function returned an invalid number or the Brent method reached its maximum of 20 steps for certain bands of vapor quality [4].
- Backend limitations. Behavior differs by backend. The IF97 backend for water and steam is prized for speed, but an April 2023 discussion records exceptions thrown by its flash routine for certain two-phase states, along with problems calling cp, viscosity, and thermal conductivity — quantities a user had to implement separately because derivatives were not yet available in that backend [3]. IF97 also ships documented limitations of its own.
The density–internal-energy case deserves emphasis because it is systematic rather than random. Scanning grids of 1,000 subdivisions in pressure (0.1 to 0.8 times critical pressure) and quality for both fluids revealed failures concentrated near phase boundaries, occurring irregularly at those points and growing at higher pressures [4]. As of the August 2022 report the issue remained open, so near-boundary inverse flashes from density and internal energy were a live weak point rather than a resolved bug.
A Practical Debugging Sequence
- Check units first. PropsSI speaks SI exclusively: pressure in Pa, temperature in K, enthalpy in J/kg, density in kg/m³, viscosity in Pa·s, conductivity in W/(m·K). Pressures entered in bar or enthalpies in kJ/kg push states far from where you intend — sometimes onto the dome itself.
- Bracket your state with saturation calls. At your pressure, evaluate the saturated-liquid and saturated-vapor values of the same property — for example, the enthalpies at quality 0 and quality 1. If your input enthalpy falls between them, the state is two-phase. The PhaseSI function, also part of the high-level interface, reports the phase CoolProp assigns to a state [1].
- If the state is two-phase, use quality-based inputs. Pair pressure with quality (or temperature with quality) directly; that pair determines the state without any inversion. Then obtain remaining properties with the same quality-aware approach rather than inverting pressure–enthalpy or density–energy pairs near the boundary.
- If the state is single-phase but close to the dome, impose the phase. The high-level interface supports optional phase imposition, which stops phase guessing from flipping your state onto the wrong branch [1]. The low-level AbstractState interface exposes equivalent controls for code that needs finer management.
- Probe sensitivity. Nudge an input by a tiny amount — a few J/kg of enthalpy, say — and rerun. If success flips to failure over such a small range, you are sitting on a boundary, and the remedy is input framing (steps 2–4) rather than different fluid data.
- Cross-check with another backend. The default Helmholtz-equation-of-state backend, REFPROP where a license permits, and tabular interpolation backends (which trade some accuracy for speed) can each converge where another stalls. A mismatch between backends near a boundary is itself diagnostic information.
- Update CoolProp and search the issue tracker. The R1233zd(E) bubble-point failures of issue #2142 were addressed after a minimal reproducer was posted [2]. Current documentation (version 8.0.0) also describes superancillaries aimed at robust, fast flashes from enthalpy or entropy inputs [1], so a newer release may simply be the fix for your case.
- Handle failures defensively. Wrap property calls in error handling, treat inf and NaN results as failures equal to exceptions, and log the exact inputs. Silent non-finite values propagate quickly into downstream engineering models.
Common Mistakes and Misconceptions
- Assuming the fluid data are broken. Failures cluster around the dome because the underlying mathematics is difficult there — not because the fluid file is corrupt. The R1233zd(E) failures appeared only in a narrow enthalpy band just above the bubble point [2].
- Treating an exception as proof the inputs are invalid. Inside the two-phase region, pressure–enthalpy pairs do define valid states: temperature equals the saturation temperature, and enthalpy fixes the quality. Solver robustness, not state validity, is usually the limiter [4].
- Expecting uniform behavior across backends. IF97’s speed comes with documented limits and reported two-phase exceptions [3]; REFPROP requires a license and its own fluid files. Near boundaries, backend choice is a first-order decision, not an afterthought.
- Reporting bugs without reducible examples. Issues that move fastest, like #2142, provide a minimal snippet with exact inputs, fluid, backend, and build details [2].
Known Limitations and Where the Work Stands
Some of this area remains unfinished. The inverse flash from density and internal energy inside the two-phase region (issue #2157) was still open when reported in August 2022, with failure bands widening at elevated pressures [4]. The IF97 backend’s two-phase gaps were under discussion, and unresolved, in April 2023 [3]. Where a failure persists in your own workflow, the reliable strategies are quality-based inputs for known two-phase states, imposed phases for known single-phase states, backend cross-checks, and staying on a recent release.
Practical Takeaways
Near-boundary property errors in CoolProp follow a recognizable anatomy: inputs within a whisker of the saturation curve, a solver or phase classifier that hesitates, and an exception or a non-finite result. Diagnose by bracketing the state with saturation values at fixed pressure — if the input lies between the saturated-liquid and saturated-vapor values, treat the state as two-phase and drive it with quality. Once inputs are framed correctly, most calls behave; whatever remains as a genuine limitation rather than user error belongs in the issue tracker, submitted with a minimal reproducer.
FAQ
Why does a CoolProp call return inf instead of raising an error?
How a failure surfaces depends on the language binding and code path: the C++ example in issue #2142 returned inf for near-bubble-point inputs, while Python typically raises an exception. Both indicate the same underlying flash failure and should be handled as errors.
How can I tell whether my state is inside the two-phase region?
At fixed pressure, evaluate the saturated-liquid and saturated-vapor values of your input property (for enthalpy, quality 0 and quality 1). If your input lies between them, the state is two-phase. The PhaseSI function also reports the phase CoolProp assigns to a state.
Which backend should I use near a phase boundary?
The default Helmholtz-equation-of-state backend is the most comprehensive; REFPROP is a strong cross-check where a license is available; IF97 is fast for water and steam but has documented limitations and reported two-phase exceptions; tabular backends trade some accuracy for speed. Cross-checking two backends is often the fastest way to isolate a boundary problem.
Are these near-boundary failures fixed?
It varies by issue. The R1233zd(E) bubble-point failures of issue #2142 were closed after being reported in July 2022, while the density-and-internal-energy inverse flash failures of issue #2157 remained open as of the August 2022 report. Check the CoolProp issue tracker for your specific fluid and input pair.
Leave a Reply