Hydraulic gas_pressure omits the reference-density offset, breaking roundtrips and the pressure join
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in src/Hydraulic/IsothermalCompressible/utils.jl at the gas-density, gas-pressure, and full-pressure definitions, then inspect their use in components.jl's FixedVolume component. Run the exact Julia reproduction from the issue; done means the interpolation roundtrips, both pressure branches meet at (ρ0, 0), and the specified endpoint behavior is preserved.
Written by the indexing model from the issue text.
Description
Describe the bug 🐞
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"]):
⌃ [961ee093] ModelingToolkit v11.20.0
⌅ [16a59e39] ModelingToolkitStandardLibrary v2.29.4
⌃ [0c5d862f] Symbolics v7.18.1
The version markers indicate that newer releases are available; they do not indicate that those releases were executed in this reproduction.
Additional context
This was found using our physics prover model checker.
- Dominant language
- Julia
- Stars
- 171
- Forks
- 51
- Avg merge
- 7d 12h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SciML/ModelingToolkitStandardLibrary.jl
-
EddyCurrent: rho, l and A have no effect, R = rho*l/A is evaluated once at constructionPossibly taken @ChrisRackauckas-Claude claimed this 23 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SciML/ModelingToolkitStandardLibrary.jl#529 · 1 comment ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
question
Difficulty 4/5 3-5 days Newbie friendliness 28/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
NPN/PNP: emission coefficients NF/NR are used in the diffusion capacitances but not in the transport currentsPossibly taken @ChrisRackauckas-Claude claimed this 27 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
SciML/ModelingToolkitStandardLibrary.jl#527 · 2 comments ·
All issues in SciML/ModelingToolkitStandardLibrary.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaDiff/TaylorSeries.jl#445 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
SciML/PETScDiffEq.jl#362 ·
Maintainers usually reply within 1 day
-
🕷️ bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CliMA/ClimaSeaIce.jl#203 ·
Maintainers usually reply within 3 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
JuliaPhysics/BeamletOptics.jl#221 ·
Maintainers usually reply within 1 day
-
release preparation spack
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day