summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2019-08-07 11:12:06 -0700
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2019-08-08 09:07:48 +0200
commita8b1c86139fe03c838e54a0940f878d5da6d57ae (patch)
tree86a9cc1f6e22a00b5f804ed610fb35c0fd8e2112
parentba4d6ae62707d20fef8d33ceab3f2de5be3e9ae7 (diff)
downloadsubsurface-a8b1c86139fe03c838e54a0940f878d5da6d57ae.tar.gz
Limit gas compressibility argument range to halfway sane values
The curve fitting for our gas compressibility was only done in the sane range of 0-500 bar, which is what a scuba cylinder can reasonably be expected to perhaps have. But the planner ends up happily using negative cylinder pressures when you run out of gas, and then the compressibility gives nonsensical results. That's clearly a planner bug, but the nonsensical gas compressibility values made it harder to see what could be wrong. So we just clamp the inpot range to the range we have verified against experimental data. If you try to get compressibility for negative pressures, you get the compressibility for an ideal and imaginary gas. And if you try to get compressibility for pressures over 500 bar, we'll just assume that it's 500 bar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--core/gas-model.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/gas-model.c b/core/gas-model.c
index 79dbd2ded..4dccdf6b3 100644
--- a/core/gas-model.c
+++ b/core/gas-model.c
@@ -47,6 +47,14 @@ double gas_compressibility_factor(struct gasmix gas, double bar)
double x1, x2, x3;
double Z;
+ /*
+ * The curve fitting range is only [0,500] bar.
+ * Anything else is way out of range for cylinder
+ * pressures.
+ */
+ if (bar < 0) bar = 0;
+ if (bar > 500) bar = 500;
+
o2 = get_o2(gas);
he = get_he(gas);