diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-04 23:09:04 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-04 23:09:04 -0800 |
commit | d87a606039698d201f81740f5ded8d7aa6e851df (patch) | |
tree | ced7f0813ec5d8cc076279aff905e479e3fcc9f1 /deco.c | |
parent | 1b22ac16f2ae22ad49a1c6bdd7b2fd9f6997e35f (diff) | |
download | subsurface-d87a606039698d201f81740f5ded8d7aa6e851df.tar.gz |
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>
Diffstat (limited to 'deco.c')
-rw-r--r-- | deco.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; |