comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 292:21a0f7393468

New CNS calculation in decoplan. BUGFIX set current gas in decoplan.
author JeanDo
date Mon, 25 Apr 2011 19:42:44 +0200
parents 4dbff2aa31ee
children e0083f259552
comparison
equal deleted inserted replaced
291:916df3161d52 292:21a0f7393468
2195 // 2195 //
2196 // new in v.101 2196 // new in v.101
2197 // optimized in v.102 : with new variables char_I_actual_ppO2 and actual_ppO2 2197 // optimized in v.102 : with new variables char_I_actual_ppO2 and actual_ppO2
2198 // 2198 //
2199 // Input: char_I_actual_ppO2 2199 // Input: char_I_actual_ppO2
2200 // char_I_step_is_1min : use 1min steps instead of 2sec.
2200 // Output: char_O_CNS_fraction 2201 // Output: char_O_CNS_fraction
2201 // Uses and Updates: CNS_fraction 2202 // Uses and Updates: CNS_fraction
2202 // Uses: acutal_ppO2 2203 // Uses: acutal_ppO2
2203 // 2204 //
2204 void deco_calc_CNS_fraction(void) 2205 void deco_calc_CNS_fraction(void)
2205 { 2206 {
2206 overlay float actual_ppO2; 2207 overlay float actual_ppO2;
2208 overlay float time_factor = 1.0f;
2207 RESET_C_STACK 2209 RESET_C_STACK
2208 2210
2209 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 ); 2211 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 );
2210 assert( char_I_actual_ppO2 > 15 ); 2212 assert( char_I_actual_ppO2 > 15 );
2211 2213
2212 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0; 2214 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0;
2215 if( char_I_step_is_1min )
2216 time_factor = 30.0f;
2213 2217
2214 if (char_I_actual_ppO2 < 50) 2218 if (char_I_actual_ppO2 < 50)
2215 CNS_fraction = CNS_fraction;// no changes 2219 ; // no changes
2216 else if (char_I_actual_ppO2 < 60) 2220 else if (char_I_actual_ppO2 < 60)
2217 CNS_fraction = 1/(-54000.0 * actual_ppO2 + 54000.0) + CNS_fraction; 2221 CNS_fraction += time_factor/(-54000.0 * actual_ppO2 + 54000.0);
2218 else if (char_I_actual_ppO2 < 70) 2222 else if (char_I_actual_ppO2 < 70)
2219 CNS_fraction = 1/(-45000.0 * actual_ppO2 + 48600.0) + CNS_fraction; 2223 CNS_fraction += time_factor/(-45000.0 * actual_ppO2 + 48600.0);
2220 else if (char_I_actual_ppO2 < 80) 2224 else if (char_I_actual_ppO2 < 80)
2221 CNS_fraction = 1/(-36000.0 * actual_ppO2 + 42300.0) + CNS_fraction; 2225 CNS_fraction += time_factor/(-36000.0 * actual_ppO2 + 42300.0);
2222 else if (char_I_actual_ppO2 < 90) 2226 else if (char_I_actual_ppO2 < 90)
2223 CNS_fraction = 1/(-27000.0 * actual_ppO2 + 35100.0) + CNS_fraction; 2227 CNS_fraction += time_factor/(-27000.0 * actual_ppO2 + 35100.0);
2224 else if (char_I_actual_ppO2 < 110) 2228 else if (char_I_actual_ppO2 < 110)
2225 CNS_fraction = 1/(-18000.0 * actual_ppO2 + 27000.0) + CNS_fraction; 2229 CNS_fraction += time_factor/(-18000.0 * actual_ppO2 + 27000.0);
2226 else if (char_I_actual_ppO2 < 150) 2230 else if (char_I_actual_ppO2 < 150)
2227 CNS_fraction = 1/(-9000.0 * actual_ppO2 + 17100.0) + CNS_fraction; 2231 CNS_fraction += time_factor/(-9000.0 * actual_ppO2 + 17100.0);
2228 else if (char_I_actual_ppO2 < 160) 2232 else if (char_I_actual_ppO2 < 160)
2229 CNS_fraction = 1/(-22500.0 * actual_ppO2 + 37350.0) + CNS_fraction; 2233 CNS_fraction += time_factor/(-22500.0 * actual_ppO2 + 37350.0);
2230 else if (char_I_actual_ppO2 < 165) 2234 else if (char_I_actual_ppO2 < 165)
2231 CNS_fraction = 0.000755 + CNS_fraction; // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity... Formula (A1) based on value for 1.55 and c=20 2235 CNS_fraction += time_factor*0.000755; // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity... Formula (A1) based on value for 1.55 and c=20
2232 else if (char_I_actual_ppO2 < 170) 2236 else if (char_I_actual_ppO2 < 170)
2233 CNS_fraction = 0.00102 + CNS_fraction; // example calculation: Sqrt((1.7/1.55)^20)*0.000404 2237 CNS_fraction += time_factor*0.00102; // example calculation: Sqrt((1.7/1.55)^20)*0.000404
2234 else if (char_I_actual_ppO2 < 175) 2238 else if (char_I_actual_ppO2 < 175)
2235 CNS_fraction = 0.00136 + CNS_fraction; 2239 CNS_fraction += time_factor*0.00136;
2236 else if (char_I_actual_ppO2 < 180) 2240 else if (char_I_actual_ppO2 < 180)
2237 CNS_fraction = 0.00180 + CNS_fraction; 2241 CNS_fraction += time_factor*0.00180;
2238 else if (char_I_actual_ppO2 < 185) 2242 else if (char_I_actual_ppO2 < 185)
2239 CNS_fraction = 0.00237 + CNS_fraction; 2243 CNS_fraction += time_factor*0.00237;
2240 else if (char_I_actual_ppO2 < 190) 2244 else if (char_I_actual_ppO2 < 190)
2241 CNS_fraction = 0.00310 + CNS_fraction; 2245 CNS_fraction += time_factor*0.00310;
2242 else if (char_I_actual_ppO2 < 195) 2246 else if (char_I_actual_ppO2 < 195)
2243 CNS_fraction = 0.00401 + CNS_fraction; 2247 CNS_fraction += time_factor*0.00401;
2244 else if (char_I_actual_ppO2 < 200) 2248 else if (char_I_actual_ppO2 < 200)
2245 CNS_fraction = 0.00517 + CNS_fraction; 2249 CNS_fraction += time_factor*0.00517;
2246 else if (char_I_actual_ppO2 < 230) 2250 else if (char_I_actual_ppO2 < 230)
2247 CNS_fraction = 0.0209 + CNS_fraction; 2251 CNS_fraction += time_factor*0.0209;
2248 else 2252 else
2249 CNS_fraction = 0.0482 + CNS_fraction; // value for 2.5 2253 CNS_fraction += time_factor*0.0482; // value for 2.5
2250 2254
2251 if (CNS_fraction > 2.5) 2255 if (CNS_fraction > 2.5)
2252 CNS_fraction = 2.5; 2256 CNS_fraction = 2.5;
2253 if (CNS_fraction < 0.0) 2257 if (CNS_fraction < 0.0)
2254 CNS_fraction = 0.0; 2258 CNS_fraction = 0.0;
2427 void deco_pull_tissues_from_vault(void) 2431 void deco_pull_tissues_from_vault(void)
2428 { 2432 {
2429 overlay unsigned char x; 2433 overlay unsigned char x;
2430 RESET_C_STACK 2434 RESET_C_STACK
2431 2435
2432 CNS_fraction = cns_vault;
2433 for (x=0;x<32;x++) 2436 for (x=0;x<32;x++)
2434 pres_tissue[x] = pres_tissue_vault[x]; 2437 pres_tissue[x] = pres_tissue_vault[x];
2438
2439 // Restore both CNS variable, too.
2440 CNS_fraction = cns_vault;
2441 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5);
2435 } 2442 }
2436 2443
2437 ////////////////////////////////////////////////////////////////////////////// 2444 //////////////////////////////////////////////////////////////////////////////
2438 // 2445 //
2439 #ifndef CROSS_COMPILE 2446 #ifndef CROSS_COMPILE