comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 307:5bc3467fc421

New live EAD/END in divemode (both OCR and CCR).
author JeanDo
date Sun, 01 May 2011 03:35:42 +0200
parents 36cc8f0c1d73
children b20fc8c4ac92
comparison
equal deleted inserted replaced
306:ab1678d98e46 307:5bc3467fc421
1363 if( int_temp > 100 *(short)char_I_deco_gas_change[4] ) 1363 if( int_temp > 100 *(short)char_I_deco_gas_change[4] )
1364 deco_gas_change[4] = char_I_deco_gas_change[4]; 1364 deco_gas_change[4] = char_I_deco_gas_change[4];
1365 } 1365 }
1366 1366
1367 const_ppO2 = char_I_const_ppO2 * 0.01; 1367 const_ppO2 = char_I_const_ppO2 * 0.01;
1368 deco_ppO2_change = char_I_deco_ppO2_change / 99.95 1368 deco_ppO2_change = char_I_deco_ppO2_change / 99.85
1369 + pres_surface 1369 + pres_surface
1370 + float_deco_distance; 1370 + float_deco_distance;
1371 deco_ppO2 = char_I_deco_ppO2 * 0.01; 1371 deco_ppO2 = char_I_deco_ppO2 * 0.01;
1372 float_desaturation_multiplier = char_I_desaturation_multiplier * 0.01; 1372 float_desaturation_multiplier = char_I_desaturation_multiplier * 0.01;
1373 float_saturation_multiplier = char_I_saturation_multiplier * 0.01; 1373 float_saturation_multiplier = char_I_saturation_multiplier * 0.01;
1385 assert( 0.00 <= He_ratio && He_ratio <= 1.00 ); 1385 assert( 0.00 <= He_ratio && He_ratio <= 1.00 );
1386 assert( (N2_ratio + He_ratio) <= 0.95 ); 1386 assert( (N2_ratio + He_ratio) <= 0.95 );
1387 assert( 0.800 < pres_respiration && pres_respiration < 14.0 ); 1387 assert( 0.800 < pres_respiration && pres_respiration < 14.0 );
1388 1388
1389 pres_diluent = pres_respiration; 1389 pres_diluent = pres_respiration;
1390 if (char_I_const_ppO2 != 0) // new in v.101 1390 if( char_I_const_ppO2 != 0 ) // new in v.101
1391 { 1391 {
1392 pres_diluent -= const_ppO2; // new in v.101 1392 pres_diluent -= const_ppO2; // new in v.101
1393 pres_diluent /= N2_ratio + He_ratio; // new in v.101 1393 pres_diluent /= N2_ratio + He_ratio; // new in v.101
1394 if( pres_diluent > pres_respiration ) // new in v.101 1394 if( pres_diluent > pres_respiration ) // new in v.101
1395 pres_diluent = pres_respiration; // new in v.101 1395 pres_diluent = pres_respiration; // new in v.101
1396
1397 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0 + 0.5);
1398 char_O_diluent_ppO2 = (char)(pres_diluent * (1.0 - N2_ratio - He_ratio) * 100.0 + 0.5);
1396 } 1399 }
1397 if (pres_diluent > ppWVapour) // new in v.101 1400
1401 if( pres_diluent > ppWVapour ) // new in v.101
1398 { 1402 {
1403 overlay float EAD, END;
1404
1399 ppN2 = N2_ratio * (pres_diluent - ppWVapour); // changed in v.101 1405 ppN2 = N2_ratio * (pres_diluent - ppWVapour); // changed in v.101
1400 ppHe = He_ratio * (pres_diluent - ppWVapour); // changed in v.101 1406 ppHe = He_ratio * (pres_diluent - ppWVapour); // changed in v.101
1401 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0); 1407
1408 // EAD : Equivalent Air Dive. Equivalent depth for the same N2 level
1409 // with plain air.
1410 // ppN2 = 79% * (P_EAD - ppWVapour)
1411 // EAD = (P_EAD - Psurface) * 10
1412 // ie: EAD = (ppN2 / 0.7902 + ppWVapour -Psurface) * 10
1413 EAD = (ppN2 / 0.7902 + ppWVapour - pres_surface) * 9.985;
1414 if( EAD < 0.0 || EAD > 245.5 ) EAD = 0.0;
1415 char_O_EAD = (char)(EAD + 0.5);
1416
1417 // END : Equivalent Narcotic Dive.
1418 // Here we count O2 as narcotic too. Hence everything but helium (has a narcosis factor of
1419 // 0.23 btw). Hence the formula becomes:
1420 // END * BarPerMeter * (1.0 - 0.0) - ppWVapour + Psurface == Pambient - ppHe - ppWVapour
1421 // ie: END = (Pambient - ppHe - Psurface) * 9.985
1422 //
1423 // Source cited:
1424 // The Physiology and Medicine of Diving by Peter Bennett and David Elliott,
1425 // 4th edition, 1993, W.B.Saunders Company Ltd, London.
1426 END = (pres_respiration - ppHe - pres_surface) * 9.985;
1427 if( END < 0.0 || END > 245.5 ) END = 0.0;
1428 char_O_END = (char)(END + 0.5);
1402 } 1429 }
1403 else // new in v.101 1430 else // new in v.101
1404 { 1431 {
1405 ppN2 = 0.0; // new in v.101 1432 ppN2 = 0.0; // new in v.101
1406 ppHe = 0.0; // new in v.101 1433 ppHe = 0.0; // new in v.101
1407 char_O_diluent = 0; 1434 char_O_EAD = char_O_END = 0;
1408 } 1435 }
1409 1436
1410 if(!char_I_step_is_1min) 1437 if(!char_I_step_is_1min)
1411 calc_tissue(0); 1438 calc_tissue(0);
1412 else 1439 else