Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 237:55178aa1f972
Hunting for NoFly bug...
+ Asserts for NoFly range.
+ Bugfix surface pressure in simulator mode.
author | JeanDo |
---|---|
date | Sun, 20 Mar 2011 10:19:19 +0100 |
parents | 3dbeacf42e9e |
children | d995e220ddac |
comparison
equal
deleted
inserted
replaced
236:3dbeacf42e9e | 237:55178aa1f972 |
---|---|
644 //---- ZH-L16 + GRADIENT FACTOR model ------------------------------------ | 644 //---- ZH-L16 + GRADIENT FACTOR model ------------------------------------ |
645 if (char_I_deco_model == 1) | 645 if (char_I_deco_model == 1) |
646 { | 646 { |
647 // Recompute leading gas limit, at current depth: | 647 // Recompute leading gas limit, at current depth: |
648 overlay float depth = (temp_deco - pres_surface) / 0.09995; | 648 overlay float depth = (temp_deco - pres_surface) / 0.09995; |
649 assert( depth >= -0.01 ); // -epsilon tolerance. | 649 assert( depth >= -0.2 ); // Allow for 200mbar of weather change. |
650 assert( low_depth < 255 ); | 650 assert( low_depth < 255 ); |
651 | 651 |
652 if( depth > low_depth ) | 652 if( depth > low_depth ) |
653 sim_limit( GF_low ); | 653 sim_limit( GF_low ); |
654 else | 654 else |
1260 void calc_hauptroutine_update_tissues(void) | 1260 void calc_hauptroutine_update_tissues(void) |
1261 { | 1261 { |
1262 assert( 0.00 <= N2_ratio && N2_ratio <= 1.00 ); | 1262 assert( 0.00 <= N2_ratio && N2_ratio <= 1.00 ); |
1263 assert( 0.00 <= He_ratio && He_ratio <= 1.00 ); | 1263 assert( 0.00 <= He_ratio && He_ratio <= 1.00 ); |
1264 assert( (N2_ratio + He_ratio) <= 0.95 ); | 1264 assert( (N2_ratio + He_ratio) <= 0.95 ); |
1265 assert( 0.800 < pres_respiration && pres_respiration < 14.0 ); | |
1265 | 1266 |
1266 if (char_I_const_ppO2 == 0) // new in v.101 | 1267 if (char_I_const_ppO2 == 0) // new in v.101 |
1267 pres_diluent = pres_respiration; // new in v.101 | 1268 pres_diluent = pres_respiration; // new in v.101 |
1268 else | 1269 else |
1269 { | 1270 { |
1650 // Apply the Eric Baker's varying gradient factor correction. | 1651 // Apply the Eric Baker's varying gradient factor correction. |
1651 // Note: the correction factor depends both on GF and b, | 1652 // Note: the correction factor depends both on GF and b, |
1652 // Actual values are in the 1.5 .. 1.0 range (for a GF=30%), | 1653 // Actual values are in the 1.5 .. 1.0 range (for a GF=30%), |
1653 // so that can change who is the leading gas... | 1654 // so that can change who is the leading gas... |
1654 // Note: Also depends of the GF_current... | 1655 // Note: Also depends of the GF_current... |
1655 // *BUT* calc_tissue() is used to compute bottom time, | |
1656 // hence what would happend at surface, | |
1657 // hence at GF_high. | |
1658 if( char_I_deco_model == 1 ) | 1656 if( char_I_deco_model == 1 ) |
1659 p = ( p - var_N2_a * GF_current) * var_N2_b | 1657 p = ( p - var_N2_a * GF_current) * var_N2_b |
1660 / (GF_current + var_N2_b * (1.0 - GF_current)); | 1658 / (GF_current + var_N2_b * (1.0 - GF_current)); |
1661 else | 1659 else |
1662 p = (p - var_N2_a) * var_N2_b; | 1660 p = (p - var_N2_a) * var_N2_b; |
1663 if( p < 0 ) p = 0; | 1661 if( p < 0.0 ) p = 0.0; |
1664 | 1662 |
1665 sim_pres_tissue_limit[ci] = p; | 1663 sim_pres_tissue_limit[ci] = p; |
1666 if( p > sim_lead_tissue_limit ) | 1664 if( p > sim_lead_tissue_limit ) |
1667 { | 1665 { |
1668 sim_lead_tissue_no = ci; | 1666 sim_lead_tissue_no = ci; |
1669 sim_lead_tissue_limit = p; | 1667 sim_lead_tissue_limit = p; |
1670 } | 1668 } |
1671 } // for ci | 1669 } // for ci |
1672 | 1670 |
1673 assert( sim_lead_tissue_no < 16 ); | 1671 assert( sim_lead_tissue_no < 16 ); |
1674 assert( 0.0 <= sim_lead_tissue_limit && sim_lead_tissue_limit <= 14.0); | 1672 assert( 0.0 <= sim_lead_tissue_limit && sim_lead_tissue_limit <= 14.0 ); |
1675 } | 1673 } |
1676 | 1674 |
1677 ////////////////////////////////////////////////////////////////////////////// | 1675 ////////////////////////////////////////////////////////////////////////////// |
1678 // clear_deco_table | 1676 // clear_deco_table |
1679 // | 1677 // |
1742 // new code in v.102 | 1740 // new code in v.102 |
1743 // | 1741 // |
1744 static void calc_gradient_factor(void) | 1742 static void calc_gradient_factor(void) |
1745 { | 1743 { |
1746 overlay float gf; | 1744 overlay float gf; |
1745 | |
1747 assert( char_O_gtissue_no < 16 ); | 1746 assert( char_O_gtissue_no < 16 ); |
1747 assert( 0.800 <= pres_respiration && pres_respiration < 14.0 ); | |
1748 | 1748 |
1749 // tissue > respiration (entsaettigungsvorgang) | 1749 // tissue > respiration (entsaettigungsvorgang) |
1750 // gradient ist wieviel prozent an limit mit basis tissue | 1750 // gradient ist wieviel prozent an limit mit basis tissue |
1751 // dh. 0% = respiration == tissue | 1751 // dh. 0% = respiration == tissue |
1752 // dh. 100% = respiration == limit | 1752 // dh. 100% = respiration == limit |
1811 RESET_C_STACK | 1811 RESET_C_STACK |
1812 | 1812 |
1813 assert( 800 < int_I_pres_surface && int_I_pres_surface < 1100 ); | 1813 assert( 800 < int_I_pres_surface && int_I_pres_surface < 1100 ); |
1814 assert( 0 < char_I_desaturation_multiplier && char_I_desaturation_multiplier <= 100 ); | 1814 assert( 0 < char_I_desaturation_multiplier && char_I_desaturation_multiplier <= 100 ); |
1815 | 1815 |
1816 N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann | 1816 N2_ratio = 0.7902; // FIXED sum as stated in bühlmann |
1817 pres_surface = int_I_pres_surface * 0.001; | 1817 pres_surface = int_I_pres_surface * 0.001; |
1818 ppN2 = N2_ratio * (pres_surface - ppWVapour); | 1818 ppN2 = N2_ratio * (pres_surface - ppWVapour); |
1819 int_O_desaturation_time = 0; | 1819 int_O_desaturation_time = 0; |
1820 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) | 1820 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) |
1821 | 1821 |
2033 // new in v.101 | 2033 // new in v.101 |
2034 // | 2034 // |
2035 void deco_clear_CNS_fraction(void) | 2035 void deco_clear_CNS_fraction(void) |
2036 { | 2036 { |
2037 RESET_C_STACK | 2037 RESET_C_STACK |
2038 | |
2038 CNS_fraction = 0.0; | 2039 CNS_fraction = 0.0; |
2039 char_O_CNS_fraction = 0; | 2040 char_O_CNS_fraction = 0; |
2040 } | 2041 } |
2041 | 2042 |
2042 ////////////////////////////////////////////////////////////////////////////// | 2043 ////////////////////////////////////////////////////////////////////////////// |
2052 // | 2053 // |
2053 void deco_calc_CNS_fraction(void) | 2054 void deco_calc_CNS_fraction(void) |
2054 { | 2055 { |
2055 overlay float actual_ppO2; | 2056 overlay float actual_ppO2; |
2056 RESET_C_STACK | 2057 RESET_C_STACK |
2058 | |
2059 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 ); | |
2060 assert( char_I_actual_ppO2 > 15 ); | |
2057 | 2061 |
2058 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0; | 2062 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0; |
2059 | 2063 |
2060 if (char_I_actual_ppO2 < 50) | 2064 if (char_I_actual_ppO2 < 50) |
2061 CNS_fraction = CNS_fraction;// no changes | 2065 CNS_fraction = CNS_fraction;// no changes |
2113 // Output: char_O_CNS_fraction | 2117 // Output: char_O_CNS_fraction |
2114 // Uses and Updates: CNS_fraction | 2118 // Uses and Updates: CNS_fraction |
2115 // | 2119 // |
2116 void deco_calc_CNS_decrease_15min(void) | 2120 void deco_calc_CNS_decrease_15min(void) |
2117 { | 2121 { |
2118 RESET_C_STACK | 2122 RESET_C_STACK |
2123 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 ); | |
2124 | |
2119 CNS_fraction = 0.890899 * CNS_fraction; | 2125 CNS_fraction = 0.890899 * CNS_fraction; |
2120 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); | 2126 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); |
2121 } | 2127 } |
2122 | 2128 |
2123 ////////////////////////////////////////////////////////////////////////////// | 2129 ////////////////////////////////////////////////////////////////////////////// |
2132 // | 2138 // |
2133 void deco_calc_percentage(void) | 2139 void deco_calc_percentage(void) |
2134 { | 2140 { |
2135 RESET_C_STACK | 2141 RESET_C_STACK |
2136 | 2142 |
2143 assert( 60 <= char_I_temp && char_I_temp <= 100 ); | |
2144 assert( 0 <= int_I_temp && int_I_temp < 2880 ); // Less than 48h... | |
2145 | |
2137 int_I_temp = (unsigned short)(((float)int_I_temp * (float)char_I_temp) * 0.01 ); | 2146 int_I_temp = (unsigned short)(((float)int_I_temp * (float)char_I_temp) * 0.01 ); |
2147 | |
2148 assert( int_I_temp < 1440 ); // Less than 24h... | |
2138 } | 2149 } |
2139 | 2150 |
2140 | 2151 |
2141 ////////////////////////////////////////////////////////////////////////////// | 2152 ////////////////////////////////////////////////////////////////////////////// |
2142 // deco_gas_volumes | 2153 // deco_gas_volumes |