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>
This commit is contained in:
Linus Torvalds 2019-08-07 11:12:06 -07:00 committed by bstoeger
parent ba4d6ae627
commit a8b1c86139

View file

@ -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);