Skip to content

fix(INCOMP): throw a clean error for molar properties (#1908)#2854

Merged
ibell merged 4 commits into
masterfrom
ib/fix-1908-incomp-molar-throws
May 4, 2026
Merged

fix(INCOMP): throw a clean error for molar properties (#1908)#2854
ibell merged 4 commits into
masterfrom
ib/fix-1908-incomp-molar-throws

Conversation

@ibell
Copy link
Copy Markdown
Contributor

@ibell ibell commented May 3, 2026

Summary

Fixes #1908.

The reproducer:

CP.PropsSI('Dmolar', 'T', 298.15, 'P', 101325, 'INCOMP::AEG[0.1]')
# -> ValueError: PropsSI failed ungracefully :: inputs were ...

raised the unhelpful "ungracefully" message from the Python wrapper because the underlying _PropsSI call returned -inf cleanly and set no errstring.

Root cause

IncompressibleBackend never overrode calc_rhomolar (or the other molar getters), so they fell through to AbstractState's default that returns the cached _rhomolar member, which clear() initialises to -_HUGE. The call returned -inf cleanly and the "failed ungracefully" path was reached because no exception was thrown.

Fix

Override the molar getters in IncompressibleBackend to throw NotImplementedError naming the mass-basis equivalent (Dmass, Hmass, etc.). PropsSI catches the exception and propagates a useful errstring.

Dmolar / rhomolar is not defined for the INCOMP backend; use Dmass / rhomass instead.

Test plan

  • New [1908] Catch2 regression test: original repro now returns a non-finite value AND a non-empty errstring containing "INCOMP"; corresponding Dmass call still works
  • Test fails on master, passes with the fix
  • All existing [PropsSI] tests pass

🤖 Generated with Claude Code

ibell and others added 2 commits May 3, 2026 10:59
PropsSI('Dmolar','T',298.15,'P',101325,'INCOMP::AEG[0.1]') returned
-infinity and the Python wrapper surfaced the unhelpful "PropsSI
failed ungracefully" because the underlying call set no errstring.

Root cause: IncompressibleBackend never overrode calc_rhomolar (or
the other molar getters), so they fell through to AbstractState's
default that returns the cached _rhomolar member, which clear()
initializes to -_HUGE. The call returned -inf cleanly and the
"failed ungracefully" path was reached because no exception was
thrown to populate errstring.

Override calc_molar_mass / calc_rhomolar / calc_hmolar / calc_smolar /
calc_umolar / calc_cpmolar / calc_cvmolar in IncompressibleBackend to
throw a NotImplementedError naming the mass-basis equivalent. PropsSI
catches the exception and propagates a useful errstring.

Add a Catch2 regression test that the original repro now produces a
non-finite return value AND a non-empty errstring containing
"INCOMP", and that the corresponding mass-basis call still works.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ibell ibell force-pushed the ib/fix-1908-incomp-molar-throws branch from 4b6f4e2 to c445679 Compare May 3, 2026 14:59
@ibell ibell merged commit fd1e7b8 into master May 4, 2026
62 checks passed
@ibell ibell deleted the ib/fix-1908-incomp-molar-throws branch May 13, 2026 00:40
@ibell ibell added this to the v8.0.0 milestone May 27, 2026
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.

Ungraceful CoolProp fail

1 participant