git bisect vs libdivecomputer interface

Linus Torvalds torvalds at linux-foundation.org
Tue Jan 10 15:08:19 PST 2017


On Tue, Jan 10, 2017 at 5:23 AM, Robert Helling <helling at lmu.de> wrote:
>
> Which worries me a bit: I am surprised that the effect of using real gas
> compressibility vs ideal gas law makes such a difference. 18.5 vs 20 is an
> 8% difference in SAC rate!
> If I print out the compressibility I get
>
> z = 1,037447 at 202,600000
> z = 0,995009 at 101,300000
>
> which does not really look like it should make an 8% difference. Maybe we
> should double check the math…

So I think what confuses you is that the error at 200 bar is only 4%,
but then you see a 8% error in gas usage.

It is indeed confusing.

But I actually think it's correct. The reason it is correct is that
the error itself isn't linear. At half tank, your gas basically acts
exactly like an ideal gas.

So *all* of the errors come in in the "half tank -> full tank"
interval. So at 200 bar, you see a 4% difference from the ideal gas
law IN THE WHOLE TANK.

In contrast, at 100 bar, you see no error at all.

So the reason you see a 8% difference is that it's a 4% difference in
total, but it all happened in that half tank gas usage that you are
looking for. So while the _absolute_ error at 200 bar is only 4%, when
you then look at the error relative to half-tank, you are basically
seeing the same absolute error distance, but you are comparing it to
half the volume!

That's how you get that "4% absolute error" becoming a "8% relative error".

Think of it this way: when you compare 100 and 99 ("full tank"), you
only have a 1% error.

But if you compare the distance from 50 ("half tank"), the distance
from 100-vs-99 to 50 is is 50-vs-49 - and now it's a 2% difference in
distance.

I hope that explanation makes sense.

Anyway, I still won't guarantee that we do all the gas calculations
right. I could have screwed something up, and we could also have other
places where we simply don't do the compressibility right (or at all),
and there could be confusion from that too.

I just sent out a patch that might at least make some of our
compressibility calculations a little bit less opaque.

Does that patch (and the explanation above) make things clearer? I'm
not really sure what your original test-case was, so maybe I've
entirely missed it.

                Linus


More information about the subsurface mailing list