Mercurial > public > ostc4
comparison Discovery/Src/vpm.c @ 290:5e0bb91d4a12 div-fixes-6
VPM, cleanup: 1st round
Rather big cleanup. Removed numerous unused global variables, made almost
all globals and functions static, removed unused code, removed commented
core. No functional change in this commit.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
| author | Jan Mulder <jlmulder@xs4all.nl> |
|---|---|
| date | Thu, 02 May 2019 08:43:07 +0200 |
| parents | 3949781096d4 |
| children | 24ff72e627f4 |
comparison
equal
deleted
inserted
replaced
| 289:8466c994f3e6 | 290:5e0bb91d4a12 |
|---|---|
| 75 #include <stdlib.h> | 75 #include <stdlib.h> |
| 76 #include <string.h> | 76 #include <string.h> |
| 77 #include <math.h> | 77 #include <math.h> |
| 78 #include <time.h> | 78 #include <time.h> |
| 79 | 79 |
| 80 //#include "compiler.h" | |
| 81 //#include "sdramc.h" | |
| 82 #include "vpm.h" | 80 #include "vpm.h" |
| 83 //#include "buehlmann.h" | |
| 84 | |
| 85 #include "decom.h" | 81 #include "decom.h" |
| 86 | |
| 87 //#include "decompression.h" | |
| 88 //#include "taskmanagement\tissue_calls.h" | |
| 89 #define true 1 | |
| 90 #define false 0 | |
| 91 | 82 |
| 92 #define GAS_N2 0 | 83 #define GAS_N2 0 |
| 93 #define GAS_HE 1 | 84 #define GAS_HE 1 |
| 94 /* temp vars to simplify UNFMTLISTs */ | 85 |
| 95 float fO2, fHe, fN2; | 86 static const _Bool buehlmannSafety = true; |
| 96 float dc, rc, ssc; | |
| 97 short mc; | |
| 98 | |
| 99 const _Bool buehlmannSafety = true; | |
| 100 /* Common Block Declarations */ | 87 /* Common Block Declarations */ |
| 101 | 88 |
| 102 extern const float SURFACE_TENSION_GAMMA; //!Adj. Range: 0.015 to 0.065 N/m | 89 extern const float SURFACE_TENSION_GAMMA; //!Adj. Range: 0.015 to 0.065 N/m |
| 103 extern const float SKIN_COMPRESSION_GAMMAC; //!Adj. Range: 0.160 to 0.290 N/m | 90 extern const float SKIN_COMPRESSION_GAMMAC; //!Adj. Range: 0.160 to 0.290 N/m |
| 104 extern const float UNITS_FACTOR; | 91 extern const float UNITS_FACTOR; |
| 105 extern const float WATER_VAPOR_PRESSURE; // (Schreiner value) based on respiratory quotien | 92 extern const float WATER_VAPOR_PRESSURE; // (Schreiner value) based on respiratory quotien |
| 106 extern const float CRIT_VOLUME_PARAMETER_LAMBDA; //!Adj. Range: 6500 to 8300 fsw-min | 93 extern const float CRIT_VOLUME_PARAMETER_LAMBDA; //!Adj. Range: 6500 to 8300 fsw-min |
| 107 extern const float GRADIENT_ONSET_OF_IMPERM_ATM; //!Adj. Range: 5.0 to 10.0 atm | 94 //extern const float GRADIENT_ONSET_OF_IMPERM_ATM; //!Adj. Range: 5.0 to 10.0 atm |
| 108 extern const float REGENERATION_TIME_CONSTANT; //!Adj. Range: 10080 to 51840 min | 95 extern const float REGENERATION_TIME_CONSTANT; //!Adj. Range: 10080 to 51840 min |
| 109 extern const float PRESSURE_OTHER_GASES_MMHG; //!Constant value for PO2 up to 2 atm | 96 //extern const float PRESSURE_OTHER_GASES_MMHG; //!Constant value for PO2 up to 2 atm |
| 110 extern const float CONSTANT_PRESSURE_OTHER_GASES; // PRESSURE_OTHER_GASES_MMHG / 760. * UNITS_FACTOR; | 97 extern const float CONSTANT_PRESSURE_OTHER_GASES; // PRESSURE_OTHER_GASES_MMHG / 760. * UNITS_FACTOR; |
| 111 | 98 |
| 112 extern const float HELIUM_TIME_CONSTANT[]; | 99 extern const float HELIUM_TIME_CONSTANT[]; |
| 113 extern const float NITROGEN_TIME_CONSTANT[]; | 100 extern const float NITROGEN_TIME_CONSTANT[]; |
| 114 | 101 |
| 115 float minimum_deco_stop_time; | 102 static float minimum_deco_stop_time; |
| 116 float run_time, run_time_first_stop; | 103 static float run_time, run_time_first_stop; |
| 117 float segment_time; | 104 static float segment_time; |
| 118 short mix_number; | 105 static short mix_number; |
| 119 float barometric_pressure; | 106 static float barometric_pressure; |
| 120 _Bool altitude_dive_algorithm_off; | 107 static _Bool altitude_dive_algorithm_off; |
| 121 _Bool units_equal_fsw, units_equal_msw; | 108 static _Bool units_equal_fsw, units_equal_msw; |
| 122 | 109 |
| 123 /* by hw 11.06.2015 to allow */ | 110 /* by hw 11.06.2015 to allow */ |
| 124 float gCNS_VPM; | 111 static float gCNS_VPM; |
| 125 | 112 |
| 126 float helium_pressure[16], nitrogen_pressure[16]; | 113 static float helium_pressure[16], nitrogen_pressure[16]; |
| 127 //float helium_pressure_crush[16], nitrogen_pressure_crush[16]; | 114 static float surface_phase_volume_time[16]; |
| 128 //float fraction_helium[MAX_GASMIXES + EXTRA_GASMIXES], fraction_nitrogen[MAX_GASMIXES + EXTRA_GASMIXES]; | 115 static float regenerated_radius_he[16], regenerated_radius_n2[16]; |
| 129 //float initial_critical_radius_he[16], initial_critical_radius_n2[16]; | 116 static float allowable_gradient_he[16], allowable_gradient_n2[16]; |
| 130 //float adjusted_critical_radius_he[16], | |
| 131 //adjusted_critical_radius_n2[16]; | |
| 132 //float max_crushing_pressure_he[16], | |
| 133 //max_crushing_pressure_n2[16]; | |
| 134 float surface_phase_volume_time[16]; | |
| 135 //float max_actual_gradient[16]; | |
| 136 //float amb_pressure_onset_of_imperm[16], | |
| 137 //gas_tension_onset_of_imperm[16]; | |
| 138 //float initial_helium_pressure_global[16], | |
| 139 //initial_nitrogen_pressure_global[16]; | |
| 140 float regenerated_radius_he[16], | |
| 141 regenerated_radius_n2[16]; | |
| 142 //float adjusted_crushing_pressure_he[16], | |
| 143 //adjusted_crushing_pressure_n2[16]; | |
| 144 float allowable_gradient_he[16], | |
| 145 allowable_gradient_n2[16]; | |
| 146 //float initial_allowable_gradient_he[16], | |
| 147 //initial_allowable_gradient_n2[16]; | |
| 148 | 117 |
| 149 //_Bool deco_zone_reached; | 118 //_Bool deco_zone_reached; |
| 150 _Bool critical_volume_algorithm_off; | 119 static _Bool critical_volume_algorithm_off; |
| 151 float max_first_stop_depth; | 120 static float max_first_stop_depth; |
| 152 float max_deco_ceiling_depth; | 121 static float max_deco_ceiling_depth; |
| 153 long vpm_time_calc_begin = 0; | |
| 154 //Boylslaw compensation | 122 //Boylslaw compensation |
| 155 float deco_gradient_he[16]; | 123 static float deco_gradient_he[16]; |
| 156 float deco_gradient_n2[16]; | 124 static float deco_gradient_n2[16]; |
| 157 int last_nullzeit; | 125 static int vpm_calc_what; |
| 158 int vpm_calc_what; | 126 static int count_critical_volume_iteration; |
| 159 int count_critical_volume_iteration; | 127 static short number_of_changes; |
| 160 short number_of_changes; | 128 static float depth_change[11]; |
| 161 float depth_change[11]; | 129 static float step_size_change[11]; |
| 162 float step_size_change[11]; | 130 static float rate_change[11]; |
| 163 float rate_change[11]; | 131 static short mix_change[11]; |
| 164 short mix_change[11]; | 132 |
| 165 | 133 static const _Bool vpm_b = true; |
| 166 const _Bool vpm_b = true; | 134 |
| 167 | |
| 168 //extern | |
| 169 /*extern float tissue_N2_saturation[4][16]; | |
| 170 extern float tissue_He_saturation[4][16]; | |
| 171 extern long dv_divetime; | |
| 172 extern dive_data_t dive_data; | |
| 173 extern int dive_ambient_pressure_mbar; | |
| 174 extern long dv_seconds_since_last_dive; | |
| 175 extern int tts[4];*/ | |
| 176 extern const float float_buehlmann_N2_factor_expositon_20_seconds[]; | 135 extern const float float_buehlmann_N2_factor_expositon_20_seconds[]; |
| 177 extern const float float_buehlmann_He_factor_expositon_20_seconds[]; | 136 extern const float float_buehlmann_He_factor_expositon_20_seconds[]; |
| 178 extern const float float_buehlmann_N2_factor_expositon_one_minute[]; | 137 extern const float float_buehlmann_N2_factor_expositon_one_minute[]; |
| 179 extern const float float_buehlmann_He_factor_expositon_one_minute[]; | 138 extern const float float_buehlmann_He_factor_expositon_one_minute[]; |
| 180 extern const float float_buehlmann_N2_factor_expositon_five_minutes[]; | 139 extern const float float_buehlmann_N2_factor_expositon_five_minutes[]; |
| 181 extern const float float_buehlmann_He_factor_expositon_five_minutes[]; | 140 extern const float float_buehlmann_He_factor_expositon_five_minutes[]; |
| 182 extern const float float_buehlmann_N2_factor_expositon_one_hour[]; | 141 extern const float float_buehlmann_N2_factor_expositon_one_hour[]; |
| 183 extern const float float_buehlmann_He_factor_expositon_one_hour[]; | 142 extern const float float_buehlmann_He_factor_expositon_one_hour[]; |
| 184 | 143 |
| 185 //extern buehlmann_configuration_t buehlmann_config; | 144 static float depth_start_of_deco_calc; |
| 186 | 145 static float depth_start_of_deco_zone; |
| 187 extern unsigned char CCR_mode; //0x100 // by tissue_calls.c // uchar | 146 static float first_stop_depth; |
| 188 | 147 static float run_time_start_of_deco_zone; |
| 189 //extern gaschange2_t gaschange_CCR_backup[2][BUEHLMANN_STRUCT_MAX_GASES]; | 148 |
| 190 | 149 static float r_nint(float *x); |
| 191 | 150 static float r_int(float *x); |
| 192 float starting_ambient_pressure_global; | 151 static _Bool nullzeit_unter60; |
| 193 float ending_ambient_pressure_global; | 152 static int vpm_calc_status; |
| 194 float depth_start_of_deco_calc; | 153 static _Bool buehlmann_wait_exceeded = false; |
| 195 float depth_start_of_deco_zone; | 154 |
| 196 float first_stop_depth; | 155 static SLifeData* pInput = NULL; |
| 197 float run_time_start_of_deco_zone; | 156 static SVpm* pVpm = NULL; |
| 198 | 157 static SDecoinfo* pDecoInfo = NULL; |
| 199 float r_nint(float *x); | 158 static SDiveSettings* pDiveSettings = NULL; |
| 200 float r_int(float *x); | 159 |
| 201 _Bool repetitive_variables_not_valid = false; | 160 static float r_nint(float *x) |
| 202 _Bool nullzeit_unter60; | |
| 203 //enum VPM_CALC_STATUS{CALC_END,CALC_BEGIN,CALC_NULLZEIT }; | |
| 204 int vpm_calc_status; | |
| 205 _Bool buehlmann_wait_exceeded = false; | |
| 206 | |
| 207 SLifeData* pInput = NULL; | |
| 208 SVpm* pVpm = NULL; | |
| 209 SDecoinfo* pDecoInfo = NULL; | |
| 210 SDiveSettings* pDiveSettings = NULL; | |
| 211 float r_nint(float *x) | |
| 212 { | 161 { |
| 213 return( (*x)>=0 ? | 162 return( (*x)>=0 ? |
| 214 floorf(*x + 0.5f) : -floorf(0.5f - *x) ); | 163 floorf(*x + 0.5f) : -floorf(0.5f - *x) ); |
| 215 } | 164 } |
| 216 | 165 |
| 217 float r_int(float *x) | 166 static float r_int(float *x) |
| 218 { | 167 { |
| 219 return( (*x>0) ? floorf(*x) : -floorf(- *x) ); | 168 return( (*x>0) ? floorf(*x) : -floorf(- *x) ); |
| 220 } | 169 } |
| 221 | 170 |
| 222 /** private functions | 171 /** private functions |
| 223 */ | 172 */ |
| 224 int onset_of_impermeability(float *starting_ambient_pressure, float *ending_ambient_pressure, float *rate, short *i); | 173 extern int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius); |
| 225 int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius); | 174 |
| 226 int nuclear_regeneration(float *dive_time);// clock_(); | 175 static int nuclear_regeneration(float *dive_time);// clock_(); |
| 227 int calc_deco_ceiling(float *deco_ceiling_depth,_Bool fallowablw); | 176 static int calc_deco_ceiling(float *deco_ceiling_depth,_Bool fallowablw); |
| 228 | 177 static int critical_volume(float *deco_phase_volume_time); ; |
| 229 int calc_barometric_pressure(float *altitude); | 178 static int calc_start_of_deco_zone(float *starting_depth, float *rate, float *depth_start_of_deco_zone); |
| 230 //extern /* Subroutine */ int vpm_repetitive_algorithm(); | 179 static int calc_initial_allowable_gradient(void); |
| 231 //extern /* Subroutine */ int gas_loadings_surface_interval(); | 180 static void decompression_stop(float *deco_stop_depth, float *step_size, _Bool final_deco_calculation); |
| 232 int critical_volume(float *deco_phase_volume_time); ; | 181 static int gas_loadings_ascent_descen(float* helium_pressure, float* nitrogen_pressure, float starting_depth,float ending_depth, float rate,_Bool check_gas_change); |
| 233 int calc_start_of_deco_zone(float *starting_depth, float *rate, float *depth_start_of_deco_zone); | 182 static int calc_surface_phase_volume_time(void); |
| 234 | 183 static int calc_max_actual_gradient(float *deco_stop_depth); |
| 235 int calc_initial_allowable_gradient(void); | 184 static int projected_ascent(float *starting_depth, float *rate, float *deco_stop_depth, float *step_size); |
| 236 void decompression_stop(float *deco_stop_depth, float *step_size, _Bool final_deco_calculation); | 185 static void vpm_calc_deco(void); |
| 237 int gas_loadings_ascent_descen(float* helium_pressure, float* nitrogen_pressure, float starting_depth,float ending_depth, float rate,_Bool check_gas_change); | 186 static int vpm_calc_critcal_volume(_Bool begin,_Bool calc_nulltime); |
| 238 | 187 static int vpm_check_converged(_Bool calc_nulltime); |
| 239 int calc_surface_phase_volume_time(void); | 188 static int vpm_calc_final_deco(_Bool begin); |
| 240 int calc_max_actual_gradient(float *deco_stop_depth); | 189 static void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth,float * Deco_Stop_Depth,float* Step_Size); |
| 241 int projected_ascent(float *starting_depth, float *rate, float *deco_stop_depth, float *step_size); | 190 static int vpm_calc_nullzeit(void); |
| 242 void vpm_calc_deco(void); | 191 static void vpm_init_1(void); |
| 243 int vpm_calc_critcal_volume(_Bool begin,_Bool calc_nulltime); | 192 static void vpm_calc_deco_ceiling(void); |
| 244 int vpm_check_converged(_Bool calc_nulltime); | 193 |
| 245 int vpm_calc_final_deco(_Bool begin); | 194 static void vpm_init_1(void) |
| 246 void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth,float * Deco_Stop_Depth,float* Step_Size); | |
| 247 int vpm_calc_nullzeit(void); | |
| 248 int vpm_repetitive_algorithm(float *surface_interval_time); | |
| 249 void vpm_init_1(void); | |
| 250 | |
| 251 void vpm_calc_deco_ceiling(void); | |
| 252 | |
| 253 //extern /* Subroutine */ int gas_loadings_constant_depth(); | |
| 254 //extern /* Subroutine */ int vpm_altitude_dive_algorithm(); | |
| 255 //extern /* Subroutine */ int calc_max_actual_gradient(), | |
| 256 //projected_ascent(); | |
| 257 | |
| 258 void ______X_X_X___________________________________________________________(void); | |
| 259 | |
| 260 //#define ARGGG | |
| 261 | |
| 262 void vpm_reset_variables(void) | |
| 263 { | |
| 264 repetitive_variables_not_valid = true; | |
| 265 } | |
| 266 | |
| 267 void vpm_init_1(void) | |
| 268 { | 195 { |
| 269 units_equal_msw = true; | 196 units_equal_msw = true; |
| 270 units_equal_fsw = false; | 197 units_equal_fsw = false; |
| 271 altitude_dive_algorithm_off= true; //!Options: ON or OFF | 198 altitude_dive_algorithm_off= true; //!Options: ON or OFF |
| 272 minimum_deco_stop_time=1.0; //!Options: float positive number | 199 minimum_deco_stop_time=1.0; //!Options: float positive number |
| 387 /* Purpose: This subprogram applies the Schreiner equation to update the */ | 314 /* Purpose: This subprogram applies the Schreiner equation to update the */ |
| 388 /* gas loadings (partial pressures of helium and nitrogen) in the half-time */ | 315 /* gas loadings (partial pressures of helium and nitrogen) in the half-time */ |
| 389 /* compartments due to a linear ascent or descent segment at a constant rate. */ | 316 /* compartments due to a linear ascent or descent segment at a constant rate. */ |
| 390 /* =============================================================================== */ | 317 /* =============================================================================== */ |
| 391 | 318 |
| 392 int gas_loadings_ascent_descen(float* helium_pressure, | 319 static int gas_loadings_ascent_descen(float* helium_pressure, |
| 393 float* nitrogen_pressure, | 320 float* nitrogen_pressure, |
| 394 float starting_depth, | 321 float starting_depth, |
| 395 float ending_depth, | 322 float ending_depth, |
| 396 float rate,_Bool check_gas_change) | 323 float rate,_Bool check_gas_change) |
| 397 { | 324 { |
| 478 } while(ending_depth_tmp > ending_depth); | 405 } while(ending_depth_tmp > ending_depth); |
| 479 | 406 |
| 480 return 0; | 407 return 0; |
| 481 } /* gas_loadings_ascent_descen */ | 408 } /* gas_loadings_ascent_descen */ |
| 482 | 409 |
| 483 float last_phase_volume_time[16]; | 410 static float last_phase_volume_time[16]; |
| 484 float n2_pressure_start_of_deco_zone[16]; | 411 static float n2_pressure_start_of_deco_zone[16]; |
| 485 float he_pressure_start_of_deco_zone[16]; | 412 static float he_pressure_start_of_deco_zone[16]; |
| 486 float phase_volume_time[16]; | 413 static float phase_volume_time[16]; |
| 487 float n2_pressure_start_of_ascent[16]; | 414 static float n2_pressure_start_of_ascent[16]; |
| 488 float he_pressure_start_of_ascent[16]; | 415 static float he_pressure_start_of_ascent[16]; |
| 489 float run_time_start_of_deco_calc; | 416 static float run_time_start_of_deco_calc; |
| 490 float starting_depth; | 417 static float starting_depth; |
| 491 float last_run_time; | 418 static float last_run_time; |
| 492 float deco_phase_volume_time; | 419 static float deco_phase_volume_time; |
| 493 | 420 static float run_time_start_of_ascent; |
| 494 float run_time_start_of_ascent; | 421 static float rate; |
| 495 | 422 static float step_size; |
| 496 float rate; | 423 static _Bool vpm_violates_buehlmann; |
| 497 float step_size; | 424 |
| 498 _Bool vpm_violates_buehlmann; | 425 static void vpm_calc_deco(void) |
| 499 | |
| 500 void vpm_calc_deco(void) | |
| 501 { | 426 { |
| 502 /* System generated locals */ | 427 /* System generated locals */ |
| 503 | 428 |
| 504 //float deepest_possible_stop_depth; | 429 //float deepest_possible_stop_depth; |
| 505 // altitude_of_dive, | 430 // altitude_of_dive, |
| 660 /* settings (default setting is 7500 fsw-min with adjustability range from */ | 585 /* settings (default setting is 7500 fsw-min with adjustability range from */ |
| 661 /* from 6500 to 8300 fsw-min according to Bruce Wienke). */ | 586 /* from 6500 to 8300 fsw-min according to Bruce Wienke). */ |
| 662 /* =============================================================================== */ | 587 /* =============================================================================== */ |
| 663 /* L50: */ | 588 /* L50: */ |
| 664 | 589 |
| 665 float deco_stop_depth; | 590 static float deco_stop_depth; |
| 666 int vpm_calc_critcal_volume(_Bool begin, | 591 static int vpm_calc_critcal_volume(_Bool begin, |
| 667 _Bool calc_nulltime) | 592 _Bool calc_nulltime) |
| 668 { /* loop will run continuous there is an exit stateme */ | 593 { /* loop will run continuous there is an exit stateme */ |
| 669 | 594 |
| 670 short i; | 595 short i; |
| 671 | 596 |
| 765 for(dp = 0;dp < DECOINFO_STRUCT_MAX_STOPS;dp++) | 690 for(dp = 0;dp < DECOINFO_STRUCT_MAX_STOPS;dp++) |
| 766 { | 691 { |
| 767 pDecoInfo->output_stop_length_seconds[dp] = 0; | 692 pDecoInfo->output_stop_length_seconds[dp] = 0; |
| 768 } | 693 } |
| 769 pDecoInfo->output_ndl_seconds = 0; | 694 pDecoInfo->output_ndl_seconds = 0; |
| 770 /*max_first_stop_depth = 0; | |
| 771 deco_zone_reached = false; | |
| 772 depth_start_of_deco_calc = 0; | |
| 773 depth_start_of_deco_zone = 0; | |
| 774 first_stop_depth = 0; | |
| 775 max_first_stop_depth_save = 0; | |
| 776 depth_start_of_deco_zone_save = 0; | |
| 777 run_time_start_of_deco_zone_save = 0; | |
| 778 tts[DECOSTOPS] = 0; | |
| 779 tts[NULLZEIT] = 0; | |
| 780 tts[FUTURESTOPS] = 0; | |
| 781 nullzeit_unter60 = false; | |
| 782 vpm_calc_status = CALC_NULLZEIT; | |
| 783 vpm_calc_what = DECOSTOPS; | |
| 784 float surfacetime = 0; | |
| 785 vpm_repetitive_algorithm(&surfacetime);*/ | |
| 786 | |
| 787 } | 695 } |
| 788 | 696 |
| 789 return CALC_NULLZEIT; | 697 return CALC_NULLZEIT; |
| 790 /* exit the critical volume l */ | 698 /* exit the critical volume l */ |
| 791 } | 699 } |
| 876 /* by the excess bubble number to represent the amount of free-gas released */ | 784 /* by the excess bubble number to represent the amount of free-gas released */ |
| 877 /* as a result of allowing a certain number of excess bubbles to form. */ | 785 /* as a result of allowing a certain number of excess bubbles to form. */ |
| 878 /* =============================================================================== */ | 786 /* =============================================================================== */ |
| 879 /* end of deco stop loop */ | 787 /* end of deco stop loop */ |
| 880 | 788 |
| 881 int vpm_check_converged(_Bool calc_nulltime) | 789 static int vpm_check_converged(_Bool calc_nulltime) |
| 882 { | 790 { |
| 883 | 791 |
| 884 short i; | 792 short i; |
| 885 float critical_volume_comparison; | 793 float critical_volume_comparison; |
| 886 float r1; | 794 float r1; |
| 973 /* end of critical volume decision */ | 881 /* end of critical volume decision */ |
| 974 /* L100: */ | 882 /* L100: */ |
| 975 // }/* end of critical vol loop */ | 883 // }/* end of critical vol loop */ |
| 976 } | 884 } |
| 977 | 885 |
| 978 void vpm_calc_deco_ceiling(void) | 886 static void vpm_calc_deco_ceiling(void) |
| 979 { | 887 { |
| 980 | 888 |
| 981 short i; | 889 short i; |
| 982 // hw 1601209 float r1; | 890 // hw 1601209 float r1; |
| 983 // hw 1601209 float stop_time; | 891 // hw 1601209 float stop_time; |
| 1086 | 994 |
| 1087 /* =============================================================================== */ | 995 /* =============================================================================== */ |
| 1088 /* DECO STOP LOOP BLOCK FOR FINAL DECOMPRESSION SCHEDULE */ | 996 /* DECO STOP LOOP BLOCK FOR FINAL DECOMPRESSION SCHEDULE */ |
| 1089 /* =============================================================================== */ | 997 /* =============================================================================== */ |
| 1090 | 998 |
| 1091 int vpm_calc_final_deco(_Bool begin) | 999 static int vpm_calc_final_deco(_Bool begin) |
| 1092 { | 1000 { |
| 1093 short i; | 1001 short i; |
| 1094 float r1; | 1002 float r1; |
| 1095 float stop_time; | 1003 float stop_time; |
| 1096 int count = 0; | 1004 int count = 0; |
| 1262 /* radii that takes place over the dive time. The regeneration time constant */ | 1170 /* radii that takes place over the dive time. The regeneration time constant */ |
| 1263 /* has a time scale of weeks so this will have very little impact on dives of */ | 1171 /* has a time scale of weeks so this will have very little impact on dives of */ |
| 1264 /* normal length, but will have a major impact for saturation dives. */ | 1172 /* normal length, but will have a major impact for saturation dives. */ |
| 1265 /* =============================================================================== */ | 1173 /* =============================================================================== */ |
| 1266 | 1174 |
| 1267 int nuclear_regeneration(float *dive_time) | 1175 static int nuclear_regeneration(float *dive_time) |
| 1268 { | 1176 { |
| 1269 /* Local variables */ | 1177 /* Local variables */ |
| 1270 float crush_pressure_adjust_ratio_he, | 1178 float crush_pressure_adjust_ratio_he, |
| 1271 ending_radius_n2, | 1179 ending_radius_n2, |
| 1272 ending_radius_he; | 1180 ending_radius_he; |
| 1371 /* The initial allowable gradients are computed directly from the */ | 1279 /* The initial allowable gradients are computed directly from the */ |
| 1372 /* "regenerated" radii after the Nuclear Regeneration subroutine. These */ | 1280 /* "regenerated" radii after the Nuclear Regeneration subroutine. These */ |
| 1373 /* gradients are tracked separately for helium and nitrogen. */ | 1281 /* gradients are tracked separately for helium and nitrogen. */ |
| 1374 /* =============================================================================== */ | 1282 /* =============================================================================== */ |
| 1375 | 1283 |
| 1376 int calc_initial_allowable_gradient() | 1284 static int calc_initial_allowable_gradient() |
| 1377 { | 1285 { |
| 1378 float initial_allowable_grad_n2_pa, | 1286 float initial_allowable_grad_n2_pa, |
| 1379 initial_allowable_grad_he_pa; | 1287 initial_allowable_grad_he_pa; |
| 1380 short i; | 1288 short i; |
| 1381 | 1289 |
| 1426 /* finds the deepest deco ceiling across all compartments. This deepest */ | 1334 /* finds the deepest deco ceiling across all compartments. This deepest */ |
| 1427 /* value (Deco Ceiling Depth) is then used by the Decompression Stop */ | 1335 /* value (Deco Ceiling Depth) is then used by the Decompression Stop */ |
| 1428 /* subroutine to determine the actual deco schedule. */ | 1336 /* subroutine to determine the actual deco schedule. */ |
| 1429 /* =============================================================================== */ | 1337 /* =============================================================================== */ |
| 1430 | 1338 |
| 1431 int calc_deco_ceiling(float *deco_ceiling_depth,_Bool fallowable) | 1339 static int calc_deco_ceiling(float *deco_ceiling_depth,_Bool fallowable) |
| 1432 { | 1340 { |
| 1433 /* System generated locals */ | 1341 /* System generated locals */ |
| 1434 float r1, r2; | 1342 float r1, r2; |
| 1435 /* Local variables */ | 1343 /* Local variables */ |
| 1436 float weighted_allowable_gradient; | 1344 float weighted_allowable_gradient; |
| 1553 /* repetitive dive to compensate for the bubbling that was allowed on the */ | 1461 /* repetitive dive to compensate for the bubbling that was allowed on the */ |
| 1554 /* previous dive. The use of the max actual gradients is intended to prevent */ | 1462 /* previous dive. The use of the max actual gradients is intended to prevent */ |
| 1555 /* the repetitive algorithm from being overly conservative. */ | 1463 /* the repetitive algorithm from being overly conservative. */ |
| 1556 /* =============================================================================== */ | 1464 /* =============================================================================== */ |
| 1557 | 1465 |
| 1558 int calc_max_actual_gradient(float *deco_stop_depth) | 1466 static int calc_max_actual_gradient(float *deco_stop_depth) |
| 1559 { | 1467 { |
| 1560 /* System generated locals */ | 1468 /* System generated locals */ |
| 1561 float r1; | 1469 float r1; |
| 1562 | 1470 |
| 1563 /* Local variables */ | 1471 /* Local variables */ |
| 1600 /* computes the time course of supersaturation gradients on the surface */ | 1508 /* computes the time course of supersaturation gradients on the surface */ |
| 1601 /* when both helium and nitrogen are present. Refer to separate write-up */ | 1509 /* when both helium and nitrogen are present. Refer to separate write-up */ |
| 1602 /* for a more detailed explanation of this algorithm. */ | 1510 /* for a more detailed explanation of this algorithm. */ |
| 1603 /* =============================================================================== */ | 1511 /* =============================================================================== */ |
| 1604 | 1512 |
| 1605 int calc_surface_phase_volume_time() | 1513 static int calc_surface_phase_volume_time() |
| 1606 { | 1514 { |
| 1607 /* Local variables */ | 1515 /* Local variables */ |
| 1608 float decay_time_to_zero_gradient; | 1516 float decay_time_to_zero_gradient; |
| 1609 short i; | 1517 short i; |
| 1610 float integral_gradient_x_time, | 1518 float integral_gradient_x_time, |
| 1660 /* Purpose: This subprogram applies the VPM Critical Volume Algorithm. This */ | 1568 /* Purpose: This subprogram applies the VPM Critical Volume Algorithm. This */ |
| 1661 /* algorithm will compute "relaxed" gradients for helium and nitrogen based */ | 1569 /* algorithm will compute "relaxed" gradients for helium and nitrogen based */ |
| 1662 /* on the setting of the Critical Volume Parameter Lambda. */ | 1570 /* on the setting of the Critical Volume Parameter Lambda. */ |
| 1663 /* =============================================================================== */ | 1571 /* =============================================================================== */ |
| 1664 | 1572 |
| 1665 int critical_volume(float *deco_phase_volume_time) | 1573 static int critical_volume(float *deco_phase_volume_time) |
| 1666 { | 1574 { |
| 1667 /* System generated locals */ | 1575 /* System generated locals */ |
| 1668 float r1; | 1576 float r1; |
| 1669 | 1577 |
| 1670 /* Local variables */ | 1578 /* Local variables */ |
| 1776 /* which the leading compartment just enters the decompression zone. */ | 1684 /* which the leading compartment just enters the decompression zone. */ |
| 1777 /* Source: "Numerical Recipes in Fortran 77", Cambridge University Press, */ | 1685 /* Source: "Numerical Recipes in Fortran 77", Cambridge University Press, */ |
| 1778 /* 1992. */ | 1686 /* 1992. */ |
| 1779 /* =============================================================================== */ | 1687 /* =============================================================================== */ |
| 1780 | 1688 |
| 1781 int calc_start_of_deco_zone(float *starting_depth, | 1689 static int calc_start_of_deco_zone(float *starting_depth, |
| 1782 float *rate, | 1690 float *rate, |
| 1783 float *depth_start_of_deco_zone) | 1691 float *depth_start_of_deco_zone) |
| 1784 { | 1692 { |
| 1785 /* Local variables */ | 1693 /* Local variables */ |
| 1786 float last_diff_change, | 1694 float last_diff_change, |
| 1975 /* gas loading during ascent (on-gassing). If the deco ceiling is violated, */ | 1883 /* gas loading during ascent (on-gassing). If the deco ceiling is violated, */ |
| 1976 /* the stop depth will be adjusted deeper by the step size until a safe */ | 1884 /* the stop depth will be adjusted deeper by the step size until a safe */ |
| 1977 /* ascent can be made. */ | 1885 /* ascent can be made. */ |
| 1978 /* =============================================================================== */ | 1886 /* =============================================================================== */ |
| 1979 | 1887 |
| 1980 int projected_ascent(float *starting_depth, | 1888 static int projected_ascent(float *starting_depth, |
| 1981 float *rate, | 1889 float *rate, |
| 1982 float *deco_stop_depth, | 1890 float *deco_stop_depth, |
| 1983 float *step_size) | 1891 float *step_size) |
| 1984 { | 1892 { |
| 1985 /* Local variables */ | 1893 /* Local variables */ |
| 2044 /* SUBROUTINE DECOMPRESSION_STOP */ | 1952 /* SUBROUTINE DECOMPRESSION_STOP */ |
| 2045 /* Purpose: This subprogram calculates the required time at each */ | 1953 /* Purpose: This subprogram calculates the required time at each */ |
| 2046 /* decompression stop. */ | 1954 /* decompression stop. */ |
| 2047 /* =============================================================================== */ | 1955 /* =============================================================================== */ |
| 2048 | 1956 |
| 2049 void decompression_stop(float *deco_stop_depth, | 1957 static void decompression_stop(float *deco_stop_depth, |
| 2050 float *step_size, | 1958 float *step_size, |
| 2051 _Bool final_deco_calculation) | 1959 _Bool final_deco_calculation) |
| 2052 { | 1960 { |
| 2053 /* Local variables */ | 1961 /* Local variables */ |
| 2054 float inspired_nitrogen_pressure; | 1962 float inspired_nitrogen_pressure; |
| 2266 // SUROUTINE BOYLES_LAW_COMPENSATION | 2174 // SUROUTINE BOYLES_LAW_COMPENSATION |
| 2267 // Purpose: This subprogram calculates the reduction in allowable gradients | 2175 // Purpose: This subprogram calculates the reduction in allowable gradients |
| 2268 // with decreasing ambient pressure during the decompression profile based | 2176 // with decreasing ambient pressure during the decompression profile based |
| 2269 // on Boyle's Law considerations. | 2177 // on Boyle's Law considerations. |
| 2270 //=============================================================================== | 2178 //=============================================================================== |
| 2271 void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth, | 2179 static void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth, |
| 2272 float* Deco_Stop_Depth, | 2180 float* Deco_Stop_Depth, |
| 2273 float* Step_Size) | 2181 float* Step_Size) |
| 2274 { | 2182 { |
| 2275 short i; | 2183 short i; |
| 2276 | 2184 |
| 2368 | 2276 |
| 2369 /* =============================================================================== */ | 2277 /* =============================================================================== */ |
| 2370 // vpm_calc_nullzeit | 2278 // vpm_calc_nullzeit |
| 2371 // Purpose: This function calcs zero time (time where no decostops are needed) | 2279 // Purpose: This function calcs zero time (time where no decostops are needed) |
| 2372 //=============================================================================== | 2280 //=============================================================================== |
| 2373 int vpm_calc_nullzeit(void) | 2281 static int vpm_calc_nullzeit(void) |
| 2374 { | 2282 { |
| 2375 static float future_helium_pressure[16]; | 2283 static float future_helium_pressure[16]; |
| 2376 static float future_nitrogen_pressure[16]; | 2284 static float future_nitrogen_pressure[16]; |
| 2377 static int temp_segment_time; | 2285 static int temp_segment_time; |
| 2378 static int mix_number; | 2286 static int mix_number; |
