Correctly handle air in the deco code

We mark air with o2.permille = 0. But it's actually 20.9% O2.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-01-04 23:09:04 -08:00
parent 1b22ac16f2
commit d87a606039

5
deco.c
View file

@ -148,13 +148,14 @@ static double tissue_tolerance_calc(void)
double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds, double ccpo2)
{
int ci;
double ppn2 = (pressure - WV_PRESSURE) * (1000 - gasmix->o2.permille - gasmix->he.permille) / 1000.0;
int fo2 = gasmix->o2.permille ? gasmix->o2.permille : 209;
double ppn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - gasmix->he.permille) / 1000.0;
double pphe = (pressure - WV_PRESSURE) * gasmix->he.permille / 1000.0;
if (ccpo2 > 0.0) { /* CC */
double rel_o2_amb, f_dilutent;
rel_o2_amb = ccpo2 / pressure;
f_dilutent = (1 - rel_o2_amb) / (1 - gasmix->o2.permille / 1000.0);
f_dilutent = (1 - rel_o2_amb) / (1 - fo2 / 1000.0);
if (f_dilutent < 0) { /* setpoint is higher than ambient pressure -> pure O2 */
ppn2 = 0.0;
pphe = 0.0;