Take incompressibility of gas into account at higher pressures

This creates a helper function called "gas_volume()" that takes the
cylinder and a particular pressure, and returns the estimated volume of
the gas at surface pressure, including proper approximation of the
incompressibility of gas.

It very much is an approximation, but it's closer to reality than
assuming a pure ideal gas.  See for example compressibility at

    http://en.wikipedia.org/wiki/Compressibility_factor

Suggested-by: Jukka Lind <jukka.lind@iki.fi>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-02-25 15:23:16 -08:00 committed by Dirk Hohndel
parent d53bedbed6
commit 308d71ec39
5 changed files with 58 additions and 36 deletions

6
dive.h
View file

@ -203,10 +203,8 @@ static inline double bar_to_atm(double bar)
return bar / SURFACE_PRESSURE * 1000;
}
static inline double to_ATM(pressure_t pressure)
{
return pressure.mbar / (double) SURFACE_PRESSURE;
}
/* Volume in mliter of a cylinder at pressure 'p' */
extern int gas_volume(cylinder_t *cyl, pressure_t p);
static inline int mbar_to_PSI(int mbar)
{