comparison src/p2_deco.c @ 585:00ad4ffd915b

CNS Fix2
author heinrichsweikamp
date Wed, 28 Feb 2018 16:24:18 +0100
parents d63dec562d50
children e81cf407261a
comparison
equal deleted inserted replaced
584:d63dec562d50 585:00ad4ffd915b
1 // *************************************************************************** 1 // ***************************************************************************
2 // p2_deco.c REFACTORED VERSION V2.98 2 // p2_deco.c REFACTORED VERSION V2.98+
3 // 3 //
4 // Created on: 12.05.2009 4 // Created on: 12.05.2009
5 // Author: heinrichs weikamp, contributions by Ralph Lembcke and others 5 // Author: heinrichs weikamp, contributions by Ralph Lembcke and others
6 // 6 //
7 // *************************************************************************** 7 // ***************************************************************************
1822 // check which plan we are on 1822 // check which plan we are on
1823 if( char_O_deco_status & DECO_PLAN_ALTERNATE ) 1823 if( char_O_deco_status & DECO_PLAN_ALTERNATE )
1824 { 1824 {
1825 //---- alternative plan ---------------------------------------------------- 1825 //---- alternative plan ----------------------------------------------------
1826 1826
1827 // clear NDL time
1828 char_O_alternate_nullzeit = 0;
1829
1830 // output ascent time
1831 int_O_alternate_ascenttime = ascent_time;
1832
1827 // shall the CNS at the end of the dive be calculated? 1833 // shall the CNS at the end of the dive be calculated?
1828 if( char_O_deco_status & DECO_CNS_CALCULATE ) 1834 if( char_O_deco_status & DECO_CNS_CALCULATE )
1829 { 1835 {
1830 // calculate the CNS for the predicted ascent, result in sim_CNS_fraction 1836 // calculate the CNS for the predicted ascent, result in sim_CNS_fraction
1831 calc_CNS_planning(); 1837 calc_CNS_planning();
1838 1844
1839 // export result 1845 // export result
1840 int_O_alternate_CNS_fraction = int_sim_CNS_fraction; 1846 int_O_alternate_CNS_fraction = int_sim_CNS_fraction;
1841 } 1847 }
1842 1848
1843 // clear NDL time
1844 char_O_alternate_nullzeit = 0;
1845
1846 // output ascent time
1847 int_O_alternate_ascenttime = ascent_time;
1848
1849 } // alternative plan 1849 } // alternative plan
1850 else 1850 else
1851 { 1851 {
1852 //---- normal plan --------------------------------------------------------- 1852 //---- normal plan ---------------------------------------------------------
1853
1854 // clear NDL time
1855 char_O_nullzeit = 0;
1856
1857 // output ascent time
1858 int_O_ascenttime = ascent_time;
1853 1859
1854 // shall the CNS at the end of the dive be calculated? 1860 // shall the CNS at the end of the dive be calculated?
1855 if( char_O_deco_status & DECO_CNS_CALCULATE ) 1861 if( char_O_deco_status & DECO_CNS_CALCULATE )
1856 { 1862 {
1857 // calculate the CNS for the predicted ascent, result in sim_CNS_fraction 1863 // calculate the CNS for the predicted ascent, result in sim_CNS_fraction
1864 convert_sim_CNS_for_display(); 1870 convert_sim_CNS_for_display();
1865 1871
1866 // export result 1872 // export result
1867 int_O_normal_CNS_fraction = int_sim_CNS_fraction; 1873 int_O_normal_CNS_fraction = int_sim_CNS_fraction;
1868 } 1874 }
1869
1870 // clear NDL time
1871 char_O_nullzeit = 0;
1872
1873 // output ascent time
1874 int_O_ascenttime = ascent_time;
1875 1875
1876 } // normal plan 1876 } // normal plan
1877 } // DECO 1877 } // DECO
1878 1878
1879 // if requested, calculate the required gas volumes and tank pressures at the end of the dive 1879 // if requested, calculate the required gas volumes and tank pressures at the end of the dive
3127 // adjust time factor if minute-based stepping is commanded, mask out flag bit 3127 // adjust time factor if minute-based stepping is commanded, mask out flag bit
3128 if( tissue_increment & TIME_MASK ) time_factor = 30.0 * (float)(tissue_increment & TIME_MASK); 3128 if( tissue_increment & TIME_MASK ) time_factor = 30.0 * (float)(tissue_increment & TIME_MASK);
3129 3129
3130 //------------------------------------------------------------------------ 3130 //------------------------------------------------------------------------
3131 // Don't increase CNS below 0.5 bar, but keep it steady. 3131 // Don't increase CNS below 0.5 bar, but keep it steady.
3132 if (char_ppO2 < 50) CNS_fraction_inc = 0; // no CNS increase below 0.5 bar ppO2 3132 if (char_ppO2 < 50) CNS_fraction_inc = 0.0; // no CNS increase below 0.5 bar ppO2
3133 //------------------------------------------------------------------------ 3133 //------------------------------------------------------------------------
3134 // Below (and including) 1.60 bar 3134 // Below (and including) 1.60 bar
3135 else if (char_ppO2 < 61) CNS_fraction_inc = time_factor/(-533.07 * char_ppO2 + 54000.0); 3135 else if (char_ppO2 < 61) CNS_fraction_inc = time_factor/(-533.07 * char_ppO2 + 54000.0);
3136 else if (char_ppO2 < 71) CNS_fraction_inc = time_factor/(-444.22 * char_ppO2 + 48600.0); 3136 else if (char_ppO2 < 71) CNS_fraction_inc = time_factor/(-444.22 * char_ppO2 + 48600.0);
3137 else if (char_ppO2 < 81) CNS_fraction_inc = time_factor/(-355.38 * char_ppO2 + 42300.0); 3137 else if (char_ppO2 < 81) CNS_fraction_inc = time_factor/(-355.38 * char_ppO2 + 42300.0);
3183 tissue_increment = char_I_extra_time; // must be limited to 127, is limited by range of char_I_extra_time 3183 tissue_increment = char_I_extra_time; // must be limited to 127, is limited by range of char_I_extra_time
3184 calc_CNS_increment(); // calculate the CNS increment 3184 calc_CNS_increment(); // calculate the CNS increment
3185 sim_CNS_fraction += CNS_fraction_inc; // sum up 3185 sim_CNS_fraction += CNS_fraction_inc; // sum up
3186 } 3186 }
3187 3187
3188 // get the ascent time dependent on the current plan 3188 // get the ascent time dependent on the current plan +++
3189 t = (char_O_deco_status & DECO_PLAN_ALTERNATE) ? int_O_alternate_ascenttime : int_O_ascenttime; 3189 t = (char_O_deco_status & DECO_PLAN_ALTERNATE) ? int_O_alternate_ascenttime : int_O_ascenttime;
3190 3190
3191 // start simulating CNS% in chunks of 127 minutes 3191 // start simulating CNS% in chunks of 127 minutes
3192 tissue_increment = 127; 3192 tissue_increment = 127;
3193 3193