Mercurial > public > hwos_code
comparison 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 |
comparison
equal
deleted
inserted
replaced
526:0d1cda9f2d43 | 527:015b7fdd90a7 |
---|---|
959 { | 959 { |
960 // In CCR mode, use calc_XX_ratio instead of XX_ratio. | 960 // In CCR mode, use calc_XX_ratio instead of XX_ratio. |
961 // Note: PPO2 and ratios are known outside the lumbs, so there is no | 961 // Note: PPO2 and ratios are known outside the lumbs, so there is no |
962 // ppWater in the equations below: | 962 // ppWater in the equations below: |
963 deco_diluent -= const_ppO2; | 963 deco_diluent -= const_ppO2; |
964 deco_diluent /= calc_N2_ratio + calc_He_ratio; | 964 deco_diluent /= calc_N2_ratio + calc_He_ratio;// potential DIV/0 issue when O2 is used as diluent! |
965 | 965 |
966 if(calc_N2_ratio==0&calc_He_ratio==0) deco_diluent = 0.0; // workaround for potential DIV/0 issue | |
966 } | 967 } |
967 | 968 |
968 if( deco_diluent > ppWater ) | 969 if( deco_diluent > ppWater ) |
969 { | 970 { |
970 ppN2 = calc_N2_ratio * (deco_diluent - ppWater); | 971 ppN2 = calc_N2_ratio * (deco_diluent - ppWater); |
1176 if( char_I_const_ppO2 != 0 ) | 1177 if( char_I_const_ppO2 != 0 ) |
1177 { | 1178 { |
1178 overlay float flush_ppO2 = pres_respiration * (1.0 - N2_ratio - He_ratio); | 1179 overlay float flush_ppO2 = pres_respiration * (1.0 - N2_ratio - He_ratio); |
1179 | 1180 |
1180 pres_diluent -= const_ppO2; | 1181 pres_diluent -= const_ppO2; |
1181 pres_diluent /= N2_ratio + He_ratio; | 1182 pres_diluent /= N2_ratio + He_ratio; // potential DIV/0 issue when O2 is used as diluent! |
1182 if( pres_diluent < 0.0 ) | 1183 if( pres_diluent < 0.0 ) |
1183 pres_diluent = 0.0; | 1184 pres_diluent = 0.0; |
1185 if(N2_ratio==0&He_ratio==0) pres_diluent = 0.0; // workaround for potential DIV/0 issue | |
1184 | 1186 |
1185 char_O_diluent = (unsigned char)(pres_diluent/pres_respiration*100.0 + 0.5); | 1187 char_O_diluent = (unsigned char)(pres_diluent/pres_respiration*100.0 + 0.5); |
1186 | 1188 |
1187 if( flush_ppO2 > 2.545) flush_ppO2 = 2.55; | 1189 if( flush_ppO2 > 2.545) flush_ppO2 = 2.55; |
1188 if( flush_ppO2 < 0.0 ) flush_ppO2 = 0.0; | 1190 if( flush_ppO2 < 0.0 ) flush_ppO2 = 0.0; |