Fix ATM-vs-bar confusion

SAC should be calculated in relationship to surface pressure, not "1 bar".

I also realize that we have a few other cases where we do the same
mistake: the partial pressure calculations do things like

    po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);

which is wrong as well - the partial pressure is also relative to
standard atmospheric pressures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-02-11 13:08:29 -08:00 committed by Dirk Hohndel
parent 92bbed3304
commit e58f54cac1
4 changed files with 16 additions and 6 deletions

10
dive.h
View file

@ -223,6 +223,11 @@ static inline double bar_to_atm(double bar)
return bar / SURFACE_PRESSURE * 1000;
}
static inline double mbar_to_atm(int mbar)
{
return (double) mbar / SURFACE_PRESSURE;
}
/* Volume in mliter of a cylinder at pressure 'p' */
extern int gas_volume(cylinder_t *cyl, pressure_t p);
extern int wet_volume(double cuft, pressure_t p);
@ -450,6 +455,11 @@ static inline int depth_to_mbar(int depth, struct dive *dive)
return calculate_depth_to_mbar(depth, dive->surface_pressure, dive->salinity);
}
static inline double depth_to_atm(int depth, struct dive *dive)
{
return mbar_to_atm(depth_to_mbar(depth, dive));
}
/* for the inverse calculation we use just the relative pressure
* (that's the one that some dive computers like the Uemis Zurich
* provide - for the other models that do this libdivecomputer has to