Skip to content

CoolPlot 1.7.0: CoolProp 8.1, whole quality lines of wide-glide blends such as R436A, Fluid.phase - #56

Merged
jowr merged 8 commits into
mainfrom
chp/coolplot-coolprop-v8-1-wemgio
Nov 23, 2026
Merged

jowr merged 8 commits into
mainfrom
chp/coolplot-coolprop-v8-1-wemgio

Conversation

@jowr

@jowr jowr commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Moves CoolPlot's CoolProp reference to 8.1.0 and adds a p-h chart of R436A, a blend with a wide glide, to the gallery. On 8.1 that chart exposed a CoolProp problem, which this PR works around and which is reported upstream as CoolProp/CoolProp#3585 and CoolProp/CoolProp#3586.

CoolProp 8.1

  • CI (tests, coolplot-core, typing), the docs build and the release check use 8.1.0. One test job keeps 8.0.0, still the minimum (coolprop>=8.0 is unchanged).
  • 8.1.0 is the first release with CoolProp.CoolProp.Plot, so CoolPlot computes fluid lines there by default, and the 41 tests of the port run in CI for the first time.
  • coolplot.thermo.native looks up CoolProp.CoolProp.Plot with getattr: the 8.1 type stubs declare it, the 8.0 stubs do not, and mypy failed with 8.1.

R436A on 8.1

The lines of quality 0.3 to 0.9 of R436A stopped between 129 and 146 K with their evaluation budget used up, and the example took 15 s. Cause: where CoolProp's two-phase QT solver fails, CoolProp falls back to the bubble/dew solver and returns its state, which misses the mass balance (R436A: 2.8 % in pressure at 140 K). On 8.1.0 that happens for 32 of the 113 predefined blends (CoolProp/CoolProp#3585). The line then zig-zags between the two solutions, and the stepping shrinks its step to nothing.

  • Mass balance check (_is_saturation_state in thermo/isolines.py): a two-phase state of a mixture on a quality line is drawn only if max |(1 - Q) x + Q y - z| <= 1e-6, calibrated on all predefined blends. Cost: a few nearly right states are refused too (5 gaps on the quality 0.1 line of Ekofisk).
  • Routing (native.port_draws): lines of intermediate quality of mixtures are computed in Python, since CoolProp's port lacks the check (CoolProp.Plot: lines of constant quality of R436A stop with the evaluation budget used up CoolProp#3586).
  • Not fixed here: the stepping's next_step has no floor at MIN_STEP. A floor in Python alone broke the point-for-point agreement with CoolProp's port (test_the_port_agrees_with_the_python_reference), so it has to land in both together. test_a_line_that_jumps_between_two_roots_reaches_its_end is a strict xfail until then. Listed under "Known issues" in the changelog.

Port vs Python: compared to 1e-7 (f8755fb)

With the port tests running in CI for the first time, two failed on every GitHub runner while passing locally: one point of the R32/R125 isenthalp in a T-s chart differed by 3.1e-9, one point of an R290 isentrope in the chart scene by 1.5e-8, against 1e-9. The Python values are bit for bit the same on the runners and locally; the port's differ. The isenthalp point amplifies the last bits of CoolProp's arithmetic: switching off glibc's FMA variants of the maths functions moves it by exactly 3.1e-9. Why the two sides take different variants on the runners is not known (not the runners' glibc 2.43: the tests pass in an Ubuntu 26.04 container).

The value comparisons between the port and Python now use PORT_RTOL = 1e-7 (tests/test_native.py). Point counts, gaps and diagnostics are still compared exactly, scenes composed from the same curves still to 1e-9, and a port that is off by 1e-6 fails all eleven cases of the agreement test.

Example

examples/wide_glide_blend.py: a heat pump with R436A evaporating at -5 deg C (dew) and condensing at 45 deg C (bubble), glide 7.8 K and 6.3 K. It runs in the docs gallery (built locally with -W, 1.4 s) and is linked from the blends how-to. Its test fails on the old code with 8.1.

Release

Release 1.7.0 (2b4276f): VERSION is 1.7.0, and the changelog section [1.7.0] includes Fluid.phase (#53) from main, an API addition, so a minor release. The upgrade guide has a section from 1.6 to 1.7.

Testing

  • CI is green on f8755fb: Python 3.11 to 3.15 with CoolProp 8.1.0, 3.11 with 8.0.0, coolplot-core, typing, docs and build.
  • Locally, before the merge of main: CoolProp 8.0.0 628 passed, 8.1.0 670 passed, through coolplot-core (COOLPLOT_NATIVE=1, -W error::CoreFallbackWarning) 707 passed; each with the one expected xfail.
  • Each new safeguard was checked by reverting it: the named tests fail.
  • An independent review found no blocking defects; its corrections to numbers and claims are in b137fef.

Summary by CodeRabbit

  • New Features
    • Added an example heat-pump diagram for the R436A wide-glide blend.
  • Bug Fixes
    • Improved mixture quality lines by omitting states that do not correctly represent the blend’s composition. This may result in fewer plotted points or a higher line starting temperature.
    • Improved compatibility with CoolProp’s numerical plotting port while retaining Python calculations for intermediate-quality mixture lines.
  • Documentation
    • Updated installation and upgrade guidance for CoolProp 8.1, while retaining support for version 8.0.
    • Added notes on mixture quality-line behavior and the new blend example.

jowr and others added 6 commits November 23, 2026 10:22
CoolProp 8.1.0 is the first release with CoolProp.CoolProp.Plot, so
CoolPlot now computes fluid lines there by default; CI tests 8.1.0
throughout and keeps one job on 8.0.0, still the minimum.

On 8.1 the lines of quality 0.3 to 0.9 of R436A stopped at 140 K with
their evaluation budget used up. CoolProp's quality flash alternates
between the right root and a wrong one (its phases miss the mixture by
1e-2 in mole fraction, 3 % in pressure), and the stepping shrank its
step below MIN_STEP at every turn until the temperature stopped moving.

- stepping: next_step keeps MIN_STEP of the range as its floor
- isolines: a two-phase state of a mixture must satisfy
  (1 - Q) x + Q y = z to 1e-6, calibrated on the 113 predefined blends
- native: lines of intermediate quality of a mixture stay in Python,
  since the port in 8.1 has neither safeguard (port_draws)
- example wide_glide_blend.py: an R436A heat pump in a p-h chart

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
The MIN_STEP floor in next_step changed the points of ordinary lines, so
the Python numerics no longer matched CoolProp's port of the stepping
(test_the_port_agrees_with_the_python_reference, h and rho lines). It
is taken out again: R436A draws whole lines through the mass balance
check and the routing alone. The stepping test is expected to fail until
both copies get the floor together.

native.py finds CoolProp.CoolProp.Plot with getattr: the type stubs of
CoolProp 8.1 declare it, those of 8.0 do not, and mypy has to pass with
both.

Release 1.6.1: version, changelog and a section in the upgrade guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
From the review of the 1.6.1 changes:
- The check also refuses some nearly right states: Ekofisk's line of
  quality 0.1 gets five gaps between 6.6 and 6.8 MPa. The comment, the
  changelog and the upgrade guide say so, and why a tolerance relative
  to |x - y| would not spare them.
- The changelog gives the measured cost of the stall: the lines stopped
  between 129 and 146 K, the example took 15 s instead of about 1.3 s.
- The calibration used 39 temperatures, not 40.
- The branding guide shows CoolPlot 1.6.1.
- Tests: a state that misses by 1e-5 is refused (a tolerance of 1e-4
  passed before), and the R436A lines end at the top of the envelope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
…e mass balance

The wrong states on lines of constant quality come from CoolProp's
fallback: where newton_raphson_twophase fails, the QT flash answers with
the bubble/dew solver, which has no mass balance (CoolProp#3585). The
code comments, the changelog, the blends guide and the example said the
flash converged on a wrong root; they now say what happens and link the
issue. The routing to Python and the expected failure of the stepping
test point at CoolProp#3586, which asks for the same check and the step
floor in CoolProp's port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CoolPlot 1.6.1 adds mixture saturation-state checks, routes intermediate-quality mixture lines through Python numerics, and adds an R436A heat-pump example. CI, tests, and documentation update CoolProp version guidance while retaining support for CoolProp 8.0.

Changes: Mixture lines and release

Layer / File(s) Summary
Mixture saturation validation
src/coolplot/thermo/isolines.py, tests/test_numerics.py, CHANGELOG.md, docs/how_to/blends.md, docs/upgrade.md
Mixture saturation states are rejected when phase compositions do not reproduce the overall composition within 1e-6. Tests cover invalid states, R436A quality lines, and a strict expected-failure stepping case. The documentation describes the validation and its effects on mixture quality lines.
Native-port routing
src/coolplot/thermo/native.py, src/coolplot/thermo/provider.py, tests/test_native*.py, docs/explanation/numerics.md, CHANGELOG.md
port_draws excludes intermediate-quality mixture lines from the native port. Other eligible lines can use the port; declined lines continue through Python numerics. Tests check routing and compare results using PORT_RTOL.
R436A wide-glide example
examples/wide_glide_blend.py, tests/test_examples.py, docs/how_to/blends.md, CHANGELOG.md
The example calculates evaporator and condenser conditions, configures a heat-pump diagram, and saves R436A_ph.svg. Tests check the printed conditions, SVG size, and both execution paths.
Release and CoolProp compatibility
.github/workflows/*, src/coolplot/__version__.py, docs/requirements.txt, docs/getting_started.md, docs/how_to/branding.md, CHANGELOG.md
The package version changes to 1.6.1. CI and documentation use CoolProp 8.1.0 as the recommended version and retain CoolProp 8.0 support.
Merge Risk: Minimal · up to f8755

This release adds a mass-balance check for mixture quality lines, keeps intermediate-quality mixture lines on Python numerics, and adds an R436A example. No merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title names three changes that appear in the changeset: the CoolProp 8.1 update (CI, docs, and requirements pin 8.1.0), whole quality lines for wide-glide blends such as R436A (mass-balance check,… Update the title to match the changeset. Use version 1.6.1 or confirm the intended release version. Remove Fluid.phase unless the diff includes that change. A title such as "CoolPlot 1.6.1: CoolProp 8.1 support and whole quality lines for w…
Passed Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names three changes that appear in the changeset: the CoolProp 8.1 update (CI, docs, and requirements pin 8.1.0), whole quality lines for wide-glide blends such as R436A (mass-balance check, Python routing for intermediate-quality mixture lines, and the new example), and Fluid.phase. The changeset does not show a Fluid.phase change in the summarized files, and the version is 1.6.1 in the release metadata, not 1.7.0. The title therefore conflicts with the summarized changes, and the PR objectives say the release details are unsettled. The title is partially related: it covers real parts of the change but overstates the version and includes an item not present in the summaries.

Resolution

Update the title to match the changeset. Use version 1.6.1 or confirm the intended release version. Remove Fluid.phase unless the diff includes that change. A title such as "CoolPlot 1.6.1: CoolProp 8.1 support and whole quality lines for wide-glide blends such as R436A" matches the summaries.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each phase with care,
Then bounds where balanced blends meet air.
A glide draws curves from dew to snow,
The heat-pump diagram starts to glow.
One version hops; the lines now flow.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6ca35db-4b35-4813-bd76-48e1bfd4c634
Commits

Reviewing files that changed from the base of the PR and between aef948e and f8755fb.

Files selected for processing: 18

  • .github/workflows/release.yml
  • .github/workflows/tests.yml
  • CHANGELOG.md
  • docs/explanation/numerics.md
  • docs/getting_started.md
  • docs/how_to/blends.md
  • docs/how_to/branding.md
  • docs/requirements.txt
  • docs/upgrade.md
  • examples/wide_glide_blend.py
  • src/coolplot/__version__.py
  • src/coolplot/thermo/isolines.py
  • src/coolplot/thermo/native.py
  • src/coolplot/thermo/provider.py
  • tests/test_examples.py
  • tests/test_native.py
  • tests/test_native_core.py
  • tests/test_numerics.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

jowr and others added 2 commits November 23, 2026 20:05
With CoolProp 8.1.0, CI runs the tests of CoolProp's port for the first
time, and two failed on every GitHub runner while passing locally:
point 12 of the R32/R125 isenthalp of 300 kJ/kg in a T-s chart differs
by 3.1e-9, a point of an R290 isentrope in the chart scene by 1.5e-8.
The Python values are bit for bit the same on the runners and here; the
port's differ. The isenthalp point amplifies the last bits of CoolProp's
arithmetic: with glibc's FMA variants of the maths functions switched
off it moves by exactly that 3.1e-9, here on both sides alike. Why the
two sides take different variants on the runners is not known.

The value comparisons between the port and Python use PORT_RTOL = 1e-7.
Point counts, gaps and diagnostics are still compared exactly, scenes
composed from the same curves still to 1e-9, and a port that is off by
1e-6 fails all eleven cases of the agreement test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
Fluid.phase (#53) is an addition to the public API, so the release is a
minor one. Its changelog entry moves from Unreleased into 1.7.0, next to
the new example; the upgrade guide gets a section from 1.6 to 1.7, and
the branding guide shows CoolPlot 1.7.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bsHH8feNGnWqjY7RbruVh
@jowr jowr changed the title CoolProp 8.1: test with it, and draw whole quality lines of wide-glide blends such as R436A CoolPlot 1.7.0: CoolProp 8.1, whole quality lines of wide-glide blends such as R436A, Fluid.phase Nov 23, 2026
@jowr
jowr merged commit 056322f into main Nov 23, 2026
11 checks passed
@jowr
jowr deleted the chp/coolplot-coolprop-v8-1-wemgio branch November 23, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant