comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 698:1a5804e21d3f

BUGFIX ascent to fisrt stop in finer steps.
author JeanDo
date Wed, 06 Mar 2013 14:43:03 +0100
parents 53e41fa1e3f0
children d36f060e8203
comparison
equal deleted inserted replaced
697:53e41fa1e3f0 698:1a5804e21d3f
84 // 2012/02/24: [jDG] Remove missed stop bug. 84 // 2012/02/24: [jDG] Remove missed stop bug.
85 // 2012/02/25: [jDG] Looking for a more stable LOW grad factor reference. 85 // 2012/02/25: [jDG] Looking for a more stable LOW grad factor reference.
86 // 2012/09/10: [mH] Fill char_O_deco_time_for_log for logbook write 86 // 2012/09/10: [mH] Fill char_O_deco_time_for_log for logbook write
87 // 2012/10/05: [jDG] Better deco_gas_volumes accuracy (average depth, switch between stop). 87 // 2012/10/05: [jDG] Better deco_gas_volumes accuracy (average depth, switch between stop).
88 // 2013/03/05: [jDG] Should vault low_depth too. 88 // 2013/03/05: [jDG] Should vault low_depth too.
89 // 2013/03/05: [jDG] Wrobell remark: ascent_to_first_stop works better with finer steps (2sec).
89 // 90 //
90 // TODO: 91 // TODO:
91 // + Allow to abort MD2 calculation (have to restart next time). 92 // + Allow to abort MD2 calculation (have to restart next time).
92 // 93 //
93 // Literature: 94 // Literature:
1335 // 1336 //
1336 // if char_O_deco_status indicate @+5 variant, add extra time at current depth, 1337 // if char_O_deco_status indicate @+5 variant, add extra time at current depth,
1337 // before ascent. 1338 // before ascent.
1338 void sim_ascent_to_first_stop(void) 1339 void sim_ascent_to_first_stop(void)
1339 { 1340 {
1341 overlay unsigned char fast = 1; // 1min or 2sec steps.
1342
1340 update_startvalues(); 1343 update_startvalues();
1341 clear_deco_table(); 1344 clear_deco_table();
1342 1345
1343 temp_deco = pres_respiration; // Starts from current real depth. 1346 temp_deco = pres_respiration; // Starts from current real depth.
1344 1347
1353 //---- Loop until first stop, gas switch, or surface is reached ---------- 1356 //---- Loop until first stop, gas switch, or surface is reached ----------
1354 for(;;) 1357 for(;;)
1355 { 1358 {
1356 overlay float old_deco = temp_deco; // Pamb backup (bars) 1359 overlay float old_deco = temp_deco; // Pamb backup (bars)
1357 1360
1358 // Try ascending 1 full minute. 1361 // Try ascending 1 full minute (fast) or 2sec (!fast):
1359 temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar. 1362 if( fast )
1363 temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar.
1364 else
1365 temp_deco -= (10.0/30.0)*METER_TO_BAR; // 2sec at 10m/min.
1366
1360 if( temp_deco < pres_surface ) // But don't go over surface. 1367 if( temp_deco < pres_surface ) // But don't go over surface.
1361 temp_deco = pres_surface; 1368 temp_deco = pres_surface;
1362 1369
1363 // Recompute sim_lead_tissue_limit at GF_low (deepest stop), because 1370 // Recompute sim_lead_tissue_limit at GF_low (deepest stop), because
1364 // one minute passed. 1371 // one minute passed.
1366 1373
1367 // Did we reach deepest remaining stop ? 1374 // Did we reach deepest remaining stop ?
1368 if( temp_deco < sim_lead_tissue_limit ) 1375 if( temp_deco < sim_lead_tissue_limit )
1369 { 1376 {
1370 temp_deco = old_deco; // Restore last correct depth, 1377 temp_deco = old_deco; // Restore last correct depth,
1371 break; // Do no spend a minute more. 1378
1379 if( fast )
1380 {
1381 fast = 0; // Retry with 2sec steps.
1382 continue;
1383 }
1384 else
1385 break; // Done...
1372 } 1386 }
1373 1387
1374 // Did we reach surface ? 1388 // Did we reach surface ?
1375 // NOTE: we should round BEFORE checking surface is reached. 1389 // NOTE: we should round BEFORE checking surface is reached.
1376 temp_depth_limit = (unsigned char)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); 1390 temp_depth_limit = (unsigned char)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER);
1387 1401
1388 temp_deco = temp_depth_limit * METER_TO_BAR + pres_surface; 1402 temp_deco = temp_depth_limit * METER_TO_BAR + pres_surface;
1389 break; 1403 break;
1390 } 1404 }
1391 1405
1392 sim_dive_mins++; // Advance simulated time by 1 minute. 1406 if( fast )
1407 sim_dive_mins++; // Advance simulated time by 1 minute.
1393 sim_alveolar_presures(); // temp_deco --> ppN2/ppHe 1408 sim_alveolar_presures(); // temp_deco --> ppN2/ppHe
1394 sim_tissue(1); // and update tissues for 1 min. 1409 sim_tissue(fast); // and update tissues for 1 min.
1395 } 1410 }
1396 } 1411 }
1397 1412
1398 ////////////////////////////////////////////////////////////////////////////// 1413 //////////////////////////////////////////////////////////////////////////////
1399 // Simulation extra time at the current depth. 1414 // Simulation extra time at the current depth.