Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 783:e57e8045527d
FIX: Gas volume computation when using several travel mix.
author | JeanDo |
---|---|
date | Sun, 15 Jun 2014 17:49:22 +0200 |
parents | 6f54104ea0ee |
children | b0c96aaa86e4 |
comparison
equal
deleted
inserted
replaced
782:6f54104ea0ee | 783:e57e8045527d |
---|---|
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 // 2013/03/05: [jDG] Wrobell remark: ascent_to_first_stop works better with finer steps (2sec). |
90 // 2013/05/08: [jDG] A. Salm remark: NOAA tables for CNS are in ATA, not bar. | 90 // 2013/05/08: [jDG] A. Salm remark: NOAA tables for CNS are in ATA, not bar. |
91 // 2013/10/22: [mH] Remove CF55 stuff | 91 // 2013/10/22: [mH] Remove CF55 stuff |
92 // 2013/12/21: [jDG] Fix CNS calculation in decoplan w/o marked gas switch | 92 // 2013/12/21: [jDG] Fix CNS calculation in decoplan w/o marked gas switch |
93 // 2014/06/16: [jDG] Fix Helium diluant. Fix volumes with many travel mix. | |
93 // | 94 // |
94 // TODO: | 95 // TODO: |
95 // + Allow to abort MD2 calculation (have to restart next time). | 96 // + Allow to abort MD2 calculation (have to restart next time). |
96 // | 97 // |
97 // Literature: | 98 // Literature: |
2353 { | 2354 { |
2354 overlay float volumes[NUM_GAS]; | 2355 overlay float volumes[NUM_GAS]; |
2355 overlay float bottom_usage, deco_usage; | 2356 overlay float bottom_usage, deco_usage; |
2356 overlay unsigned char i, deepest_first; | 2357 overlay unsigned char i, deepest_first; |
2357 overlay unsigned char gas, depth; | 2358 overlay unsigned char gas, depth; |
2359 overlay unsigned char lastGasStop = 255; | |
2358 RESET_C_STACK | 2360 RESET_C_STACK |
2359 | 2361 |
2360 //---- initialize with bottom consumption -------------------------------- | 2362 //---- initialize with bottom consumption -------------------------------- |
2361 for(i=0; i<NUM_GAS; ++i) // Nothing yet... | 2363 for(i=0; i<NUM_GAS; ++i) // Nothing yet... |
2362 volumes[i] = 0.0; | 2364 volumes[i] = 0.0; |
2395 if( time == 0 ) continue; // not yet: still search table. | 2397 if( time == 0 ) continue; // not yet: still search table. |
2396 | 2398 |
2397 newDepth = char_O_deco_depth[31-i]; | 2399 newDepth = char_O_deco_depth[31-i]; |
2398 } | 2400 } |
2399 | 2401 |
2400 //---- Gas switch during this step ----------------------------------- | 2402 //---- Gas switch during or before this stop -------------------------- |
2403 for(;;) | |
2401 { | 2404 { |
2402 overlay unsigned char newGas = 0; | 2405 overlay unsigned char newGas = 0; |
2403 overlay unsigned char newStop = 0; // NO CHANGE yet | 2406 overlay unsigned char newStop = 0; // NO CHANGE yet |
2404 overlay unsigned char j; | 2407 overlay unsigned char j; |
2405 | 2408 |
2406 for(j=0; j<NUM_GAS; ++j) | 2409 for(j=0; j<NUM_GAS; ++j) |
2407 { | 2410 { |
2408 // Skip gas without changing depth: | 2411 // Skip gas without changing depth: |
2409 if( ! char_I_deco_gas_change[j] ) | 2412 if( ! char_I_deco_gas_change[j] ) |
2410 continue; | 2413 continue; |
2411 // Select gas changed between [newDepth .. depth] | 2414 // Select gas changed between [newDepth .. lastGasStop[ |
2415 // Note that <= means changing gas at BEGINNING of this stop. | |
2416 // Note that < means we cant use the same gas twice | |
2412 if( newDepth <= char_I_deco_gas_change[j] | 2417 if( newDepth <= char_I_deco_gas_change[j] |
2413 && char_I_deco_gas_change[j] <= depth ) | 2418 && char_I_deco_gas_change[j] < lastGasStop ) |
2414 { | 2419 { |
2415 // Keep the DEEPEST gas in that range: | 2420 // Keep the DEEPEST gas in that range: |
2416 // Note: that = means changing gas at BEGINNING of this stop. | |
2417 if( char_I_deco_gas_change[j] >= newStop ) | 2421 if( char_I_deco_gas_change[j] >= newStop ) |
2418 { | 2422 { |
2419 newGas = j; | 2423 newGas = j; |
2420 newStop = char_I_deco_gas_change[j]; | 2424 newStop = char_I_deco_gas_change[j]; |
2421 } | 2425 } |
2422 } | 2426 } |
2423 } | 2427 } |
2424 | 2428 |
2425 if( newStop ) // Did we find something ? | 2429 // Did we find something ? |
2426 { | 2430 if( !newStop ) |
2427 // usage BEFORE gas switch (if any), at 10m/min : | 2431 break; |
2428 if( deco_usage > 0.0 && depth > newStop ) | 2432 |
2429 // Plus usage during ascent to the next stop, at 10m/min. | 2433 //---- usage BEFORE gas switch (if any), at 10m/min : |
2430 volumes[gas] += ((depth+newStop)*0.05 + 1.0) // average depth --> bar. | 2434 if( deco_usage > 0.0 && depth > newStop ) |
2431 * (depth-newStop)*0.1 // metre --> min | 2435 // Plus usage during ascent to the next stop, at 10m/min. |
2432 * deco_usage; | 2436 volumes[gas] += ((depth+newStop)*0.05 + 1.0) // average depth --> bar. |
2433 | 2437 * (depth-newStop)*0.1 // metre --> min |
2434 // Do gas switch: | 2438 * deco_usage; |
2435 gas = newGas; | 2439 |
2440 //---- Do gas switch: | |
2441 gas = newGas; | |
2442 | |
2443 lastGasStop = newStop; // Mark last used gas | |
2444 if( newStop < depth ) // ascent to gas switch, | |
2436 depth = newStop; | 2445 depth = newStop; |
2437 } | 2446 } |
2438 } | 2447 |
2439 | 2448 //---- usage AFTER gas switch (if any), at 10m/min : |
2440 // usage AFTER gas switch (if any), at 10m/min : | |
2441 if( depth > newDepth ) | 2449 if( depth > newDepth ) |
2442 volumes[gas] += ((depth+newDepth)*0.05 + 1.0) // average depth --> bar. | 2450 volumes[gas] += ((depth+newDepth)*0.05 + 1.0) // average depth --> bar. |
2443 * (depth-newDepth)*0.1 // metre --> min | 2451 * (depth-newDepth)*0.1 // metre --> min |
2444 * deco_usage; | 2452 * deco_usage; |
2445 | 2453 |
2446 // Do stop: | 2454 //---- Do stop: |
2447 depth = newDepth; | 2455 depth = newDepth; |
2448 | 2456 |
2449 // Usage at stop: | 2457 // Usage at stop: |
2450 if( deco_usage > 0.0 ) | 2458 if( deco_usage > 0.0 ) |
2451 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar. | 2459 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar. |