annotate Common/Src/calc_crush.c @ 677:1953cd9145b3 Betatest

Move include file to common to ... ... get things compiled. The configuration.h file is also used from the RTE code, so it should be in the Common tree. Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author Jan Mulder <jan@jlmulder.nl>
date Wed, 20 Apr 2022 20:25:04 +0200
parents 8f8ea3a32e82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Common/Src/calc_crush.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief VPM Desaturation code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author Heinrichs Weikamp
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 2018
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 #include "calc_crush.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "math.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "vpm.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 /* Common Block Declarations */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 //#pragma warning(disable:1035)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 const float SURFACE_TENSION_GAMMA = 0.0179f; //!Adj. Range: 0.015 to 0.065 N/m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 const float SKIN_COMPRESSION_GAMMAC = 0.257f; //!Adj. Range: 0.160 to 0.290 N/m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 const float UNITS_FACTOR = 10.1325f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 const float WATER_VAPOR_PRESSURE = 0.493f; // (Schreiner value) based on respiratory quotien
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 const float CRIT_VOLUME_PARAMETER_LAMBDA = 7500.0f; //!Adj. Range: 6500 to 8300 fsw-min
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 const float GRADIENT_ONSET_OF_IMPERM_ATM = 8.2f; //!Adj. Range: 5.0 to 10.0 atm
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 const float REGENERATION_TIME_CONSTANT = 20160.0f; //!Adj. Range: 10080 to 51840 min
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 const float PRESSURE_OTHER_GASES_MMHG = 102.0f; //!Constant value for PO2 up to 2 atm
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 const float CONSTANT_PRESSURE_OTHER_GASES = 102.0f * 10.1325f / 760.0f; // PRESSURE_OTHER_GASES_MMHG / 760. * UNITS_FACTOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 const float HELIUM_TIME_CONSTANT[16] = {3.68695308808482E-001f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 2.29518933960247E-001f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 1.46853216220327E-001f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 9.91626867753856E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 6.78890480470074E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 4.78692804254106E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 3.37626488338989E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 2.38113081607676E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 1.68239606932026E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 1.25592893741610E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 9.80544886914621E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 7.67264977374303E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 6.01220557342307E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 4.70185307665137E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 3.68225234041620E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 2.88775228329769E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 const float NITROGEN_TIME_CONSTANT[16] = {1.38629436111989E-001f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 8.66433975699932E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 5.54517744447956E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 3.74674151654024E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 2.56721177985165E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 1.80978376125312E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 1.27651414467762E-002f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 9.00191143584345E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 6.35914844550409E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 4.74758342849278E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 3.70666941475907E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 2.90019740820061E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 2.27261370675392E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 1.77730046297422E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 1.39186180835330E-003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 1.09157036308653E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 int onset_of_impermeability(SGas* pGas, float *starting_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 float *ending_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 float *rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 float* amb_pressure_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 float* gas_tension_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 float* initial_helium_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 float* initial_nitrogen_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 short i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 int radius_root_finder (float *a, float *b, float *c, float *low_bound, float *high_bound, float *ending_radius);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 //void get_inert_gases_(SBuehlmann* input, ,short gas_id, float ambient_pressure_bar, float* fraction_nitrogen,float* fraction_helium );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 int vpm_repetitive_algorithm(SVpm* pVpm, float *surface_interval_time, float* initial_critical_radius_he, float* initial_critical_radius_n2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 /* NOTE ABOUT PRESSURE UNITS USED IN CALCULATIONS: */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 /* It is the convention in decompression calculations to compute all gas */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 /* loadings, absolute pressures, partial pressures, etc., in the units of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 /* depth pressure that you are diving - either feet of seawater (fsw) or */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 /* meters of seawater (msw). This program follows that convention with the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 /* the exception that all VPM calculations are performed in SI units (by */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /* necessity). Accordingly, there are several conversions back and forth */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 /* between the diving pressure units and the SI units. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 /* FUNCTION SUBPROGRAM FOR GAS LOADING CALCULATIONS - ASCENT AND DESCENT */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 float schreiner_equation__2(float *initial_inspired_gas_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 float *rate_change_insp_gas_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 float *interval_time_minutes,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 const float *gas_time_constant,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 float *initial_gas_pressure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 /* System generated locals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 float ret_val;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 float time_null_pressure = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 float time_rest = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 float time = *interval_time_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 /* Note: The Schreiner equation is applied when calculating the uptake or */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 /* elimination of compartment gases during linear ascents or descents at a */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 /* constant rate. For ascents, a negative number for rate must be used. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 if( *rate_change_insp_gas_pressure < 0.0f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 time_null_pressure = -1.0f * *initial_inspired_gas_pressure / *rate_change_insp_gas_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 if(time > time_null_pressure )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 time_rest = time - time_null_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 time = time_null_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 ret_val =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 *initial_inspired_gas_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 *rate_change_insp_gas_pressure *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 (time - 1.f / *gas_time_constant) -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 (*initial_inspired_gas_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 *initial_gas_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 *rate_change_insp_gas_pressure / *gas_time_constant) *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 expf(-(*gas_time_constant) * time);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 if(time_rest > 0.0f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 ret_val = ret_val * expf(-(*gas_time_constant) * time_rest);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 return ret_val;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 }; /* schreiner_equation__2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 /* SUBROUTINE CALC_CRUSHING_PRESSURE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 /* Purpose: Compute the effective "crushing pressure" in each compartment as */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 /* a result of descent segment(s). The crushing pressure is the gradient */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /* (difference in pressure) between the outside ambient pressure and the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 /* gas tension inside a VPM nucleus (bubble seed). This gradient acts to */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 /* reduce (shrink) the radius smaller than its initial value at the surface. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 /* This phenomenon has important ramifications because the smaller the radius */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 /* of a VPM nucleus, the greater the allowable supersaturation gradient upon */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 /* ascent. Gas loading (uptake) during descent, especially in the fast */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 /* compartments, will reduce the magnitude of the crushing pressure. The */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 /* crushing pressure is not cumulative over a multi-level descent. It will */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 /* be the maximum value obtained in any one discrete segment of the overall */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 /* descent. Thus, the program must compute and store the maximum crushing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 /* pressure for each compartment that was obtained across all segments of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 /* the descent profile. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 /* The calculation of crushing pressure will be different depending on */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 /* whether or not the gradient is in the VPM permeable range (gas can diffuse */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /* across skin of VPM nucleus) or the VPM impermeable range (molecules in */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 /* skin of nucleus are squeezed together so tight that gas can no longer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 /* diffuse in or out of nucleus; the gas becomes trapped and further resists */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 /* the crushing pressure). The solution for crushing pressure in the VPM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 /* permeable range is a simple linear equation. In the VPM impermeable */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 /* range, a cubic equation must be solved using a numerical method. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 /* Separate crushing pressures are tracked for helium and nitrogen because */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 /* they can have different critical radii. The crushing pressures will be */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 /* the same for helium and nitrogen in the permeable range of the model, but */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /* they will start to diverge in the impermeable range. This is due to */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 /* the differences between starting radius, radius at the onset of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 /* impermeability, and radial compression in the impermeable range. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 int calc_crushing_pressure(SLifeData* lifeData, SVpm* vpm, float * initial_helium_pressure, float * initial_nitrogen_pressure, float starting_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 float rate )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 /* System generated locals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 static float r1, r2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 static float low_bound_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 ending_radius_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 gradient_onset_of_imperm_pa;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 static float low_bound_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 ending_radius_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 high_bound_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 crushing_pressure_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 short i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 static float crushing_pressure_pascals_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 gradient_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 starting_gas_tension,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 high_bound_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 crushing_pressure_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 amb_press_onset_of_imperm_pa,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 crushing_pressure_pascals_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 radius_onset_of_imperm_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 starting_gradient,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 radius_onset_of_imperm_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 ending_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 static float ending_ambient_pressure_pa,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 a_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 b_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 c_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 ending_gradient,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 gas_tension_onset_of_imperm_pa,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 a_he,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 b_he, c_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 static float amb_pressure_onset_of_imperm[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 static float gas_tension_onset_of_imperm[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 static float helium_pressure_crush[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 static float nitrogen_pressure_crush[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 static float ending_ambient_pressure = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 ending_ambient_pressure = lifeData->pressure_ambient_bar * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 for( i = 0; i < 16; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 helium_pressure_crush[i] = lifeData->tissue_helium_bar[i] * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 nitrogen_pressure_crush[i] = lifeData->tissue_nitrogen_bar[i] * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* loop */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 /* CALCULATIONS */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 /* First, convert the Gradient for Onset of Impermeability from units of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 /* atmospheres to diving pressure units (either fsw or msw) and to Pascals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 /* (SI units). The reason that the Gradient for Onset of Impermeability is */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 /* given in the program settings in units of atmospheres is because that is */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 /* how it was reported in the original research papers by Yount and */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 /* colleauges. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 gradient_onset_of_imperm = GRADIENT_ONSET_OF_IMPERM_ATM * UNITS_FACTOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 gradient_onset_of_imperm_pa = GRADIENT_ONSET_OF_IMPERM_ATM * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 /* Assign values of starting and ending ambient pressures for descent segment */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 //starting_ambient_pressure = *starting_depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 //ending_ambient_pressure = *ending_depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 /* MAIN LOOP WITH NESTED DECISION TREE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 /* For each compartment, the program computes the starting and ending */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 /* gas tensions and gradients. The VPM is different than some dissolved gas */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 /* algorithms, Buhlmann for example, in that it considers the pressure due to */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 /* oxygen, carbon dioxide, and water vapor in each compartment in addition to */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 /* the inert gases helium and nitrogen. These "other gases" are included in */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 /* the calculation of gas tensions and gradients. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 crushing_pressure_he = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 crushing_pressure_n2 = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 for (i = 0; i < 16; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 starting_gas_tension = initial_helium_pressure[i] + initial_nitrogen_pressure[i] + CONSTANT_PRESSURE_OTHER_GASES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 starting_gradient = starting_ambient_pressure - starting_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 ending_gas_tension = helium_pressure_crush[i] + nitrogen_pressure_crush[i] + CONSTANT_PRESSURE_OTHER_GASES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 ending_gradient = ending_ambient_pressure - ending_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 /* Compute radius at onset of impermeability for helium and nitrogen */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 /* critical radii */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 radius_onset_of_imperm_he = 1.0f / (
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 gradient_onset_of_imperm_pa /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 ((SKIN_COMPRESSION_GAMMAC -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 SURFACE_TENSION_GAMMA) * 2.0f) +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 1.0f / vpm->adjusted_critical_radius_he[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 radius_onset_of_imperm_n2 = 1.0f / (
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 gradient_onset_of_imperm_pa /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 ((SKIN_COMPRESSION_GAMMAC -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 SURFACE_TENSION_GAMMA) * 2.0f) +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 1.0f / vpm->adjusted_critical_radius_n2[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 /* FIRST BRANCH OF DECISION TREE - PERMEABLE RANGE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 /* Crushing pressures will be the same for helium and nitrogen */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 if (ending_gradient <= gradient_onset_of_imperm) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 crushing_pressure_he = ending_ambient_pressure - ending_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 crushing_pressure_n2 = ending_ambient_pressure - ending_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 /* SECOND BRANCH OF DECISION TREE - IMPERMEABLE RANGE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 /* Both the ambient pressure and the gas tension at the onset of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 /* impermeability must be computed in order to properly solve for the ending */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 /* radius and resultant crushing pressure. The first decision block */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 /* addresses the special case when the starting gradient just happens to be */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 /* equal to the gradient for onset of impermeability (not very likely!). */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 if (ending_gradient > gradient_onset_of_imperm) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 if (starting_gradient == gradient_onset_of_imperm) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 amb_pressure_onset_of_imperm[i] = starting_ambient_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 gas_tension_onset_of_imperm[i] = starting_gas_tension;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 /* In most cases, a subroutine will be called to find these values using a */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 /* numerical method. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 if (starting_gradient < gradient_onset_of_imperm) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 onset_of_impermeability(&(lifeData->actualGas), &starting_ambient_pressure, &ending_ambient_pressure, &rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 amb_pressure_onset_of_imperm, gas_tension_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 initial_helium_pressure, initial_nitrogen_pressure, i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 /* Next, using the values for ambient pressure and gas tension at the onset */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 /* of impermeability, the equations are set up to process the calculations */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 /* through the radius root finder subroutine. This subprogram will find the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 /* root (solution) to the cubic equation using a numerical method. In order */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 /* to do this efficiently, the equations are placed in the form */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 /* Ar^3 - Br^2 - C = 0, where r is the ending radius after impermeable */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 /* compression. The coefficients A, B, and C for helium and nitrogen are */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 /* computed and passed to the subroutine as arguments. The high and low */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 /* bounds to be used by the numerical method of the subroutine are also */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 /* computed (see separate page posted on Deco List ftp site entitled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 /* "VPM: Solving for radius in the impermeable regime"). The subprogram */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 /* will return the value of the ending radius and then the crushing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 /* pressures for helium and nitrogen can be calculated. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 ending_ambient_pressure_pa = ending_ambient_pressure / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 amb_press_onset_of_imperm_pa = amb_pressure_onset_of_imperm[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 gas_tension_onset_of_imperm_pa = gas_tension_onset_of_imperm[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 b_he = (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) * 2.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 a_he = ending_ambient_pressure_pa - amb_press_onset_of_imperm_pa + gas_tension_onset_of_imperm_pa
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 + (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) * 2.0f / radius_onset_of_imperm_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 r1 = radius_onset_of_imperm_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 c_he = gas_tension_onset_of_imperm_pa * (r1 * (r1 * r1));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 high_bound_he = radius_onset_of_imperm_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 low_bound_he = b_he / a_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 radius_root_finder(&a_he, &b_he, &c_he, &low_bound_he, &high_bound_he, &ending_radius_he);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 r1 = radius_onset_of_imperm_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 r2 = ending_radius_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 crushing_pressure_pascals_he =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 gradient_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 ending_ambient_pressure_pa -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 amb_press_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 gas_tension_onset_of_imperm_pa *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 (1.0f - r1 * (r1 * r1) / (r2 * (r2 * r2)));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 crushing_pressure_he =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 crushing_pressure_pascals_he / 101325.0f * UNITS_FACTOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 b_n2 = (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) * 2.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 a_n2 = ending_ambient_pressure_pa -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 amb_press_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 gas_tension_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 2.0f / radius_onset_of_imperm_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 r1 = radius_onset_of_imperm_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 c_n2 = gas_tension_onset_of_imperm_pa * (r1 * (r1 * r1));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 high_bound_n2 = radius_onset_of_imperm_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 low_bound_n2 = b_n2 / a_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 radius_root_finder(&a_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 &b_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 &c_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 &low_bound_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 &high_bound_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 &ending_radius_n2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 r1 = radius_onset_of_imperm_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 /* Computing 3rd power */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 r2 = ending_radius_n2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 crushing_pressure_pascals_n2 =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 gradient_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 ending_ambient_pressure_pa -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 amb_press_onset_of_imperm_pa +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 gas_tension_onset_of_imperm_pa * (1.0f - r1 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 (r1 * r1) / (r2 * (r2 * r2)));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 crushing_pressure_n2 = crushing_pressure_pascals_n2 / 101325.0f * UNITS_FACTOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 /* UPDATE VALUES OF MAX CRUSHING PRESSURE IN GLOBAL ARRAYS */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 /* Computing MAX */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 r1 = vpm->max_crushing_pressure_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 vpm->max_crushing_pressure_he[i] = fmaxf(r1, crushing_pressure_he);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 /* Computing MAX */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 r1 = vpm->max_crushing_pressure_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 vpm->max_crushing_pressure_n2[i] = fmaxf(r1, crushing_pressure_n2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 } /* calc_crushing_pressure */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 /* SUBROUTINE ONSET_OF_IMPERMEABILITY */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 /* Purpose: This subroutine uses the Bisection Method to find the ambient */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 /* pressure and gas tension at the onset of impermeability for a given */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /* compartment. Source: "Numerical Recipes in Fortran 77", */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 /* Cambridge University Press, 1992. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 int onset_of_impermeability(SGas* pGas, float *starting_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 float *ending_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 float *rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 float* amb_pressure_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 float* gas_tension_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 float* initial_helium_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 float* initial_nitrogen_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 short i)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 /* Local variables */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 float time, last_diff_change, mid_range_nitrogen_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 short j;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 float gas_tension_at_mid_range,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 initial_inspired_n2_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 gradient_onset_of_imperm,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 starting_gas_tension,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 low_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 initial_inspired_he_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 high_bound_nitrogen_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 nitrogen_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 function_at_mid_range,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 function_at_low_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 high_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 mid_range_helium_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 mid_range_time,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 ending_gas_tension,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 function_at_high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 float mid_range_ambient_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 high_bound_helium_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 helium_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 float fraction_helium_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 float fraction_helium_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 float fraction_nitrogen_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 float fraction_nitrogen_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 /* loop */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 /* CALCULATIONS */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 /* First convert the Gradient for Onset of Impermeability to the diving */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 /* pressure units that are being used */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 gradient_onset_of_imperm = GRADIENT_ONSET_OF_IMPERM_ATM * UNITS_FACTOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* ESTABLISH THE BOUNDS FOR THE ROOT SEARCH USING THE BISECTION METHOD */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 /* In this case, we are solving for time - the time when the ambient pressure */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 /* minus the gas tension will be equal to the Gradient for Onset of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 /* Impermeabliity. The low bound for time is set at zero and the high */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 /* bound is set at the elapsed time (segment time) it took to go from the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 /* starting ambient pressure to the ending ambient pressure. The desired */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* ambient pressure and gas tension at the onset of impermeability will */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 /* be found somewhere between these endpoints. The algorithm checks to */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 /* make sure that the solution lies in between these bounds by first */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 /* computing the low bound and high bound function values. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 /*initial_inspired_he_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 (*starting_ambient_pressure - water_vapor_pressure) * fraction_helium[mix_number - 1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 initial_inspired_n2_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 (*starting_ambient_pressure - water_vapor_pressure) * fraction_nitrogen[mix_number - 1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 helium_rate = *rate * fraction_helium[mix_number - 1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 nitrogen_rate = *rate * fraction_nitrogen[mix_number - 1];*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 low_bound = 0.;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 high_bound = (*ending_ambient_pressure - *starting_ambient_pressure) / *rate;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 //New
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 decom_get_inert_gases( *starting_ambient_pressure / 10.0f, pGas, &fraction_nitrogen_begin, &fraction_helium_begin );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 decom_get_inert_gases(*ending_ambient_pressure / 10.0f, pGas, &fraction_nitrogen_end, &fraction_helium_end );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 initial_inspired_he_pressure = (*starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 initial_inspired_n2_pressure = (*starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 helium_rate = ((*ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 nitrogen_rate = ((*ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 starting_gas_tension =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 initial_helium_pressure[i] +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 initial_nitrogen_pressure[i] +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 CONSTANT_PRESSURE_OTHER_GASES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 function_at_low_bound =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 *starting_ambient_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 starting_gas_tension -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 gradient_onset_of_imperm;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 high_bound_helium_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 schreiner_equation__2(&initial_inspired_he_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 &helium_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 &high_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 &HELIUM_TIME_CONSTANT[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 &initial_helium_pressure[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 high_bound_nitrogen_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 schreiner_equation__2(&initial_inspired_n2_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 &nitrogen_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 &high_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 &NITROGEN_TIME_CONSTANT[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 &initial_nitrogen_pressure[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 ending_gas_tension =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 high_bound_helium_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 high_bound_nitrogen_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 CONSTANT_PRESSURE_OTHER_GASES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 function_at_high_bound =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 *ending_ambient_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 ending_gas_tension -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 gradient_onset_of_imperm;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 if (function_at_high_bound * function_at_low_bound >= 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 //printf("\nERROR! ROOT IS NOT WITHIN BRACKETS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 /* APPLY THE BISECTION METHOD IN SEVERAL ITERATIONS UNTIL A SOLUTION WITH */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 /* THE DESIRED ACCURACY IS FOUND */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 /* Note: the program allows for up to 100 iterations. Normally an exit will */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 /* be made from the loop well before that number. If, for some reason, the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 /* program exceeds 100 iterations, there will be a pause to alert the user. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 if (function_at_low_bound < 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 time = low_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 differential_change = high_bound - low_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 time = high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 differential_change = low_bound - high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 for (j = 1; j <= 100; ++j) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 last_diff_change = differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 differential_change = last_diff_change * 0.5f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 mid_range_time = time + differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 mid_range_ambient_pressure = *starting_ambient_pressure + *rate * mid_range_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 mid_range_helium_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 schreiner_equation__2(&initial_inspired_he_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 &helium_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 &mid_range_time,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 &HELIUM_TIME_CONSTANT[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 &initial_helium_pressure[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 mid_range_nitrogen_pressure =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 schreiner_equation__2(&initial_inspired_n2_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 &nitrogen_rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 &mid_range_time,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 &NITROGEN_TIME_CONSTANT[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 &initial_nitrogen_pressure[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 gas_tension_at_mid_range =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 mid_range_helium_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 mid_range_nitrogen_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 CONSTANT_PRESSURE_OTHER_GASES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 function_at_mid_range =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 mid_range_ambient_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 gas_tension_at_mid_range -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 gradient_onset_of_imperm;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 if (function_at_mid_range <= 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 time = mid_range_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 if (fabs(differential_change) < .001f ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 function_at_mid_range == 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 goto L100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 //printf("\nERROR! ROOT SEARCH EXCEEDED MAXIMUM ITERATIONS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 /* When a solution with the desired accuracy is found, the program jumps out */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 /* of the loop to Line 100 and assigns the solution values for ambient */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /* pressure and gas tension at the onset of impermeability. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 L100:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 amb_pressure_onset_of_imperm[i] = mid_range_ambient_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 gas_tension_onset_of_imperm[i] = gas_tension_at_mid_range;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 } /* onset_of_impermeability */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 /* SUBROUTINE RADIUS_ROOT_FINDER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 /* Purpose: This subroutine is a "fail-safe" routine that combines the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 /* Bisection Method and the Newton-Raphson Method to find the desired root. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 /* This hybrid algorithm takes a bisection step whenever Newton-Raphson would */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 /* take the solution out of bounds, or whenever Newton-Raphson is not */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 /* converging fast enough. Source: "Numerical Recipes in Fortran 77", */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 /* Cambridge University Press, 1992. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 int radius_root_finder (float *a,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 float *b,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 float *c,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 float *low_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 float *high_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 float *ending_radius)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 /* System generated locals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 float r1, r2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 /* Local variables */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 float radius_at_low_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 last_diff_change,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 function,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 radius_at_high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 short i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 float function_at_low_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 last_ending_radius,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 function_at_high_bound,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 derivative_of_function,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 /* loop */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 /* BEGIN CALCULATIONS BY MAKING SURE THAT THE ROOT LIES WITHIN BOUNDS */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 /* In this case we are solving for radius in a cubic equation of the form, */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 /* Ar^3 - Br^2 - C = 0. The coefficients A, B, and C were passed to this */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 /* subroutine as arguments. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 function_at_low_bound =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 *low_bound * (*low_bound * (*a * *low_bound - *b)) - *c;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 function_at_high_bound =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 *high_bound * (*high_bound * (*a * *high_bound - *b)) - *c;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 if (function_at_low_bound > 0.0f && function_at_high_bound > 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 // printf("\nERROR! ROOT IS NOT WITHIN BRACKETS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 /* Next the algorithm checks for special conditions and then prepares for */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 /* the first bisection. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 if (function_at_low_bound < 0.0f && function_at_high_bound < 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 //printf("\nERROR! ROOT IS NOT WITHIN BRACKETS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 if (function_at_low_bound == 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 *ending_radius = *low_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 } else if (function_at_high_bound == 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 *ending_radius = *high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 } else if (function_at_low_bound < 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 radius_at_low_bound = *low_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 radius_at_high_bound = *high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 radius_at_high_bound = *low_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 radius_at_low_bound = *high_bound;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 *ending_radius = (*low_bound + *high_bound) * .5f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 last_diff_change = (r1 = *high_bound - *low_bound, fabs(r1));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 differential_change = last_diff_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 /* At this point, the Newton-Raphson Method is applied which uses a function */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 /* and its first derivative to rapidly converge upon a solution. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 /* Note: the program allows for up to 100 iterations. Normally an exit will */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 /* be made from the loop well before that number. If, for some reason, the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 /* program exceeds 100 iterations, there will be a pause to alert the user. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 /* When a solution with the desired accuracy is found, exit is made from the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 /* loop by returning to the calling program. The last value of ending */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 /* radius has been assigned as the solution. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 function =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 *ending_radius * (*ending_radius * (*a * *ending_radius - *b)) - *c;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 derivative_of_function =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 *ending_radius * (*ending_radius * 3.0f * *a - *b * 2.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 for (i = 1; i <= 100; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 if (((*ending_radius - radius_at_high_bound) * derivative_of_function - function) *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 ((*ending_radius - radius_at_low_bound) * derivative_of_function - function) >= 0.0f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 || (r1 = function * 2.0f, fabs(r1)) >
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 (r2 = last_diff_change * derivative_of_function, fabs(r2))) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 last_diff_change = differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 differential_change =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 (radius_at_high_bound - radius_at_low_bound) * .5f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 *ending_radius = radius_at_low_bound + differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 if (radius_at_low_bound == *ending_radius) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 last_diff_change = differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 differential_change = function / derivative_of_function;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 last_ending_radius = *ending_radius;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 *ending_radius -= differential_change;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 if (last_ending_radius == *ending_radius) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 if (fabs(differential_change) < 1e-12) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 function =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 *ending_radius * (*ending_radius * (*a * *ending_radius - *b)) - *c;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 derivative_of_function =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 *ending_radius * (*ending_radius * 3.0f * *a - *b * 2.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 if (function < 0.0f) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 radius_at_low_bound = *ending_radius;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 radius_at_high_bound = *ending_radius;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 // printf("\nERROR! ROOT SEARCH EXCEEDED MAXIMUM ITERATIONS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 } /* radius_root_finder */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 void vpm_init(SVpm* pVpm, short conservatism, short repetitive_dive, long seconds_since_last_dive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
727 float critical_radius_n2_microns = 0.82; /* be conservative in case of an unexpected parameter value */
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
728 float critical_radius_he_microns = 0.72;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 float initial_critical_radius_n2[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 float initial_critical_radius_he[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 int i = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 float surface_time = seconds_since_last_dive / 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 pVpm->repetitive_variables_not_valid = !repetitive_dive;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 //pVpm->vpm_conservatism = conservatism;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 switch(conservatism)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 case 0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 critical_radius_n2_microns=0.55; //!Adj. Range: 0.2 to 1.35 microns
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 critical_radius_he_microns=0.45; //!Adj. Range: 0.2 to 1.35 microns
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 critical_radius_n2_microns=0.58;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 critical_radius_he_microns=0.48;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 critical_radius_n2_microns=0.62;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 critical_radius_he_microns=0.52;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 case 3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 critical_radius_n2_microns=0.68;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 critical_radius_he_microns=0.58;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 case 4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 critical_radius_n2_microns=0.75;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 critical_radius_he_microns=0.65;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 case 5:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 critical_radius_n2_microns=0.82;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 critical_radius_he_microns=0.72;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 break;
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
761 default:
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
762 critical_radius_n2_microns=0.82;
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
763 critical_radius_he_microns=0.72;
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
764 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 for (i = 0; i < 16; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 initial_critical_radius_n2[i] = critical_radius_n2_microns * 1e-6f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 initial_critical_radius_he[i] = critical_radius_he_microns * 1e-6f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 if( (surface_time > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 && (!pVpm->repetitive_variables_not_valid) )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 //&& (pVpm->decomode_vpm_plus_conservatism_last_dive > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 //&& (pVpm->decomode_vpm_plus_conservatism_last_dive - 1 == pVpm->vpm_conservatism))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 vpm_repetitive_algorithm(pVpm, &surface_time,initial_critical_radius_he, initial_critical_radius_n2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 //Kein gültiger Wiederholungstauchgang
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 for (i = 0; i < 16; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 pVpm->adjusted_critical_radius_n2[i] = initial_critical_radius_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 pVpm->adjusted_critical_radius_he[i] = initial_critical_radius_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 pVpm->repetitive_variables_not_valid = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 for (i = 0; i < 16; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 pVpm->max_crushing_pressure_he[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 pVpm->max_crushing_pressure_n2[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 pVpm->max_actual_gradient[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 pVpm->adjusted_crushing_pressure_he[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 pVpm->adjusted_crushing_pressure_n2[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 pVpm->initial_allowable_gradient_he[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 pVpm->initial_allowable_gradient_n2[i] = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 pVpm->max_first_stop_depth_save = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 pVpm->depth_start_of_deco_zone_save = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 pVpm->run_time_start_of_deco_zone_save = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 pVpm->deco_zone_reached = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 /* SUBROUTINE VPM_REPETITIVE_ALGORITHM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 /* Purpose: This subprogram implements the VPM Repetitive Algorithm that was */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 /* envisioned by Professor David E. Yount only months before his passing. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 int vpm_repetitive_algorithm(SVpm* pVpm, float *surface_interval_time, float* initial_critical_radius_he, float* initial_critical_radius_n2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 /* Local variables */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 static float max_actual_gradient_pascals;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 //static float initial_allowable_grad_n2_pa, initial_allowable_grad_he_pa;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 static short i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 static float adj_crush_pressure_n2_pascals,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 new_critical_radius_n2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 adj_crush_pressure_he_pascals,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 new_critical_radius_he;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 /* loop */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 /* CALCULATIONS */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 /* by hw 160215 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 /* IN: */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 /* pVpm->max_actual_gradient[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 /* pVpm->initial_allowable_gradient_n2[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 /* pVpm->initial_allowable_gradient_he[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 /* pVpm->adjusted_crushing_pressure_he[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 /* pVpm->adjusted_crushing_pressure_n2[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 /* OUT: */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 /* pVpm->adjusted_critical_radius_n2[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 /* pVpm->adjusted_critical_radius_he[i] */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 for (i = 0; i < 16; ++i) {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 max_actual_gradient_pascals = pVpm->max_actual_gradient[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 adj_crush_pressure_he_pascals = pVpm->adjusted_crushing_pressure_he[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 adj_crush_pressure_n2_pascals = pVpm->adjusted_crushing_pressure_n2[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 initial_allowable_grad_he_pa =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 pVpm->initial_allowable_gradient_he[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 initial_allowable_grad_n2_pa =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 pVpm->initial_allowable_gradient_n2[i] / UNITS_FACTOR * 101325.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 if (pVpm->max_actual_gradient[i] > pVpm->initial_allowable_gradient_n2[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 new_critical_radius_n2 =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 SURFACE_TENSION_GAMMA * 2.0f *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 (max_actual_gradient_pascals * SKIN_COMPRESSION_GAMMAC -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 SURFACE_TENSION_GAMMA * adj_crush_pressure_n2_pascals);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 pVpm->adjusted_critical_radius_n2[i] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 initial_critical_radius_n2[i]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 + (initial_critical_radius_n2[i] - new_critical_radius_n2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 * exp(-(*surface_interval_time) / REGENERATION_TIME_CONSTANT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 pVpm->adjusted_critical_radius_n2[i] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 initial_critical_radius_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 if (pVpm->max_actual_gradient[i] > pVpm->initial_allowable_gradient_he[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 new_critical_radius_he =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 SURFACE_TENSION_GAMMA * 2.0f *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 (SKIN_COMPRESSION_GAMMAC - SURFACE_TENSION_GAMMA) /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 (max_actual_gradient_pascals * SKIN_COMPRESSION_GAMMAC -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 SURFACE_TENSION_GAMMA * adj_crush_pressure_he_pascals);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 pVpm->adjusted_critical_radius_he[i] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 initial_critical_radius_he[i]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 + ( initial_critical_radius_he[i] - new_critical_radius_he)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 * exp(-(*surface_interval_time) / REGENERATION_TIME_CONSTANT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 } else {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 pVpm->adjusted_critical_radius_he[i] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 initial_critical_radius_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 } /* vpm_repetitive_algorithm */