diff src/p2_deco.c @ 527:015b7fdd90a7

BUGFIX: O2 as diluent in CCR caused wrong calculations (Deco, EAD, END) in less then 6m depth
author heinrichsweikamp
date Sat, 05 Aug 2017 17:36:58 +0200
parents 4d70a93b18cb
children a5d2e6083b1d
line wrap: on
line diff
--- a/src/p2_deco.c	Sat Aug 05 16:50:28 2017 +0200
+++ b/src/p2_deco.c	Sat Aug 05 17:36:58 2017 +0200
@@ -961,8 +961,9 @@
         // Note: PPO2 and ratios are known outside the lumbs, so there is no
         //       ppWater in the equations below:
         deco_diluent -= const_ppO2;
-        deco_diluent /= calc_N2_ratio + calc_He_ratio;
-
+        deco_diluent /= calc_N2_ratio + calc_He_ratio;// potential DIV/0 issue when O2 is used as diluent!
+        
+        if(calc_N2_ratio==0&calc_He_ratio==0) deco_diluent = 0.0; // workaround for potential DIV/0 issue
     }
 
     if( deco_diluent > ppWater )
@@ -1178,9 +1179,10 @@
         overlay float flush_ppO2 = pres_respiration * (1.0 - N2_ratio - He_ratio);
 
         pres_diluent -= const_ppO2;
-        pres_diluent /= N2_ratio + He_ratio;
+        pres_diluent /= N2_ratio + He_ratio;            // potential DIV/0 issue when O2 is used as diluent!
         if( pres_diluent < 0.0 )
             pres_diluent = 0.0;
+        if(N2_ratio==0&He_ratio==0) pres_diluent = 0.0; // workaround for potential DIV/0 issue
 
         char_O_diluent = (unsigned char)(pres_diluent/pres_respiration*100.0 + 0.5);