Skip to content

Scroll radial leakage: _radial_leakage_angles raises ValueError on ~2-ULP rounding (phi_min > phi_max) in multilump example #109

Description

@ibell

Summary

_radial_leakage_angles in PDSim/scroll/symm_scroll_geo.pyx raises a ValueError because of a floating-point rounding artifact: it does a strict if phi_min > phi_max: raise check, and for a degenerate (zero-length) radial-leakage overlap the two angles come out mathematically equal but differ by ~2 ULP, so phi_min ends up infinitesimally greater than phi_max.

Observed for the radial-leakage key pair (2001, 1) at theta = 0.0:

phi_max(15.148966328953213) < phi_min(15.148966328953215)   # differ by ~2e-15

This is pure scroll geometry — no CoolProp involvement, version-independent.

Reproduction

examples/scroll_compressor_multilump.py hits it once it gets into the solver. (Note: that example also has a separate default_timer typo that aborts it earlier; fixed in #108. With that fix in place, this geometry error is what stops the run.) The other scroll examples (scroll_compressor.py, _disc, _valves, _w_VI) do not trigger it — it's specific to the multilump example's geometry/parameters.

File "PDSim/scroll/_scroll.pyx", line 41, in radial_leakage_area
File "PDSim/scroll/symm_scroll_geo.pyx", line 405, in radial_leakage_area
File "PDSim/scroll/symm_scroll_geo.pyx", line 515, in _radial_leakage_angles
ValueError: For the keys (2001,1) @theta = 0.0 max < min (error because phi_max(15.148966328953213) < phi_min(15.148966328953215)

Root cause

In _radial_leakage_angles (around line 514):

if phi_min > phi_max:
    raise ValueError('For the keys ('+str(key1)+','+str(key2)+') @theta = '+...)

phi_min / phi_max are built from involute-angle arithmetic (geo.phi_fie - theta - 2*pi*alpha, the overlap() helper, etc.). When the overlap genuinely collapses to zero length, the two expressions are equal in exact arithmetic but round to values a couple of ULP apart, and the strict > comparison treats that as an error rather than a zero-area leakage path.

Suggested fix

Tolerate a negligible difference instead of raising — e.g. only raise when the inversion exceeds a small tolerance, and otherwise clamp to a zero-length (zero-area) overlap:

if phi_min > phi_max:
    if phi_min - phi_max < 1e-10:   # rounding noise on a degenerate overlap
        phi_min = phi_max
    else:
        raise ValueError(...)

(Tolerance value up to the maintainers; the point is to not fail on ~ULP-level noise.) Worth confirming the (2001,1) @ theta=0 overlap is in fact meant to be zero-length here.

Environment

  • PDSim @ master (also present on the coolprop-abi-guard / v8 work, which touches this file)
  • Python 3.9, macOS arm64; reproduced against CoolProp 7.2.1.dev20260610124924 but the code path is CoolProp-independent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions