mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
d53bedbed6
commit
308d71ec39
5 changed files with 58 additions and 36 deletions
13
divelist.c
13
divelist.c
|
@ -697,26 +697,19 @@ static int calculate_otu(struct dive *dive)
|
|||
*/
|
||||
static double calculate_airuse(struct dive *dive)
|
||||
{
|
||||
double airuse = 0;
|
||||
int airuse = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
pressure_t start, end;
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
int size = cyl->type.size.mliter;
|
||||
double kilo_atm;
|
||||
|
||||
if (!size)
|
||||
continue;
|
||||
|
||||
start = cyl->start.mbar ? cyl->start : cyl->sample_start;
|
||||
end = cyl->end.mbar ? cyl->end : cyl->sample_end;
|
||||
kilo_atm = (to_ATM(start) - to_ATM(end)) / 1000.0;
|
||||
|
||||
/* Liters of air at 1 atm == milliliters at 1k atm*/
|
||||
airuse += kilo_atm * size;
|
||||
airuse += gas_volume(cyl, start) - gas_volume(cyl, end);
|
||||
}
|
||||
return airuse;
|
||||
return airuse / 1000.0;
|
||||
}
|
||||
|
||||
/* this only uses the first divecomputer to calculate the SAC rate */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue