Mercurial > public > hwos_code
comparison src/p2_deco.c @ 618:7b3903536213
work on new battery menu
author | heinrichsweikamp |
---|---|
date | Mon, 04 Feb 2019 22:57:24 +0100 |
parents | d866684249bd |
children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
617:08b28118c46b | 618:7b3903536213 |
---|---|
2716 } | 2716 } |
2717 | 2717 |
2718 ////////////////////////////////////////////////////////////////////////////// | 2718 ////////////////////////////////////////////////////////////////////////////// |
2719 // calc_limit | 2719 // calc_limit |
2720 // | 2720 // |
2721 // Input: | 2721 // Input: GF_parameter gradient factor to be used, negative values activate surface mode |
2722 // tissue_increment : selector for context: real or simulated tissues | 2722 // tissue_increment selector for context: real or simulated tissues |
2723 // sim_pres_tissue_N2/_He : tissue pressures (used in simulated tissues context) | 2723 // sim_pres_tissue_N2/_He tissue pressures (used in simulated tissues context) |
2724 // pres_tissue_N2/_He : tissue pressures (used in real tissues context) | 2724 // pres_tissue_N2/_He tissue pressures (used in real tissues context) |
2725 // | 2725 // |
2726 // Output: | 2726 // Output: lead_supersat highest supersaturation found among all tissues, 1.0 = 100% |
2727 // lead_supersat : supersaturation of the leading tissue, 1.0 = 100% | 2727 // lead_tissue number of the leading tissue (0-15) |
2728 // ceiling : ceiling in bar relative pressure | 2728 // ceiling ceiling in bar relative pressure |
2729 // | 2729 // |
2730 // Modified: | 2730 // Modified: |
2731 // char_O_deco_warnings : for IBCD, microbubbles and outside warning (only in real tissues context) | 2731 // char_O_deco_warnings for IBCD, microbubbles and outside warning (only in real tissues context) |
2732 // | 2732 // |
2733 static void calc_limit(PARAMETER float GF_parameter) | 2733 static void calc_limit(PARAMETER float GF_parameter) |
2734 { | 2734 { |
2735 overlay float lead_tissue_limit = 0.0; | 2735 overlay float lead_tissue_limit = 0.0; |
2736 | 2736 |
2742 lead_supersat = 0.0; | 2742 lead_supersat = 0.0; |
2743 | 2743 |
2744 // check context | 2744 // check context |
2745 if( tissue_increment & TISSUE_FLAG ) | 2745 if( tissue_increment & TISSUE_FLAG ) |
2746 { | 2746 { |
2747 // clear IBCD, microbubbles and outside warning flags (locked warnings will be preserved) | 2747 // clear IBCD, micro bubbles and outside warning flags (locked warnings will be preserved) |
2748 char_O_deco_warnings &= ~(DECO_WARNING_IBCD + DECO_WARNING_MBUBBLES + DECO_WARNING_OUTSIDE + DECO_ATTENTION_OUTSIDE ); | 2748 char_O_deco_warnings &= ~(DECO_WARNING_IBCD + DECO_WARNING_MBUBBLES + DECO_WARNING_OUTSIDE + DECO_ATTENTION_OUTSIDE ); |
2749 } | 2749 } |
2750 | 2750 |
2751 // loop over all tissues | 2751 // loop over all tissues |
2752 for( ci = 0; ci < NUM_COMP; ci++ ) | 2752 for( ci = 0; ci < NUM_COMP; ci++ ) |
2774 read_Buhlmann_coefficients(); | 2774 read_Buhlmann_coefficients(); |
2775 | 2775 |
2776 // adopt a and b coefficients to current N2/He ratio inside the tissue | 2776 // adopt a and b coefficients to current N2/He ratio inside the tissue |
2777 adopt_Buhlmann_coefficients(); | 2777 adopt_Buhlmann_coefficients(); |
2778 | 2778 |
2779 // calculate minimum ambient pressure that the tissue can withstand according to straight Buhlmann | |
2780 pres_min = (pres_tissue - var_N2_a) * var_N2_b; | |
2781 | |
2782 // next calculations are only relevant when invoked on the real tissues | 2779 // next calculations are only relevant when invoked on the real tissues |
2783 if( tissue_increment & TISSUE_FLAG ) | 2780 if( tissue_increment & TISSUE_FLAG ) |
2784 { | 2781 { |
2782 overlay float pres_tissue_max; | |
2785 overlay float supersat; | 2783 overlay float supersat; |
2786 overlay float baseline_threshold; | 2784 overlay float baseline_threshold; |
2787 | 2785 |
2788 // calculate current supersaturation value (1.0 = 100%) of this tissue according to straight Buhlmann | |
2789 supersat = (pres_tissue - real_pres_respiration) / (pres_tissue - pres_min); | |
2790 | |
2791 // check if tissue is in supersaturation | 2786 // check if tissue is in supersaturation |
2792 if( supersat > 0.0 ) | 2787 if( pres_tissue > real_pres_respiration ) |
2793 { | 2788 { |
2789 // calculate maximum allowed tissue pressure at current ambient pressure | |
2790 pres_tissue_max = real_pres_respiration / var_N2_b + var_N2_a; | |
2791 | |
2792 // calculate current supersaturation value (1.0 = 100%) of this tissue according to straight Buhlmann | |
2793 supersat = ( pres_tissue - real_pres_respiration ) | |
2794 / ( pres_tissue_max - real_pres_respiration ); | |
2795 | |
2794 // memorize highest supersaturation found | 2796 // memorize highest supersaturation found |
2795 if( supersat > lead_supersat ) lead_supersat = supersat; | 2797 if( supersat > lead_supersat ) lead_supersat = supersat; |
2796 | 2798 |
2797 // tissue-dependent baseline threshold for micro bubbles and outside warnings | 2799 // tissue-dependent baseline threshold for micro bubbles and outside warnings |
2798 baseline_threshold = 0.02 * ci + 1.0; | 2800 baseline_threshold = 0.02 * ci + 1.0; |
2805 if( supersat > baseline_threshold + 0.05 ) | 2807 if( supersat > baseline_threshold + 0.05 ) |
2806 char_O_deco_warnings |= (DECO_WARNING_OUTSIDE + DECO_WARNING_OUTSIDE_lock ); | 2808 char_O_deco_warnings |= (DECO_WARNING_OUTSIDE + DECO_WARNING_OUTSIDE_lock ); |
2807 } | 2809 } |
2808 } | 2810 } |
2809 | 2811 |
2810 // Apply the Eric Baker's varying gradient factor correction if the GF-Model is selected. | 2812 // calculate the minimum ambient pressure that the tissue can withstand |
2811 // Note: the correction factor depends both on GF and b, so that can change which is the | 2813 if( char_I_deco_model == 0 ) |
2812 // leading tissue... (this equation [1] is the inverse of equation [2]) | 2814 { |
2813 if( char_I_deco_model != 0 ) pres_min = ( pres_tissue - (var_N2_a * GF_parameter) ) | 2815 // straight Buhlmann |
2814 / ( 1.0 - GF_parameter + (GF_parameter / var_N2_b ) ); | 2816 pres_min = (pres_tissue - var_N2_a) * var_N2_b; |
2817 } | |
2818 else | |
2819 { | |
2820 // Buhlmann with Eric Baker's varying gradient factor correction | |
2821 // note: this equation [1] is the inverse of equation [2] | |
2822 pres_min = ( pres_tissue - (var_N2_a * GF_parameter) ) | |
2823 / ( 1.0 - GF_parameter + (GF_parameter / var_N2_b ) ); | |
2824 } | |
2815 | 2825 |
2816 // check if this tissue requires a higher ambient pressure than was found to be needed up to now | 2826 // check if this tissue requires a higher ambient pressure than was found to be needed up to now |
2817 if( pres_min > lead_tissue_limit ) | 2827 if( pres_min > lead_tissue_limit ) |
2818 { | 2828 { |
2819 lead_tissue_limit = pres_min; | 2829 lead_tissue_limit = pres_min; |
2836 // leading tissue is in IBCD condition and in super-saturation, so issue a warning | 2846 // leading tissue is in IBCD condition and in super-saturation, so issue a warning |
2837 char_O_deco_warnings |= (DECO_WARNING_IBCD + DECO_WARNING_IBCD_lock); | 2847 char_O_deco_warnings |= (DECO_WARNING_IBCD + DECO_WARNING_IBCD_lock); |
2838 } | 2848 } |
2839 } | 2849 } |
2840 } | 2850 } |
2841 | |
2842 ////////////////////////////////////////////////////////////////////////////// | 2851 ////////////////////////////////////////////////////////////////////////////// |
2843 // calc_NDL_time | 2852 // calc_NDL_time |
2844 // | 2853 // |
2845 // calculation of the remaining bottom time (NDL: no decompression limit) | 2854 // calculation of the remaining bottom time (NDL: no decompression limit) |
2846 // | 2855 // |