From 52b92ee03ba86fd77308aef6c62c51c68344bcb8 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 28 Jan 2015 11:35:15 +0100 Subject: Don't let the oxygen partial pressure drop below 0. No oxygen at all is not quite enough for the average diver but this prevents inifintie loops/extremely long deco when subsurface is used in pscr mode with unrealistic values for pscr preferences. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- dive.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dive.c') diff --git a/dive.c b/dive.c index 4d4cc3e1d..5732c0f83 100644 --- a/dive.c +++ b/dive.c @@ -1683,6 +1683,8 @@ 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); + if (pressures->o2 < 0) // He's dead, Jim. + pressures->o2 = 0; 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)); -- cgit v1.2.3-70-g09d2