Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 276:02303915c199
BUGFIX CF16 applyed to diluant in CCR mode.
author | JeanDo |
---|---|
date | Mon, 18 Apr 2011 01:19:06 +0200 |
parents | 4310ab395dbe |
children | 17aab4ca0547 |
comparison
equal
deleted
inserted
replaced
275:4310ab395dbe | 276:02303915c199 |
---|---|
1105 | 1105 |
1106 ////////////////////////////////////////////////////////////////////////////// | 1106 ////////////////////////////////////////////////////////////////////////////// |
1107 // | 1107 // |
1108 // Input: calc_N2_ratio, calc_He_ratio : simulated gas mix. | 1108 // Input: calc_N2_ratio, calc_He_ratio : simulated gas mix. |
1109 // temp_deco : simulated respiration pressure + security offset (deco_distance) | 1109 // temp_deco : simulated respiration pressure + security offset (deco_distance) |
1110 // float_deco_distance : security factor. | |
1110 // Water-vapor pressure inside lumbs (ppWVapour). | 1111 // Water-vapor pressure inside lumbs (ppWVapour). |
1111 // | 1112 // |
1112 // Output: ppN2, ppHe. | 1113 // Output: ppN2, ppHe. |
1113 // | 1114 // |
1114 static void sim_alveolar_presures(void) | 1115 static void sim_alveolar_presures(void) |
1115 { | 1116 { |
1116 overlay float deco_diluent = temp_deco; // new in v.101 | 1117 overlay float deco_diluent = temp_deco; // new in v.101 |
1117 | 1118 |
1119 // Take deco offset into account, but not at surface. | |
1120 // Note: this should be done on ambiant pressure, hence before | |
1121 // computing the diluant partial pressure... | |
1122 if( deco_diluent > pres_surface ) | |
1123 deco_diluent += float_deco_distance; | |
1124 | |
1118 //---- CCR mode : deco gas switch ? -------------------------------------- | 1125 //---- CCR mode : deco gas switch ? -------------------------------------- |
1119 if (char_I_const_ppO2 != 0) | 1126 if( char_I_const_ppO2 != 0 ) |
1120 { | 1127 { |
1121 // In CCR mode, calc_XX_ratio == XX_ratio. | 1128 // In CCR mode, use calc_XX_ratio instead of XX_ratio. |
1129 // Note: PPO2 and ratios are known outside the lumbs, so there is no | |
1130 // ppWVapour in the equations below: | |
1122 if( temp_deco > deco_ppO2_change ) | 1131 if( temp_deco > deco_ppO2_change ) |
1123 deco_diluent = ((temp_deco - const_ppO2)/(calc_N2_ratio + calc_He_ratio)); | 1132 deco_diluent -= const_ppO2; |
1124 else | 1133 else |
1125 deco_diluent = ((temp_deco - deco_ppO2)/(calc_N2_ratio + calc_He_ratio)); | 1134 deco_diluent -= deco_ppO2; |
1135 deco_diluent /= calc_N2_ratio + calc_He_ratio; | |
1126 | 1136 |
1127 if (deco_diluent > temp_deco) | 1137 if (deco_diluent > temp_deco) |
1128 deco_diluent = temp_deco; | 1138 deco_diluent = temp_deco; |
1129 } | 1139 } |
1130 | |
1131 // Take deco offset into account, but not at surface. | |
1132 if( deco_diluent > pres_surface ) | |
1133 deco_diluent += float_deco_distance; | |
1134 | 1140 |
1135 if( deco_diluent > ppWVapour ) | 1141 if( deco_diluent > ppWVapour ) |
1136 { | 1142 { |
1137 ppN2 = calc_N2_ratio * (deco_diluent - ppWVapour); | 1143 ppN2 = calc_N2_ratio * (deco_diluent - ppWVapour); |
1138 ppHe = calc_He_ratio * (deco_diluent - ppWVapour); | 1144 ppHe = calc_He_ratio * (deco_diluent - ppWVapour); |
1365 assert( 0.00 <= N2_ratio && N2_ratio <= 1.00 ); | 1371 assert( 0.00 <= N2_ratio && N2_ratio <= 1.00 ); |
1366 assert( 0.00 <= He_ratio && He_ratio <= 1.00 ); | 1372 assert( 0.00 <= He_ratio && He_ratio <= 1.00 ); |
1367 assert( (N2_ratio + He_ratio) <= 0.95 ); | 1373 assert( (N2_ratio + He_ratio) <= 0.95 ); |
1368 assert( 0.800 < pres_respiration && pres_respiration < 14.0 ); | 1374 assert( 0.800 < pres_respiration && pres_respiration < 14.0 ); |
1369 | 1375 |
1370 if (char_I_const_ppO2 == 0) // new in v.101 | 1376 pres_diluent = pres_respiration; |
1371 pres_diluent = pres_respiration; // new in v.101 | 1377 if (char_I_const_ppO2 != 0) // new in v.101 |
1372 else | 1378 { |
1373 { | 1379 pres_diluent -= const_ppO2; // new in v.101 |
1374 pres_diluent = ((pres_respiration - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101 | 1380 pres_diluent /= N2_ratio + He_ratio; // new in v.101 |
1375 if (pres_diluent > pres_respiration) // new in v.101 | 1381 if( pres_diluent > pres_respiration ) // new in v.101 |
1376 pres_diluent = pres_respiration; // new in v.101 | 1382 pres_diluent = pres_respiration; // new in v.101 |
1377 } | 1383 } |
1378 if (pres_diluent > ppWVapour) // new in v.101 | 1384 if (pres_diluent > ppWVapour) // new in v.101 |
1379 { | 1385 { |
1380 ppN2 = N2_ratio * (pres_diluent - ppWVapour); // changed in v.101 | 1386 ppN2 = N2_ratio * (pres_diluent - ppWVapour); // changed in v.101 |
1381 ppHe = He_ratio * (pres_diluent - ppWVapour); // changed in v.101 | 1387 ppHe = He_ratio * (pres_diluent - ppWVapour); // changed in v.101 |
1382 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0); | 1388 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0); |
1383 } | 1389 } |
1384 else // new in v.101 | 1390 else // new in v.101 |
1385 { | 1391 { |