You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hydraulic gas_pressure omits the reference-density offset, breaking roundtrips and the pressure join #518
The gas-density interpolation and pressure inverse do not invert one another. The density relation is ρ = ρ0 + p(ρ0−ρgas)/(−pgas), but the inverse uses ρ(−pgas)/(ρ0−ρgas) without subtracting ρ0.
For ρ0=1000, ρgas=1, pgas=−1000 and p=−500, the roundtrip returns 500500/999 (approximately +501 Pa) instead of −500 Pa. The combined pressure function also returns 1000 at density 999 and zero at density 1000: pressure decreases across the join as density increases.
This function is used by the public FixedVolume component. Direct substitution into that component's pressure equation reproduces the same error.
Expected behavior
On the interpolation branch, pressure and density should roundtrip consistently and match the two specified endpoints. The affine inverse is p = (ρ−ρ0)(−pgas)/(ρ0−ρgas). The gas and liquid pressure branches should join at (ρ0, 0). This asks for consistency of the library's own interpolation, not an ideal-gas law or a different cavitation model.
Minimal Reproducible Example 👇
The helper functions are called through their module because they are not exported. A named tuple supplies exactly the material fields they read. Rational inputs make the counterexample exact.
import ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible as H
# Rational inputs make this an exact arithmetic reproduction.
fluid = (ρ=1000//1, β=1000//1, n=1, let_gas=1,
ρ_gas=1//1, p_gas=-1000//1)
p =-500//1
rho = H.gas_density(fluid, p)
println("input pressure = ", p)
println("density = ", rho)
println("roundtrip pressure = ", H.gas_pressure(fluid, rho))
println("full pressure at density 999 = ", H.full_pressure(fluid, 999//1))
println("full pressure at density 1000 = ", H.full_pressure(fluid, 1000//1))
Error & Stacktrace ⚠️
No exception or stacktrace occurs. The observed output is:
input pressure = -500//1
density = 1001//2
roundtrip pressure = 500500//999
full pressure at density 999 = 1000//1
full pressure at density 1000 = 0//1
Environment (please complete the following information):
Julia 1.11.9. Relevant installed-package entries, captured with using Pkg; Pkg.status(["ModelingToolkit", "ModelingToolkitStandardLibrary", "Symbolics"]):
Activity
ChrisRackauckas-Claude commentedon Oct 9, 2026
Thanks for the report. A fix by @jitendravjh is open in #520, which makes
gas_pressurethe exact inverse ofgas_density. It is now in review.🤖 Posted by an AI agent (Claude Code, model claude-opus-5-5[1m]) on behalf of Chris Rackauckas: https://claude.ai/code/session_01H4fXBChQshAwfpLMCpEvAX