SAC and Gas Consumed Calculation

Linus Torvalds torvalds at
Tue Feb 11 09:36:41 UTC 2014

On Tue, Feb 11, 2014 at 5:39 AM, Rick Walsh <rickmwalsh at> wrote:
> I have just realized that Subsurface appears to be miscalculating gas
> consumption and SAC.

Heh. Not really.

What happens is that subsurface actually calculates gas consumption
differently - and better - than you expect.

In particular, it takes the incompressibility of the gas into account, so:

> Gas consumption and SAC should be:
> consumption = tank size x (start pressure - end pressure)

You'd think so, and yes, that's true for an ideal gas, and it's what
you get taught in dive theory.

But an "ideal gas" doesn't actually exist, and real gases actually
don't compress linearly with pressure. Also, you are missing the fact
that one atmosphere of pressure isn't actually one bar.

So the *real* calculation is:

   consumption = amount_of_air_at_beginning - amount_of_air_at_end;

where the amount of air is *not* just "tank size times pressure in
bar". It's a combination of: "take compressibility into account"
(which is a fairly small issue under 220 bar - you'll see more
differences when you do high-pressure tanks with 300bar) and "convert
bar to atm" (which is the majority of your discrepancy).

Remember: one ATM is ~1.013 bar, so without the compressibility, your gas use is


which is about 1445, not 1464. So there was 19 l too much in your
simple calculation that ignored the difference between 1 bar and one

The compressibility does show up above 200 bar, and takes that 1445
down about eight liters more, so you really did use only about 1437 l
of air at surface pressure.

If you care about the math (or want to change it), see dive.c:

The "if (bar > 200) bar = .." part is the compressibility - it's an
approximation, but it's a reasonably good one, and closer to reality
than not doing it.

You can get the numbers you expect if you remove that, and turn the
function into just

     return pressure.mbar / 1000.0;

but that would actually be wrong.

So be happy: your SAC really is better than your calculations indicated.

Or be sad: your cylinder contains less air than you thought it did.

And as mentioned, the "contains less air than you thought it did"
really starts becoming much more noticeable at high pressure. A 400
bar really does not contain twice as much air as a 200 bar one. At
lower pressures, air acts pretty much like an ideal gas.


More information about the subsurface mailing list