Mercurial > public > hwos_code
comparison src/p2_deco.c @ 322:fe06f1d1a285
FIX 16bits CNS feedback: assert CNS up to 999%
author | jDG |
---|---|
date | Fri, 12 Jun 2015 22:15:57 +0200 |
parents | 0ce5fa241b8e |
children | 19f7dc2b12d6 |
comparison
equal
deleted
inserted
replaced
313:0ce5fa241b8e | 322:fe06f1d1a285 |
---|---|
1893 for(t=0; t<char_I_dive_interval; ++t) | 1893 for(t=0; t<char_I_dive_interval; ++t) |
1894 { | 1894 { |
1895 calc_tissue(2); // period = 10min. | 1895 calc_tissue(2); // period = 10min. |
1896 CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9) | 1896 CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9) |
1897 } | 1897 } |
1898 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.56 ); | 1898 assert( 0.0 <= CNS_fraction && CNS_fraction <= 9.99 ); // 999 % |
1899 int_O_CNS_fraction = (unsigned int)(CNS_fraction * 100.0 + 0.5); | 1899 int_O_CNS_fraction = (unsigned short)(CNS_fraction * 100.0 + 0.5); |
1900 | 1900 |
1901 //---- Restore model ----------------------------------------------------- | 1901 //---- Restore model ----------------------------------------------------- |
1902 char_I_deco_model = backup_model; | 1902 char_I_deco_model = backup_model; |
1903 } | 1903 } |
1904 | 1904 |
1926 void deco_calc_CNS_fraction(void) | 1926 void deco_calc_CNS_fraction(void) |
1927 { | 1927 { |
1928 overlay float time_factor = 1.0f; | 1928 overlay float time_factor = 1.0f; |
1929 RESET_C_STACK | 1929 RESET_C_STACK |
1930 | 1930 |
1931 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.56 ); | 1931 assert( 0.0 <= CNS_fraction && CNS_fraction <= 9.99 ); |
1932 assert( char_I_actual_ppO2 > 15 ); | 1932 assert( char_I_actual_ppO2 > 15 ); |
1933 | 1933 |
1934 if( char_I_step_is_1min == 1 ) | 1934 if( char_I_step_is_1min == 1 ) |
1935 time_factor = 30.0f; | 1935 time_factor = 30.0f; |
1936 else if( char_I_step_is_1min == 2 ) | 1936 else if( char_I_step_is_1min == 2 ) |
1955 CNS_fraction += time_factor/( -88.84 * char_I_actual_ppO2 + 17100.0); | 1955 CNS_fraction += time_factor/( -88.84 * char_I_actual_ppO2 + 17100.0); |
1956 else if (char_I_actual_ppO2 < 167) | 1956 else if (char_I_actual_ppO2 < 167) |
1957 CNS_fraction += time_factor/(-222.11 * char_I_actual_ppO2 + 37350.0); | 1957 CNS_fraction += time_factor/(-222.11 * char_I_actual_ppO2 + 37350.0); |
1958 //------------------------------------------------------------------------ | 1958 //------------------------------------------------------------------------ |
1959 // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity: | 1959 // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity: |
1960 // J Appl Physiol 92: 248–256, 2002, doi:10.1152/japplphysiol.00434.2001 | 1960 // J Appl Physiol 92: 248--256, 2002, doi:10.1152/japplphysiol.00434.2001 |
1961 // Formula (A1) based on value for 1.55 and c=20 | 1961 // Formula (A1) based on value for 1.55 and c=20 |
1962 // example calculation: Sqrt((1.7/1.55)^20)*0.000404 | 1962 // example calculation: Sqrt((1.7/1.55)^20)*0.000404 |
1963 else if (char_I_actual_ppO2 < 172) | 1963 else if (char_I_actual_ppO2 < 172) |
1964 CNS_fraction += time_factor*0.00102; | 1964 CNS_fraction += time_factor*0.00102; |
1965 else if (char_I_actual_ppO2 < 177) | 1965 else if (char_I_actual_ppO2 < 177) |
1977 else if (char_I_actual_ppO2 < 233) | 1977 else if (char_I_actual_ppO2 < 233) |
1978 CNS_fraction += time_factor*0.0209; | 1978 CNS_fraction += time_factor*0.0209; |
1979 else | 1979 else |
1980 CNS_fraction += time_factor*0.0482; // value for 2.5 | 1980 CNS_fraction += time_factor*0.0482; // value for 2.5 |
1981 | 1981 |
1982 if( CNS_fraction > 9.99) | 1982 if( CNS_fraction > 9.99) // Limit display to 999% |
1983 CNS_fraction = 9.99; | 1983 CNS_fraction = 9.99; |
1984 if( CNS_fraction < 0.0 ) | 1984 if( CNS_fraction < 0.0 ) |
1985 CNS_fraction = 0.0; | 1985 CNS_fraction = 0.0; |
1986 | 1986 |
1987 int_O_CNS_fraction = (unsigned int)(100.0 * CNS_fraction + 0.5); | 1987 int_O_CNS_fraction = (unsigned short)(100.0 * CNS_fraction + 0.5); |
1988 } | 1988 } |
1989 | 1989 |
1990 ////////////////////////////////////////////////////////////////////////////// | 1990 ////////////////////////////////////////////////////////////////////////////// |
1991 // deco_calc_CNS_planning | 1991 // deco_calc_CNS_planning |
1992 // | 1992 // |
2110 // Uses and Updates: CNS_fraction | 2110 // Uses and Updates: CNS_fraction |
2111 // | 2111 // |
2112 void deco_calc_CNS_decrease_15min(void) | 2112 void deco_calc_CNS_decrease_15min(void) |
2113 { | 2113 { |
2114 RESET_C_STACK | 2114 RESET_C_STACK |
2115 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.56 ); | 2115 assert( 0.0 <= CNS_fraction && CNS_fraction <= 9.99 ); |
2116 | 2116 |
2117 CNS_fraction = 0.890899 * CNS_fraction; | 2117 CNS_fraction = 0.890899 * CNS_fraction; |
2118 int_O_CNS_fraction = (unsigned int)(CNS_fraction * 100.0 + 0.5); | 2118 int_O_CNS_fraction = (unsigned short)(CNS_fraction * 100.0 + 0.5); |
2119 } | 2119 } |
2120 | 2120 |
2121 ////////////////////////////////////////////////////////////////////////////// | 2121 ////////////////////////////////////////////////////////////////////////////// |
2122 // deco_calc_percentage | 2122 // deco_calc_percentage |
2123 // | 2123 // |
2257 pres_tissue_He[x] = pres_tissue_He_vault[x]; | 2257 pres_tissue_He[x] = pres_tissue_He_vault[x]; |
2258 } | 2258 } |
2259 | 2259 |
2260 // Restore both CNS variable, too. | 2260 // Restore both CNS variable, too. |
2261 CNS_fraction = cns_vault; | 2261 CNS_fraction = cns_vault; |
2262 int_O_CNS_fraction = (unsigned int)(CNS_fraction * 100.0 + 0.5); | 2262 int_O_CNS_fraction = (unsigned short)(CNS_fraction * 100.0 + 0.5); |
2263 | 2263 |
2264 // GF history too: | 2264 // GF history too: |
2265 low_depth = low_depth_vault; | 2265 low_depth = low_depth_vault; |
2266 locked_GF_step = GF_delta / low_depth; | 2266 locked_GF_step = GF_delta / low_depth; |
2267 } | 2267 } |