comparison src/p2_deco.c @ 324:0e9dcdcf03c1

FIX NDL prediction error with Buhlmann model: might be desaturating too fast.
author jdg@air
date Sat, 13 Jun 2015 02:28:37 +0200
parents 19f7dc2b12d6
children 7812ec7ef694
comparison
equal deleted inserted replaced
323:19f7dc2b12d6 324:0e9dcdcf03c1
85 // 2013/03/05: [jDG] Should vault low_depth too. 85 // 2013/03/05: [jDG] Should vault low_depth too.
86 // 2013/03/05: [jDG] Wrobell remark: ascent_to_first_stop works better with finer steps (2sec). 86 // 2013/03/05: [jDG] Wrobell remark: ascent_to_first_stop works better with finer steps (2sec).
87 // 2013/05/08: [jDG] A. Salm remark: NOAA tables for CNS are in ATA, not bar. 87 // 2013/05/08: [jDG] A. Salm remark: NOAA tables for CNS are in ATA, not bar.
88 // 2013/12/21: [jDG] Fix CNS calculation in decoplan w/o marked gas switch 88 // 2013/12/21: [jDG] Fix CNS calculation in decoplan w/o marked gas switch
89 // 2014/06/16: [jDG] Fix Helium diluant. Fix volumes with many travel mix. 89 // 2014/06/16: [jDG] Fix Helium diluant. Fix volumes with many travel mix.
90 // 2014/06/29: [mH] Compute int_O_ceiling 90 // 2014/06/29: [mH] Compute int_O_ceiling
91 // 2015/06/12: [jDG] Fix NDL prediction while desaturating with the Buhlmann model.
91 // 92 //
92 // TODO: 93 // TODO:
93 // 94 //
94 // Literature: 95 // Literature:
95 // Buhlmann, Albert: Tauchmedizin; 4. Auflage [2002]; 96 // Buhlmann, Albert: Tauchmedizin; 4. Auflage [2002];
188 #ifndef UNIX 189 #ifndef UNIX
189 # pragma udata bank6=0x600 190 # pragma udata bank6=0x600
190 #endif 191 #endif
191 192
192 static unsigned char ci; 193 static unsigned char ci;
193 static float pres_respiration; 194 static float pres_respiration;
194 static float pres_surface; 195 static float pres_surface;
195 static float temp_deco; 196 static float temp_deco;
196 static float ppN2; 197 static float ppN2;
197 static float ppHe; 198 static float ppHe;
198 static float temp_tissue; 199 static float temp_tissue;
199 static float N2_ratio; // Breathed gas nitrogen ratio. 200 static float N2_ratio; // Breathed gas nitrogen ratio.
200 static float He_ratio; // Breathed gas helium ratio. 201 static float He_ratio; // Breathed gas helium ratio.
201 static float var_N2_a; // Buhlmann a, for current N2 tissue. 202 static float var_N2_a; // Buhlmann a, for current N2 tissue.
202 static float var_N2_b; // Buhlmann b, for current N2 tissue. 203 static float var_N2_b; // Buhlmann b, for current N2 tissue.
203 static float var_He_a; // Buhlmann a, for current He tissue. 204 static float var_He_a; // Buhlmann a, for current He tissue.
204 static float var_He_b; // Buhlmann b, for current He tissue. 205 static float var_He_b; // Buhlmann b, for current He tissue.
205 static float var_N2_e; // Exposition, for current N2 tissue. 206 static float var_N2_e; // Exposition, for current N2 tissue.
206 static float var_He_e; // Exposition, for current He tissue. 207 static float var_He_e; // Exposition, for current He tissue.
207 static float var_N2_ht; // Half-time for current N2 tissue. 208 static float var_N2_ht; // Half-time for current N2 tissue.
208 static float var_He_ht; // Half-time for current N2 tissue. 209 static float var_He_ht; // Half-time for current N2 tissue.
209 210
210 static float pres_diluent; // new in v.101 211 static float pres_diluent; // new in v.101
211 static float const_ppO2; // new in v.101 212 static float const_ppO2; // new in v.101
212 213
213 static unsigned char sim_gas_last_depth; // Depth of last used gas, to detected a gas switch. 214 static unsigned char sim_gas_last_depth; // Depth of last used gas, to detected a gas switch.
214 static unsigned char sim_gas_last_used; // Number of last used gas, to detected a gas switch. 215 static unsigned char sim_gas_last_used; // Number of last used gas, to detected a gas switch.
215 static unsigned short sim_dive_mins; // Simulated dive time. 216 static unsigned short sim_dive_mins; // Simulated dive time.
216 static float calc_N2_ratio; // Simulated (switched) nitrogen ratio. 217 static float calc_N2_ratio; // Simulated (switched) nitrogen ratio.
217 static float calc_He_ratio; // Simulated (switched) helium ratio. 218 static float calc_He_ratio; // Simulated (switched) helium ratio.
218 static float CNS_fraction; // new in v.101 219 static float CNS_fraction; // new in v.101
219 static float float_saturation_multiplier; // new in v.101 220 static float float_saturation_multiplier; // new in v.101
220 static float float_desaturation_multiplier; // new in v.101 221 static float float_desaturation_multiplier; // new in v.101
221 static float float_deco_distance; // new in v.101 222 static float float_deco_distance; // new in v.101
222 223
223 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 224 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109
224 static unsigned char internal_deco_gas [NUM_STOPS]; 225 static unsigned char internal_deco_gas [NUM_STOPS];
225 226
226 //---- Bank 7 parameters ----------------------------------------------------- 227 //---- Bank 7 parameters -----------------------------------------------------
1414 overlay float dTHe = (ppHe - tHe) * var_He_e; 1415 overlay float dTHe = (ppHe - tHe) * var_He_e;
1415 1416
1416 //---- Apply security margin when using the non-GF model 1417 //---- Apply security margin when using the non-GF model
1417 if( char_I_deco_model == 0 ) 1418 if( char_I_deco_model == 0 )
1418 { 1419 {
1419 dTN2 *= float_saturation_multiplier; 1420 // NDL can be computed while ascending... SO we have
1420 dTHe *= float_saturation_multiplier; 1421 // to check wether we are saturating or desaturating.
1422 if( dTN2 > 0.0 ) dTN2 *= float_saturation_multiplier;
1423 else dTN2 *= float_desaturation_multiplier;
1424
1425 if( dTHe > 0.0 ) dTHe *= float_saturation_multiplier;
1426 else dTHe *= float_saturation_multiplier;
1421 } 1427 }
1422 else // Or GF-based model 1428 else // Or GF-based model
1423 M0 = GF_high * (M0 - pres_surface) + pres_surface; 1429 M0 = GF_high * (M0 - pres_surface) + pres_surface;
1424 1430
1425 //---- Simulate off-gasing while going to surface 1431 //---- Simulate off-gasing while going to surface