diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-01-19 20:26:14 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-20 17:22:08 +1200 |
commit | bbef887b792286939902be9ce102ec9b44e5ca55 (patch) | |
tree | a044a143944282ea2fbf0a4c9477be5b281dcd68 /dive.c | |
parent | 39b528d6dae2ad3e05a385821736688b6e590c2f (diff) | |
download | subsurface-bbef887b792286939902be9ce102ec9b44e5ca55.tar.gz |
Don't divide 0/0 when using a PSCR with 100% oxygen
Reported-by: Anton "glance" Lundin <glance@acc.umu.se>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1683,8 +1683,12 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre } else { if (divemode == PSCR) { /* The steady state approximation should be good enough */ pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - (1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (prefs.bottomsac * prefs.pscr_ratio / 1000.0); - pressures->he = (amb_pressure - pressures->o2) * get_he(mix) / (1000.0 - get_o2(mix)); - pressures->n2 = (amb_pressure - pressures->o2) * (1000 - get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix)); + if (get_o2(mix) != 1000) { + pressures->he = (amb_pressure - pressures->o2) * get_he(mix) / (1000.0 - get_o2(mix)); + pressures->n2 = (amb_pressure - pressures->o2) * (1000 - get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix)); + } else { + pressures->he = pressures->n2 = 0; + } } else { // Open circuit dives: no gas pressure values available, they need to be calculated pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure; // These calculations are also used if the CCR calculation above.. |