annotate Common/Src/decom.c @ 857:ba1aebc6d5af Evo_2_23

Developer feature debug warning: The debug warnings are only available to developers who activate the feature via compile switch. After that it is possible to define a condition and a content of a warning which will be shown if a special situation occure (visualized in the main view as already done for other warnings like ppo2). In the first implementation details regarding the error state of the DiveO2 will be shown in case the sensor reports a problem. Feel free to change the implementation in case you want to observe another behavior.
author Ideenmodellierer
date Sun, 05 May 2024 17:27:28 +0200
parents 012f94ec2fe0
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/decom.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief This code is used to calculate desat, calculated by RTE and send to Firmware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 22-Feb-2016
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 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 ##### Changes #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 V1.0.2 1602220x decom_oxygen_calculate_cns() changed to hwOS version
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include <math.h>
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
40 #include <string.h>
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #include "calc_crush.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
44 #define FRACTION_N2_AIR 0.7902
38
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] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 3.68695308808482E-001,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 2.29518933960247E-001,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 1.46853216220327E-001,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 9.91626867753856E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 6.78890480470074E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 4.78692804254106E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 3.37626488338989E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 2.38113081607676E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 1.68239606932026E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 1.25592893741610E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 9.80544886914621E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 7.67264977374303E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 6.01220557342307E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 4.70185307665137E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 3.68225234041620E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 2.88775228329769E-003};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 const float nitrogen_time_constant[16] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 1.38629436111989E-001,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 8.66433975699932E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 5.54517744447956E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 3.74674151654024E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 2.56721177985165E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 1.80978376125312E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 1.27651414467762E-002,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 9.00191143584345E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 6.35914844550409E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 4.74758342849278E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 3.70666941475907E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 2.90019740820061E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 2.27261370675392E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 1.77730046297422E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 1.39186180835330E-003,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 1.09157036308653E-003};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 const float buehlmann_N2_a[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 1.1696f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 1.0000f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 0.8618f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 0.7562f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 0.6200f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 0.5043f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 0.4410f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 0.4000f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 0.3750f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 0.3500f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 0.3295f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 0.3065f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 0.2835f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 0.2610f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 0.2480f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 0.2327f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 const float buehlmann_N2_b[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 0.5578f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 0.6514f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 0.7222f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 0.7825f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 0.8126f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 0.8434f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 0.8693f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 0.8910f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 0.9092f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 0.9222f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 0.9319f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 0.9403f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 0.9477f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 0.9544f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 0.9602f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 0.9653f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 const float buehlmann_He_a[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 1.6189f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 1.3830f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 1.1919f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 1.0458f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 0.9220f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 0.8205f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 0.7305f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 0.6502f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 0.5950f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 0.5545f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 0.5333f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 0.5189f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 0.5181f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 0.5176f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 0.5172f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 0.5119f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 const float buehlmann_He_b[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 0.4770f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 0.5747f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 0.6527f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 0.7223f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 0.7582f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 0.7957f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 0.8279f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 0.8553f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 0.8757f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 0.8903f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 0.8997f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 0.9073f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 0.9122f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 0.9171f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 0.9217f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 0.9267f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 const float buehlmann_N2_t_halflife[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 5.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 8.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 12.5f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 18.5f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 27.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 38.3f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 54.3f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 77.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 109.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 146.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 187.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 239.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 305.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 390.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 498.0f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 635.0f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 const float buehlmann_He_t_halflife[] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 1.88f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 3.02f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 4.72f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 6.99f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 10.21f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 14.48f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 20.53f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 29.11f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 41.20f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 55.19f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 70.69f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 90.34f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 115.29f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 147.42f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 188.24f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 240.03f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 const float float_buehlmann_N2_factor_expositon_one_second[] = { 2.30782347297664E-003f, 1.44301447809736E-003f, 9.23769302935806E-004f, 6.24261986779007E-004f, 4.27777107246730E-004f, 3.01585140931371E-004f, 2.12729727268379E-004f, 1.50020603047807E-004f, 1.05980191127841E-004f, 7.91232600646508E-005f, 6.17759153688224E-005f, 4.83354552742732E-005f, 3.78761777920511E-005f, 2.96212356654113E-005f, 2.31974277413727E-005f, 1.81926738960225E-005f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 const float float_buehlmann_N2_factor_expositon_003_second[] = { 6.90750456296407E-003f, 4.32279956671600E-003f, 2.76874864793053E-003f, 1.87161709452954E-003f, 1.28278242026003E-003f, 9.04482589432765E-004f, 6.38053429621421E-004f, 4.49994293975742E-004f, 3.17906879170993E-004f, 2.37350999218289E-004f, 1.85316297551252E-004f, 1.44999356986975E-004f, 1.13624229615916E-004f, 8.88610747694640E-005f, 6.95906688746861E-005f, 5.45770287740943E-005f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 const float float_buehlmann_N2_factor_expositon_008_second[] = { 1.83141447532454E-002f, 1.14859796471039E-002f, 7.36630472495203E-003f, 4.98319782231915E-003f, 3.41709742823104E-003f, 2.41013596224415E-003f, 1.70057124687550E-003f, 1.19953484034729E-003f, 8.47527105247492E-004f, 6.32810814525819E-004f, 4.94100480767923E-004f, 3.86618231662861E-004f, 3.02969256443353E-004f, 2.36945319086024E-004f, 1.85564355251966E-004f, 1.45532124251058E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 const float float_buehlmann_N2_factor_expositon_10_seconds[] = { 2.28400315657541E-002f, 1.43368013598124E-002f, 9.19938673477072E-003f, 6.22511239287027E-003f, 4.69545762670800E-003f, 3.01176178733265E-003f, 2.12526200031782E-003f, 1.49919365737827E-003f, 1.05929662305226E-03f, 7.909509380171760E-004f, 6.17587450108648E-004f, 4.83249432061905E-004f, 3.78697227222391E-004f, 2.61728759809380E-004f, 2.31950063482533E-004f, 1.81911845881011E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 const float float_buehlmann_N2_factor_expositon_18_seconds[] = { 4.07358806747357E-002f, 2.56581087982929E-002f, 1.64979259737517E-002f, 1.11772892486697E-002f, 7.67205373705648E-003f, 5.41463899418337E-003f, 3.82221908774349E-003f, 2.69693016270112E-003f, 1.90592594569927E-003f, 1.42326123023573E-003f, 1.11138278062062E-003f, 8.69680830683950E-004f, 6.81551750048359E-004f, 5.33048018290350E-004f, 4.17471377070378E-004f, 3.27417496114757E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 const float float_buehlmann_N2_factor_expositon_20_seconds[] = { 4.51583960895835E-002f, 2.84680588463941E-002f, 1.83141447532454E-002f, 1.24114727614367E-002f, 8.52086250432193E-003f, 6.01445286560154E-003f, 4.24600726206570E-003f, 2.99613973313428E-003f, 2.11747113676897E-003f, 1.58127627264804E-003f, 1.23479348595879E-003f, 9.66265334110261E-004f, 7.57251042854845E-004f, 5.92258033589421E-004f, 4.63846326133055E-004f, 3.63790599842373E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 const float float_buehlmann_N2_factor_expositon_one_minute[] = { 1.29449436703876E-001f, 8.29959567953288E-002f, 5.39423532744041E-002f, 3.67741962370398E-002f, 2.53453908775689E-002f, 1.79350552316596E-002f, 1.26840126026602E-002f, 8.96151553540825E-003f, 6.33897185233323E-003f, 4.73633146787078E-003f, 3.69980819572546E-003f, 2.89599589841472E-003f, 2.27003327536857E-003f, 1.77572199977927E-003f, 1.39089361795441E-003f, 1.09097481687104E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 const float float_buehlmann_N2_factor_expositon_100_second[] = { 2.06299474015900E-001f, 1.34463438993857E-001f, 8.82775114417832E-002f, 6.05359181023788E-002f, 4.18844218114071E-002f, 2.97126970072147E-002f, 2.10505144045823E-002f, 1.48911986890571E-002f, 1.05426136839346E-002f, 7.88141652426455E-003f, 6.15873909572406E-003f, 4.82199900095137E-003f, 3.78052526350936E-003f, 2.95778454900952E-003f, 2.31708109427220E-003f, 1.81763004457269E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 const float float_buehlmann_N2_factor_expositon_five_minutes[]= { 5.00000000000000E-001f, 3.51580222674495E-001f, 2.42141716744801E-001f, 1.70835801932547E-001f, 1.20463829104624E-001f, 8.65157896183918E-002f, 6.18314987350977E-002f, 4.40116547625051E-002f, 3.12955727186929E-002f, 2.34583889613009E-002f, 1.83626606868127E-002f, 1.43963540993090E-002f, 1.12987527093947E-002f, 8.84713405486026E-003f, 6.93514912851934E-003f, 5.44298480182925E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 const float float_buehlmann_N2_factor_expositon_800_second[] = { 8.42509868763141E-001f, 6.85019737526282E-001f, 5.22579198044792E-001f, 3.93205767018569E-001f, 2.89861248917861E-001f, 2.14397627137602E-001f, 1.56505490290652E-001f, 1.13102166881646E-001f, 8.12935637814599E-002f, 6.13392112527207E-002f, 4.82208523469105E-002f, 3.79311861210304E-002f, 2.98470272862601E-002f, 2.34187624071612E-002f, 1.83870151711824E-002f, 1.44488700649190E-002f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 const float float_buehlmann_N2_factor_expositon_one_hour[]= { 9.99755859375000E-001f, 9.94475728271980E-001f, 9.64103176406343E-001f, 8.94394508891055E-001f, 7.85689004286732E-001f, 6.62392147498621E-001f, 5.35088626789486E-001f, 4.17318576947576E-001f, 3.17197008420226E-001f, 2.47876700002107E-001f, 1.99405069752929E-001f, 1.59713055172538E-001f, 1.27468761759271E-001f, 1.01149026804458E-001f, 8.01196838116008E-002f, 6.33955413542552E-002f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 const float float_buehlmann_He_factor_expositon_one_second[] = { 6.12608039419837E-003f, 3.81800836683133E-003f, 2.44456078654209E-003f, 1.65134647076792E-003f, 1.13084424730725E-003f, 7.97503165599123E-004f, 5.62552521860549E-004f, 3.96776399429366E-004f, 2.80360036664540E-004f, 2.09299583354805E-004f, 1.63410794820518E-004f, 1.27869320250551E-004f, 1.00198406028040E-004f, 7.83611475491108E-005f, 6.13689891868496E-005f, 4.81280465299827E-005f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 const float float_buehlmann_He_factor_expositon_003_second[] = { 1.82658845044263E-002f, 1.14103491926518E-002f, 7.31576933570466E-003f, 4.94586307993539E-003f, 3.38869776192019E-003f, 2.39060197012086E-003f, 1.68670834759044E-003f, 1.18985696621965E-003f, 8.40844326779777E-004f, 6.27767340286467E-004f, 4.90152279561396E-004f, 3.83558911153159E-004f, 3.00565099928485E-004f, 2.35065021719993E-004f, 1.84095669333084E-004f, 1.44377190774980E-004f}; // 3 He
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 const float float_buehlmann_He_factor_expositon_008_second[] = { 4.79706116082057E-002f, 3.01390075707096E-002f, 1.93899772993034E-002f, 1.31346689569831E-002f, 9.01102820363486E-003f, 6.36224538449637E-003f, 4.49156910795023E-003f, 3.16980660943422E-003f, 2.24068067793926E-003f, 1.67317060331207E-003f, 1.30653891641375E-003f, 1.02249686330114E-003f, 8.01306192375617E-004f, 6.26717274191169E-004f, 4.90846474157092E-004f, 3.84959521834594E-004f}; // 8 He
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 const float float_buehlmann_He_factor_expositon_10_seconds[] = { 5.95993001714799E-002f, 3.75307444923134E-002f, 2.41784389107607E-002f, 1.63912909924208E-002f, 1.25106927410620E-002f, 7.94647192918641E-003f, 5.61130562069978E-003f, 3.96068706690245E-003f, 2.80006593100546E-003f, 2.09102564918129E-003f, 1.63290683272987E-003f, 1.27795767799976E-003f, 1.00153239354972E-003f, 7.33352120986130E-004f, 6.13520442722559E-004f, 4.81176244777948E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 const float float_buehlmann_He_factor_expositon_18_seconds[] = { 1.04710896899039E-001f, 6.65386126706349E-002f, 4.30995968284519E-002f, 2.93106657684409E-002f, 2.01607137751910E-002f, 1.42581599093282E-002f, 1.00776711616688E-002f, 7.11793906429403E-003f, 5.03447255531631E-003f, 3.76069760984632E-003f, 2.93731229281968E-003f, 2.29914783358365E-003f, 1.80203605181650E-003f, 1.40956155658090E-003f, 1.10406577253352E-003f, 8.65950533235460E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 const float float_buehlmann_He_factor_expositon_20_seconds[] = { 1.15646523762030E-001f, 7.36529322024796E-002f, 4.77722809133601E-002f, 3.25139075644434E-002f, 2.23755519884017E-002f, 1.58297974422514E-002f, 1.11911244906306E-002f, 7.90568709176287E-003f, 5.59229149279306E-003f, 4.17767891009702E-003f, 3.26314728073529E-003f, 2.55428218017273E-003f, 2.00206171996409E-003f, 1.56605681014277E-003f, 1.22666447811148E-003f, 9.62120958977297E-004f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 const float float_buehlmann_He_factor_expositon_one_minute[] = { 3.08363886219441E-001f, 2.05084082411030E-001f, 1.36579295730211E-001f, 9.44046323514587E-002f, 6.56358626478964E-002f, 4.67416115355790E-002f, 3.31990512604121E-002f, 2.35300557146709E-002f, 1.66832281977395E-002f, 1.24807506400979E-002f, 9.75753219809561E-003f, 7.64329013320042E-003f, 5.99416843126677E-003f, 4.69081666943783E-003f, 3.67548116287808E-003f, 2.88358673732592E-003f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 const float float_buehlmann_He_factor_expositon_100_second[] = { 4.59084487437744E-001f, 3.17867635141657E-001f, 2.17103957783539E-001f, 1.52336166567559E-001f, 1.06981885584572E-001f, 7.66825160768219E-002f, 5.47171474343117E-002f, 3.89083581201959E-002f, 2.76504642556165E-002f, 2.07145921483078E-002f, 1.62096019995457E-002f, 1.27063337640768E-002f, 9.97030625587825E-003f, 7.80579708939710E-003f, 6.11829377951190E-003f, 4.80135692933603E-003f}; // 100 He
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 const float float_buehlmann_He_factor_expositon_five_minutes[]= { 8.41733751018722E-001f, 6.82600697933713E-001f, 5.20142493735619E-001f, 3.90924736715930E-001f, 2.87834706153524E-001f, 2.12857832580192E-001f, 1.55333364924147E-001f, 1.12242395185686E-001f, 8.06788883581406E-002f, 6.08653819753062E-002f, 4.78448115000141E-002f, 3.76366999883051E-002f, 2.96136888654287E-002f, 2.32350754744602E-002f, 1.82428098114835E-002f, 1.43350223887367E-002f}; // thre
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 const float float_buehlmann_He_factor_expositon_800_second[] = { 9.92671155759686E-001f, 9.53124140216102E-001f, 8.58865632718416E-001f, 7.33443528431762E-001f, 5.95533881446524E-001f, 4.71787742036413E-001f, 3.62479376011699E-001f, 2.72021750877104E-001f, 2.00940186773410E-001f, 1.54187175639359E-001f, 1.22553521140786E-001f, 9.72431193565182E-002f, 7.70338702477497E-002f, 6.07666995543268E-002f, 4.79109397391700E-002f, 3.77715319879068E-002f}; // 800 He
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 const float float_buehlmann_He_factor_expositon_one_hour[]= { 9.99999999753021E-001f, 9.99998954626205E-001f, 9.99850944669188E-001f, 9.97393537149572E-001f, 9.82979603888650E-001f, 9.43423231328217E-001f, 8.68106292901111E-001f, 7.60374619482322E-001f, 6.35576141220644E-001f, 5.29310840978539E-001f, 4.44744511849213E-001f, 3.68942936079581E-001f, 3.02834419265355E-001f, 2.45810174422126E-001f, 1.98231319020275E-001f, 1.59085372294989E-001f};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 void decom_get_inert_gases(const float ambient_pressure_bar,const SGas* pGas, float* fraction_nitrogen, float* fraction_helium )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 float fraction_all_inertgases;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 float ppo2_fraction_setpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 float diluent_divisor;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 *fraction_nitrogen = ((float)pGas->nitrogen_percentage) / 100.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 *fraction_helium = ((float)pGas->helium_percentage) / 100.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
224 if(pGas->AppliedDiveMode == DIVEMODE_CCR)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
225 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
226 // continue with CCR
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
227 fraction_all_inertgases = *fraction_nitrogen + *fraction_helium;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
229 ppo2_fraction_setpoint = (float)pGas->setPoint_cbar/ (100 * ambient_pressure_bar);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
230
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
231 diluent_divisor = (1.0f - ppo2_fraction_setpoint) / fraction_all_inertgases;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
232 if(diluent_divisor < 0)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
233 diluent_divisor = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
235 *fraction_nitrogen *= diluent_divisor;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
236 *fraction_helium *= diluent_divisor;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
237 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
238 if(pGas->AppliedDiveMode == DIVEMODE_PSCR)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
239 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
240 fraction_all_inertgases = *fraction_nitrogen + *fraction_helium;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
241 ppo2_fraction_setpoint = decom_calc_SimppO2(ambient_pressure_bar, pGas) / ambient_pressure_bar;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
242 diluent_divisor = (1.0f - ppo2_fraction_setpoint) / fraction_all_inertgases;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
243 if(diluent_divisor < 0)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
244 diluent_divisor = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
246 *fraction_nitrogen *= diluent_divisor;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
247 *fraction_helium *= diluent_divisor;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
248 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 void decom_tissues_exposure(int period_in_seconds, SLifeData * pLifeData)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 decom_tissues_exposure2(period_in_seconds, &pLifeData->actualGas, pLifeData->pressure_ambient_bar, pLifeData->tissue_nitrogen_bar, pLifeData->tissue_helium_bar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 void decom_tissues_exposure2(int period_in_seconds, SGas* pActualGas, float ambiant_pressure_bar, float *tissue_N2_selected_stage, float *tissue_He_selected_stage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 int ci;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 float percent_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 float percent_He;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 float partial_pressure_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 float partial_pressure_He;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 int period_in_seconds_left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
270 if(period_in_seconds > 0)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
271 {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 decom_get_inert_gases(ambiant_pressure_bar, pActualGas, &percent_N2, &percent_He);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 partial_pressure_N2 = (ambiant_pressure_bar - WATER_VAPOUR_PRESSURE) * percent_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 partial_pressure_He = (ambiant_pressure_bar - WATER_VAPOUR_PRESSURE) * percent_He;
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
277 period_in_seconds_left = period_in_seconds;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
279 while(period_in_seconds_left)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
280 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
281 if(period_in_seconds_left >= 3600)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
282 period_in_seconds = 3600;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
283 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
284 if(period_in_seconds_left >= 800)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
285 period_in_seconds = 800;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
286 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
287 if(period_in_seconds_left >= 300)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
288 period_in_seconds = 300;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
289 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
290 if(period_in_seconds_left >= 100)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
291 period_in_seconds = 100;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
292 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
293 if(period_in_seconds_left >= 60)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
294 period_in_seconds = 60;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
295 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
296 if(period_in_seconds_left == 36)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
297 period_in_seconds = 18;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
298 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
299 if(period_in_seconds_left >= 20)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
300 period_in_seconds = 20;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
301 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
302 if(period_in_seconds_left >= 18)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
303 period_in_seconds = 18;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
304 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
305 if(period_in_seconds_left >= 10)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
306 period_in_seconds = 10;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
307 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
308 if(period_in_seconds_left >= 8)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
309 period_in_seconds = 8;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
310 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
311 if(period_in_seconds_left >= 3)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
312 period_in_seconds = 3;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
313 else
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
314 period_in_seconds = 1;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
316 period_in_seconds_left -= period_in_seconds;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
318 switch (period_in_seconds)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 {
57
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
320 case 1:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
321 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
322 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
323 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_one_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
324 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_one_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
325 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
326 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
327 case 3:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
328 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
329 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
330 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_003_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
331 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_003_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
332 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
333 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
334 case 8:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
335 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
336 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
337 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_008_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
338 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_008_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
339 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
340 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
341 case 10:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
342 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
343 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
344 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_10_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
345 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_10_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
346 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
347 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
348 case 18:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
349 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
350 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
351 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_18_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
352 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_18_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
353 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
354 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
355 case 20:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
356 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
357 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
358 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_20_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
359 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_20_seconds[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
360 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
361 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
362 case 60:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
363 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
364 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
365 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_one_minute[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
366 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_one_minute[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
367 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
368 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
369 case 100:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
370 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
371 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
372 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_100_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
373 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_100_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
374 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
375 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
376 case 300:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
377 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
378 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
379 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_five_minutes[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
380 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_five_minutes[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
381 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
382 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
383 case 800:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
384 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
385 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
386 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_800_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
387 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_800_second[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
388 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
389 break;
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
390 case 3600:
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
391 for (ci=0;ci<16;ci++)
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
392 {
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
393 tissue_N2_selected_stage[ci] += (partial_pressure_N2 - tissue_N2_selected_stage[ci]) * float_buehlmann_N2_factor_expositon_one_hour[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
394 tissue_He_selected_stage[ci] += (partial_pressure_He - tissue_He_selected_stage[ci]) * float_buehlmann_He_factor_expositon_one_hour[ci];
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
395 }
e941c9e49f73 Resolve format warnings
Ideenmodellierer
parents: 38
diff changeset
396 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
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 void decom_reset_with_1000mbar(SLifeData * pLifeData)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 double saturation = 1.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 saturation -= WATER_VAPOUR_PRESSURE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 saturation *= FRACTION_N2_AIR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 for(int i=0;i<16;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 pLifeData->tissue_nitrogen_bar[i] = saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 pLifeData->tissue_helium_bar[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 pLifeData->otu = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 pLifeData->cns = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 pLifeData->desaturation_time_minutes = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 pLifeData->no_fly_time_minutes = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419
129
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
420 void decom_reset_with_ambientmbar(float ambient, SLifeData * pLifeData)
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
421 {
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
422
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
423 float saturation = 1.0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
424 saturation = ambient;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
425 saturation -= WATER_VAPOUR_PRESSURE;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
426 saturation *= FRACTION_N2_AIR;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
427
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
428 for(int i=0;i<16;i++)
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
429 {
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
430 pLifeData->tissue_nitrogen_bar[i] = saturation;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
431 pLifeData->tissue_helium_bar[i] = 0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
432 }
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
433 pLifeData->otu = 0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
434 pLifeData->cns = 0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
435 pLifeData->desaturation_time_minutes = 0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
436 pLifeData->no_fly_time_minutes = 0;
239aa58b533d Added function to initialise structures with the actual ambient pressure
Ideenmodellierer
parents: 57
diff changeset
437 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 /* NOTE ABOUT PRESSURE UNITS USED IN CALCULATIONS: */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 /* It is the convention in decompression calculations to compute all gas */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 /* loadings, absolute pressures, partial pressures, etc., in the units of */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 /* depth pressure that you are diving - either feet of seawater (fsw) or */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 /* meters of seawater (msw). This program follows that convention with the */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 /* the exception that all VPM calculations are performed in SI units (by */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 /* necessity). Accordingly, there are several conversions back and forth */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 /* between the diving pressure units and the SI units. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 /* FUNCTION SUBPROGRAM FOR GAS LOADING CALCULATIONS - ASCENT AND DESCENT */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 float decom_schreiner_equation(float *initial_inspired_gas_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 float *rate_change_insp_gas_pressure,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 float *interval_time_minutes,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 const float *gas_time_constant,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 float *initial_gas_pressure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 /* System generated locals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 float ret_val;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 float time_null_pressure = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 float time_rest = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 float time = *interval_time_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 /* Note: The Schreiner equation is applied when calculating the uptake or */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 /* elimination of compartment gases during linear ascents or descents at a */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 /* constant rate. For ascents, a negative number for rate must be used. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* =============================================================================== */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 if( *rate_change_insp_gas_pressure < 0.0f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 time_null_pressure = -1.0f * *initial_inspired_gas_pressure / *rate_change_insp_gas_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 if(time > time_null_pressure )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 time_rest = time - time_null_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 time = time_null_pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 ret_val =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 *initial_inspired_gas_pressure +
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 *rate_change_insp_gas_pressure *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 (time - 1.f / *gas_time_constant) -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 (*initial_inspired_gas_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 *initial_gas_pressure -
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 *rate_change_insp_gas_pressure / *gas_time_constant) *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 expf(-(*gas_time_constant) * time);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 if(time_rest > 0.0f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 ret_val = ret_val * expf(-(*gas_time_constant) * time_rest);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 return ret_val;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 }; /* schreiner_equation__2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 void decom_tissues_exposure_stage_schreiner(int period_in_seconds, SGas* pGas, float starting_ambient_pressure_bar, float ending_ambient_pressure_bar,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 float* pTissue_nitrogen_bar, float* pTissue_helium_bar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 float initial_pressure_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 float initial_pressure_He;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 float ending_pressure_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 float ending_pressure_He;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 float fraction_N2_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 float fraction_N2_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 float fraction_He_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 float fraction_He_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 float rate_N2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 float rate_He;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 float period_in_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 int ci;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 if(period_in_seconds <= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 decom_get_inert_gases(starting_ambient_pressure_bar, pGas, &fraction_N2_begin, &fraction_He_begin );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 decom_get_inert_gases(ending_ambient_pressure_bar, pGas, &fraction_N2_end, &fraction_He_end );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 initial_pressure_N2 = (starting_ambient_pressure_bar - WATER_VAPOUR_PRESSURE) * fraction_N2_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 initial_pressure_He = (starting_ambient_pressure_bar - WATER_VAPOUR_PRESSURE) * fraction_He_begin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 ending_pressure_N2 = (ending_ambient_pressure_bar - WATER_VAPOUR_PRESSURE) * fraction_N2_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 ending_pressure_He = (ending_ambient_pressure_bar - WATER_VAPOUR_PRESSURE) * fraction_He_end;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 rate_N2 = (ending_pressure_N2 - initial_pressure_N2) / period_in_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 rate_He = (ending_pressure_He - initial_pressure_He) / period_in_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 period_in_minutes = ((float)period_in_seconds) / 60.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 for (ci=0;ci<16;ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 pTissue_nitrogen_bar[ci] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 decom_schreiner_equation(
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 &initial_pressure_N2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 &rate_N2,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 &period_in_minutes,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 &nitrogen_time_constant[ci],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 &pTissue_nitrogen_bar[ci]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 pTissue_helium_bar[ci] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 decom_schreiner_equation(
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 &initial_pressure_He,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 &rate_He,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 &period_in_minutes,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 &helium_time_constant[ci],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 &pTissue_helium_bar[ci]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 _Bool nextSetpointChange(SDiveSettings* pDiveSettings, uint8_t depth_meter, uint8_t* change_depth_meter, char* setpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 uint8_t new_depth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 char new_setpoint = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 for(int i = 1; i <= 5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 if(pDiveSettings->setpoint[i].setpoint_cbar > 0 && pDiveSettings->setpoint[i].depth_meter > 0 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 if( pDiveSettings->setpoint[i].depth_meter > new_depth && pDiveSettings->setpoint[i].depth_meter < depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 new_depth = pDiveSettings->setpoint[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 new_setpoint = pDiveSettings->setpoint[i].setpoint_cbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 if(new_depth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 * change_depth_meter = new_depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 * setpoint = new_setpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
581 void insertGasIntoList(SGasLine* pGas, SGasLine** pGasList, uint8_t gasInSettings, uint8_t* pGasInSettingsList, uint8_t GasListLength)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
582 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
583 uint8_t localGasIndex = GasListLength;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
584 if(pGas != 0)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
585 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
586 while(localGasIndex != 0) /* first entry */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
587 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
588 if(pGasList[localGasIndex-1]->depth_meter > pGas->depth_meter) /* switch depth of existing gas is deeper then new one => move down */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
589 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
590 pGasList[localGasIndex] = pGasList[localGasIndex-1];
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
591 pGasInSettingsList[localGasIndex] = pGasInSettingsList[localGasIndex - 1];
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
592 localGasIndex--;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
593 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
594 else
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
595 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
596 break;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
597 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
598 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
599 pGasList[localGasIndex] = pGas;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
600 pGasInSettingsList[localGasIndex] = gasInSettings;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
601 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
602 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 void decom_CreateGasChangeList(SDiveSettings* pInput, const SLifeData* pLifeData)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 {
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
606 SGasLine localPSCRFirst;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
607 SGasLine *pLocalGasList[5] = {0,0,0,0,0};
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
608 uint8_t localGasInSettingsList[5] = {0,0,0,0,0};
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
609
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
610 uint8_t gasStart = 1;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
611 uint8_t gasIndex = 0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
612 uint8_t gasEntryCnt = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
614 int i=0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
615 for(i=0;i< 5;i++) /* reset list */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
616 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
617 pInput->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero = 0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
618 pInput->decogaslist[i].GasIdInSettings = 255;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
619 pInput->decogaslist[i].setPoint_cbar = 0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
620 pInput->decogaslist[i].helium_percentage = 0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
621 pInput->decogaslist[i].nitrogen_percentage = 0;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
622 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
623 /* FirstGas
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
624 * 0 = special gas, 1 to 5 is OC gas, 6 to 10 is diluent
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
625 */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
626 pInput->decogaslist[0] = pLifeData->actualGas;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
627 /* Add Deco Gases
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
628 * special (gasId == 0) is never a deco/travel gas but actual gas only
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
629 */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
630
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
631 if(pInput->diveMode != DIVEMODE_OC)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
632 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
633 gasStart = 6; /* CCR or PSCR => CC gaslist */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
634 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
635
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
636 if(pInput->diveMode == DIVEMODE_PSCR) /* Handle first gas as deco gas */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
637 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
638 for(gasIndex = gasStart; gasIndex < gasStart + 5; gasIndex++)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
639 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
640 if(pInput->gas[gasIndex].note.ub.first)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
641 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
642 if (pLifeData->actualGas.GasIdInSettings != gasIndex)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
643 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
644 memcpy(&localPSCRFirst, &pInput->gas[gasIndex], sizeof(SGasLine));
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
645 localPSCRFirst.depth_meter = calc_MOD(gasIndex);
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
646 insertGasIntoList(&localPSCRFirst, pLocalGasList, gasIndex, localGasInSettingsList, gasEntryCnt);
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
647 gasEntryCnt++;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
648 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 }
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
650 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
651 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
652 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
655 for(gasIndex = gasStart; gasIndex < gasStart + 5; gasIndex++)
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
656 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
657 if(((pInput->gas[gasIndex].note.ub.active) && (pInput->gas[gasIndex].depth_meter)) /* ready for deco calculation */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
658 && (pLifeData->actualGas.GasIdInSettings != gasIndex) /* not the actual gas */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
659 && (pInput->gas[gasIndex].depth_meter < pLifeData->depth_meter )) /* a gas which is on the way to surface */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 {
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
661 insertGasIntoList(&pInput->gas[gasIndex], pLocalGasList, gasIndex, localGasInSettingsList, gasEntryCnt);
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
662 gasEntryCnt++;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 }
855
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
664 }
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
665 for(gasIndex = 1; gasIndex < gasEntryCnt+1; gasIndex++) /* move gasLine Information into deco List */
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
666 {
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
667 pInput->decogaslist[gasIndex].change_during_ascent_depth_meter_otherwise_zero = pLocalGasList[gasIndex-1]->depth_meter;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
668 pInput->decogaslist[gasIndex].nitrogen_percentage = 100;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
669 pInput->decogaslist[gasIndex].nitrogen_percentage -= pLocalGasList[gasIndex-1]->oxygen_percentage;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
670 pInput->decogaslist[gasIndex].nitrogen_percentage -= pLocalGasList[gasIndex-1]->helium_percentage;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
671 pInput->decogaslist[gasIndex].helium_percentage = pLocalGasList[gasIndex-1]->helium_percentage;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
672 pInput->decogaslist[gasIndex].GasIdInSettings = localGasInSettingsList[gasIndex-1];
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
673 pInput->decogaslist[gasIndex].AppliedDiveMode = pInput->diveMode;
012f94ec2fe0 Redefine Deco gas creation function:
Ideenmodellierer
parents: 684
diff changeset
674 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 void test_decom_CreateGasChangeList(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 SDiveSettings diveSetting;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 SLifeData lifeData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 lifeData.depth_meter = 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 lifeData.actualGas.helium_percentage = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 lifeData.actualGas.nitrogen_percentage = 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 lifeData.actualGas.setPoint_cbar = 18;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 lifeData.actualGas.GasIdInSettings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 lifeData.actualGas.change_during_ascent_depth_meter_otherwise_zero = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 diveSetting.diveMode = DIVEMODE_CCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 diveSetting.gas[6].depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 diveSetting.gas[6].helium_percentage = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 diveSetting.gas[6].oxygen_percentage = 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 diveSetting.gas[6].note.ub.active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 diveSetting.gas[7].depth_meter = 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 diveSetting.gas[7].helium_percentage = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 diveSetting.gas[7].oxygen_percentage = 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 diveSetting.gas[7].note.ub.active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 diveSetting.gas[8].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 diveSetting.gas[9].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 diveSetting.gas[10].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 diveSetting.setpoint[0].depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 diveSetting.setpoint[1].depth_meter = 80;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 diveSetting.setpoint[1].setpoint_cbar = 20;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 diveSetting.setpoint[2].depth_meter = 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 diveSetting.setpoint[2].setpoint_cbar = 25;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 diveSetting.setpoint[3].depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 diveSetting.setpoint[4].depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 diveSetting.setpoint[5].depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 decom_CreateGasChangeList(&diveSetting, &lifeData);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 uint8_t decom_tissue_test_tolerance(float* Tissue_nitrogen_bar, float* Tissue_helium_bar, float GF_value, float depth_in_bar_absolute)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 float tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 float inertgas_a;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 float inertgas_b;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 float inertgas_tolerance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 float gf_minus_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 gf_minus_1 = GF_value - 1.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 for (int ci = 0; ci < 16; ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 if(Tissue_helium_bar[ci] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 tissue_inertgas_saturation = Tissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 inertgas_a = buehlmann_N2_a[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 inertgas_b = buehlmann_N2_b[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 tissue_inertgas_saturation = Tissue_nitrogen_bar[ci] + Tissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 inertgas_a = ( ( buehlmann_N2_a[ci] * Tissue_nitrogen_bar[ci]) + ( buehlmann_He_a[ci] * Tissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 inertgas_b = ( ( buehlmann_N2_b[ci] * Tissue_nitrogen_bar[ci]) + ( buehlmann_He_b[ci] * Tissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 inertgas_tolerance = ( (GF_value / inertgas_b - gf_minus_1) * depth_in_bar_absolute ) + ( GF_value * inertgas_a );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 if(inertgas_tolerance < tissue_inertgas_saturation)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 void decom_tissues_desaturation_time(const SLifeData* pLifeData, SLifeData2* pOutput)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 float pressure_in_gas_for_complete;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 float pressure_in_gas_for_desat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 float diff_to_complete;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 float diff_to_desatpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 float necessary_halftimes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 float desattime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 pressure_in_gas_for_complete = 0.7902f * ( pLifeData->pressure_surface_bar - 0.0627f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 pressure_in_gas_for_desat = 1.05f * pressure_in_gas_for_complete;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 for(int i=0; i<16; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 diff_to_complete = pressure_in_gas_for_complete - pLifeData->tissue_nitrogen_bar[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 diff_to_desatpoint = pressure_in_gas_for_desat - pLifeData->tissue_nitrogen_bar[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 if((diff_to_desatpoint >= 0) || (diff_to_complete >= 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 pOutput->tissue_nitrogen_desaturation_time_minutes[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 necessary_halftimes = (logf(1.0f - (diff_to_desatpoint/diff_to_complete)) / -0.6931f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 desattime = buehlmann_N2_t_halflife[i] * necessary_halftimes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 if(desattime <= (float)0xFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 pOutput->tissue_nitrogen_desaturation_time_minutes[i] = desattime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 pOutput->tissue_nitrogen_desaturation_time_minutes[i] = 0xFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 for(int i=0; i<16; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 diff_to_desatpoint = 0.05f - pLifeData->tissue_helium_bar[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 diff_to_complete = -1.0f * pLifeData->tissue_helium_bar[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 if((diff_to_desatpoint >= 0) || (diff_to_complete >= 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 pOutput->tissue_helium_desaturation_time_minutes[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 necessary_halftimes = (logf(1.0f - (diff_to_desatpoint/diff_to_complete)) / -0.6931f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 desattime = buehlmann_He_t_halflife[i] * necessary_halftimes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 if(desattime <= (float)0xFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 pOutput->tissue_helium_desaturation_time_minutes[i] = desattime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 pOutput->tissue_helium_desaturation_time_minutes[i] = 0xFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 #define MAX_DEGRADE_OTU_TIME_MINUTES (1440)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 //CNS&OTU:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 #define OXY_TEN_MINUTES_IN_SECONDS (600)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 #define OXY_HALF_LIVE_OF_TEN_MINUTES__INVERSE_NINTH_ROOT_OF_TWO (0.92587471f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 #define OXY_NINE_DAYS_IN_TEN_MINUTES (1296)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 #define OXY_ONE_SIXTIETH_PART (0.0166667f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 #define OXY_NEGATIVE_FIVE_SIXTH_PARTS (-0.8333333f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 void decom_oxygen_calculate_otu(float* oxygen_otu, float pressure_oxygen_real)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 if(pressure_oxygen_real <= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 *oxygen_otu += (pow((double)(0.5f / (pressure_oxygen_real - 0.5f)),OXY_NEGATIVE_FIVE_SIXTH_PARTS)) * OXY_ONE_SIXTIETH_PART;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 void decom_oxygen_calculate_otu_degrade(float* oxygen_otu, long seconds_since_last_dive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 static long otu_time_ticker = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 static double otu_degrade_every_10_minutes = 999.9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 long cycles_since_last_call;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 if((*oxygen_otu <= 0) || (seconds_since_last_dive == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 *oxygen_otu = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 else if(seconds_since_last_dive < OXY_TEN_MINUTES_IN_SECONDS)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 otu_time_ticker = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 otu_degrade_every_10_minutes = *oxygen_otu / (MAX_DEGRADE_OTU_TIME_MINUTES / 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 cycles_since_last_call = seconds_since_last_dive / (otu_time_ticker * OXY_TEN_MINUTES_IN_SECONDS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 *oxygen_otu -= ((double)cycles_since_last_call) * otu_degrade_every_10_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 otu_time_ticker += cycles_since_last_call;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 if((*oxygen_otu < 0) || (otu_time_ticker > (MAX_DEGRADE_OTU_TIME_MINUTES / 10)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 *oxygen_otu = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 void decom_oxygen_calculate_cns_degrade(float* oxygen_cns, long seconds_since_last_dive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 static long cns_time_ticker = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 int cns_max_cycles;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 if((*oxygen_cns <= 0.5f) || (seconds_since_last_dive == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 *oxygen_cns = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 else if(seconds_since_last_dive < OXY_TEN_MINUTES_IN_SECONDS)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 cns_time_ticker = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 cns_max_cycles = OXY_NINE_DAYS_IN_TEN_MINUTES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 while((*oxygen_cns >= 0.5f) && ((cns_time_ticker * OXY_TEN_MINUTES_IN_SECONDS) < seconds_since_last_dive) && cns_max_cycles)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 cns_time_ticker++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 cns_max_cycles--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 *oxygen_cns *= OXY_HALF_LIVE_OF_TEN_MINUTES__INVERSE_NINTH_ROOT_OF_TWO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 // new hwOS style
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 void decom_oxygen_calculate_cns(float* oxygen_cns, float pressure_oxygen_real)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 uint8_t char_I_actual_ppO2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 float CNS_fraction = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 const float time_factor = 3000.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 if(pressure_oxygen_real < 0.15f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 char_I_actual_ppO2 = 15;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 if(pressure_oxygen_real >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 char_I_actual_ppO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 char_I_actual_ppO2 = (uint8_t)(pressure_oxygen_real * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 if (char_I_actual_ppO2 < 50)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 (void)0; // no changes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 //------------------------------------------------------------------------
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 // Below (and including) 1.60 bar
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 else if (char_I_actual_ppO2 < 61)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 CNS_fraction += time_factor/(-533.07f * char_I_actual_ppO2 + 54000.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 else if (char_I_actual_ppO2 < 71)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 CNS_fraction += time_factor/(-444.22f * char_I_actual_ppO2 + 48600.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 else if (char_I_actual_ppO2 < 81)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 CNS_fraction += time_factor/(-355.38f * char_I_actual_ppO2 + 42300.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 else if (char_I_actual_ppO2 < 91)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 CNS_fraction += time_factor/(-266.53f * char_I_actual_ppO2 + 35100.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 else if (char_I_actual_ppO2 < 111)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 CNS_fraction += time_factor/(-177.69f * char_I_actual_ppO2 + 27000.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 else if (char_I_actual_ppO2 < 152)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 CNS_fraction += time_factor/( -88.84f * char_I_actual_ppO2 + 17100.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 else if (char_I_actual_ppO2 < 167)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 CNS_fraction += time_factor/(-222.11f * char_I_actual_ppO2 + 37350.0f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 //------------------------------------------------------------------------
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 // J Appl Physiol 92: 248--256, 2002, doi:10.1152/japplphysiol.00434.2001
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 // Formula (A1) based on value for 1.55 and c=20
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 // example calculation: Sqrt((1.7/1.55)^20)*0.000404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 else if (char_I_actual_ppO2 < 172)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 CNS_fraction += time_factor*0.00102f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 else if (char_I_actual_ppO2 < 177)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 CNS_fraction += time_factor*0.00136f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 else if (char_I_actual_ppO2 < 182)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 CNS_fraction += time_factor*0.00180f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 else if (char_I_actual_ppO2 < 187)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 CNS_fraction += time_factor*0.00237f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 else if (char_I_actual_ppO2 < 192)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 CNS_fraction += time_factor*0.00310f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 else if (char_I_actual_ppO2 < 198)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 CNS_fraction += time_factor*0.00401f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 else if (char_I_actual_ppO2 < 203)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 CNS_fraction += time_factor*0.00517f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 else if (char_I_actual_ppO2 < 233)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911 CNS_fraction += time_factor*0.0209f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 CNS_fraction += time_factor*0.0482f; // value for 2.5
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 if( CNS_fraction > 999.0f) // Limit display to 999%
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 CNS_fraction = 999.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 if( CNS_fraction < 0.0f )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 CNS_fraction = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 //calculate cns for the actual ppo2 for 1 second
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 *oxygen_cns += OXY_ONE_SIXTIETH_PART * CNS_fraction;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 if( *oxygen_cns > 999.0f) // Limit display to 999%
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 *oxygen_cns = 999.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 if( *oxygen_cns < 0.0f )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 *oxygen_cns = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 /* old DR5 style
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 void decom_oxygen_calculate_cns(float* oxygen_cns, float pressure_oxygen_real)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 int cns_no_range = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 _Bool not_found = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 //for the cns calculation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 const float cns_ppo2_ranges[60][2] = {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 {0.50f, 0.00f}, {0.60f, 0.14f}, {0.64f, 0.15f}, {0.66f, 0.16f}, {0.68f, 0.17f}, {0.70f, 0.18f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 {0.74f, 0.19f}, {0.76f, 0.20f}, {0.78f, 0.21f}, {0.80f, 0.22f}, {0.82f, 0.23f}, {0.84f, 0.24f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 {0.86f, 0.25f}, {0.88f, 0.26f}, {0.90f, 0.28f}, {0.92f, 0.29f}, {0.94f, 0.30f}, {0.96f, 0.31f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 {0.98f, 0.32f}, {1.00f, 0.33f}, {1.02f, 0.35f}, {1.04f, 0.36f}, {1.06f, 0.38f}, {1.08f, 0.40f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 {1.10f, 0.42f}, {1.12f, 0.43f}, {1.14f, 0.43f}, {1.16f, 0.44f}, {1.18f, 0.46f}, {1.20f, 0.47f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 {1.22f, 0.48f}, {1.24f, 0.51f}, {1.26f, 0.52f}, {1.28f, 0.54f}, {1.30f, 0.56f}, {1.32f, 0.57f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 {1.34f, 0.60f}, {1.36f, 0.62f}, {1.38f, 0.63f}, {1.40f, 0.65f}, {1.42f, 0.68f}, {1.44f, 0.71f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 {1.46f, 0.74f}, {1.48f, 0.78f}, {1.50f, 0.83f}, {1.52f, 0.93f}, {1.54f, 1.04f}, {1.56f, 1.19f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 {1.58f, 1.47f}, {1.60f, 2.22f}, {1.62f, 5.00f}, {1.65f, 6.25f}, {1.67f, 7.69f}, {1.70f, 10.0f},
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 {1.72f,12.50f}, {1.74f,20.00f}, {1.77f,25.00f}, {1.79f,31.25f}, {1.80f,50.00f}, {1.82f,100.0f}};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 //find the correct cns range for the corresponding ppo2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 cns_no_range = 58;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 while (cns_no_range && not_found)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 if (pressure_oxygen_real > cns_ppo2_ranges[cns_no_range][0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 cns_no_range++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 not_found = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 cns_no_range--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 //calculate cns for the actual ppo2 for 1 second
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 *oxygen_cns += OXY_ONE_SIXTIETH_PART * cns_ppo2_ranges[cns_no_range][1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 void decom_oxygen_calculate_cns_exposure(int period_in_seconds, SGas* pActualGas, float pressure_ambient_bar, float* oxygen_cns)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 float pressure_oxygen_real;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 float one_second_cns;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 pressure_oxygen_real = decom_calc_ppO2(pressure_ambient_bar, pActualGas);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 one_second_cns = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 decom_oxygen_calculate_cns(&one_second_cns, pressure_oxygen_real);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 *oxygen_cns += one_second_cns * period_in_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 void decom_oxygen_calculate_cns_stage_SchreinerStyle(int period_in_seconds, SGas* pGas, float starting_ambient_pressure_bar, float ending_ambient_pressure_bar, float* oxygen_cns)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 if(ending_ambient_pressure_bar == starting_ambient_pressure_bar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 decom_oxygen_calculate_cns_exposure(period_in_seconds, pGas, starting_ambient_pressure_bar, oxygen_cns);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 float pressure_oxygen_real;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 float initial_pressure_oxygen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 float ending_pressure_oxygen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 float rate_oxygen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 initial_pressure_oxygen = decom_calc_ppO2(starting_ambient_pressure_bar, pGas);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 ending_pressure_oxygen = decom_calc_ppO2(ending_ambient_pressure_bar, pGas);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 rate_oxygen = (ending_pressure_oxygen - initial_pressure_oxygen) / period_in_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 pressure_oxygen_real = initial_pressure_oxygen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 for(int i = 0; i < period_in_seconds; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997 decom_oxygen_calculate_cns(oxygen_cns, pressure_oxygen_real);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 pressure_oxygen_real += rate_oxygen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 float decom_calc_ppO2(const float ambiant_pressure_bar, const SGas* pGas)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1005 float percent_N2 = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 float percent_He = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 float percent_O2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1009 decom_get_inert_gases(ambiant_pressure_bar, pGas, &percent_N2, &percent_He);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1010 percent_O2 = 1 - percent_N2 - percent_He;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1011
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1012 return (ambiant_pressure_bar - WATER_VAPOUR_PRESSURE) * percent_O2;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1016 float decom_calc_SimppO2(float ambiant_pressure_bar, const SGas* pGas)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1017 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1018 float o2Ratio = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1019 float inertGasRatio = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1020 float simulatedPSCRppo2 = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1021
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1022 o2Ratio = (100.0 - pGas->nitrogen_percentage - pGas->helium_percentage) / 100.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1023 inertGasRatio = 1.0 - o2Ratio;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1024 simulatedPSCRppo2 = (ambiant_pressure_bar - WATER_VAPOUR_PRESSURE) * o2Ratio;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1025 simulatedPSCRppo2 -= (inertGasRatio * pGas->pscr_factor);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1026 if(simulatedPSCRppo2 < 0.0)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1027 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1028 simulatedPSCRppo2 = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1029 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1030 return simulatedPSCRppo2;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1031 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1032
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1033 float decom_calc_SimppO2_O2based(float ambiant_pressure_bar, uint8_t O2PerCent, float factor)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1034 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1035 float o2Ratio = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1036 float inertGasRatio = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1037 float simulatedPSCRppo2 = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1038
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1039 o2Ratio = O2PerCent / 100.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1040 inertGasRatio = 1.0 - o2Ratio;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1041 simulatedPSCRppo2 = (ambiant_pressure_bar - WATER_VAPOUR_PRESSURE) * o2Ratio;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1042 simulatedPSCRppo2 -= (inertGasRatio * factor);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1043 if(simulatedPSCRppo2 < 0.0)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1044 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1045 simulatedPSCRppo2 = 0.0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1046 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1047 return simulatedPSCRppo2;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1048 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 129
diff changeset
1049
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 uint8_t decom_get_actual_deco_stop(SDiveState* pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 SDecoinfo* pDecoinfo;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 uint8_t depthNext, depthLast, depthSecond, depthInc;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 pDecoinfo = &pDiveState->decolistBuehlmann;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 pDecoinfo = &pDiveState->decolistVPM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 depthLast = (uint8_t)(pDiveState->diveSettings.last_stop_depth_bar * 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 depthSecond = (uint8_t)(pDiveState->diveSettings.input_second_to_last_stop_depth_bar * 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 depthInc = (uint8_t)(pDiveState->diveSettings.input_next_stop_increment_depth_bar * 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 if(pDecoinfo->output_stop_length_seconds[0] > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 depthNext = depthLast;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 for(int i = DECOINFO_STRUCT_MAX_STOPS -1 ;i > 0; i--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 if(pDecoinfo->output_stop_length_seconds[i] > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 depthNext = depthSecond + ( (i - 1) * depthInc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 return depthNext;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 // ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 // decom_calc_desaturation_time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 /// @brief This code is used to calculate desat, calculated by RTE and send to Firmware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 /// similar but more technical in code than decom_tissues_desaturation_time()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 /// the later has 0.05 for helium in contrast to this one.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 /// This one goes down to 70%, the oterh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 /// output is desat time in minutes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 // ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 int decom_calc_desaturation_time(float* Tissue_nitrogen_bar, float* Tissue_helium_bar, float surface_pressure_bar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 const float N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 float pres_surface;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 float temp_atem;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 float float_desaturation_multiplier;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 float temp1,temp2,temp3,temp4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 int ci;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 int int_temp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 int int_O_desaturation_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 pres_surface = ((float)surface_pressure_bar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 temp_atem = N2_ratio * (pres_surface - 0.0627f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103 int_O_desaturation_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 float_desaturation_multiplier = 100 / 142.0f; // new in v.101 (70,42%/100.=142)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 for (ci=0;ci<16;ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 // saturation_time (for flight) and N2_saturation in multiples of halftime
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and noFly calculations
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 // N2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 temp1 = 1.05f * temp_atem;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 temp1 = temp1 - (float)Tissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 temp2 = temp_atem - (float)Tissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 if (temp2 >= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 temp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 temp2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 temp1 = temp1 / temp2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 if (temp1 > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 temp1 = logf(1.0f - temp1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 temp1 = temp1 / -0.6931f; // temp1 is the multiples of half times necessary.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 // minus because log is negative
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131 temp2 = buehlmann_N2_t_halflife[ci] * temp1 / float_desaturation_multiplier; // time necessary (in minutes ) for complete desaturation (see comment about 10 percent) , new in v.101: float_desaturation_multiplier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 temp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136 temp2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 // He
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 temp3 = 0.1f - (float)Tissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 if (temp3 >= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 temp3 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 temp4 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 temp3 = -1.0f * temp3 / (float)Tissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 if (temp3 > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 temp3 = logf(1.0f - temp3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 temp3 = temp3 / -0.6931f; // temp1 is the multiples of half times necessary.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 // minus because log is negative
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 temp4 = buehlmann_He_t_halflife[ci] * temp3 / float_desaturation_multiplier; // time necessary (in minutes ) for "complete" desaturation, new in v.101 float_desaturation_multiplier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158 temp3 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 temp4 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 // saturation_time (for flight)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 if (temp4 > temp2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 int_temp = (int)temp4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 int_temp = (int)temp2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 if(int_temp > int_O_desaturation_time)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 int_O_desaturation_time = int_temp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 /*// N2 saturation in multiples of halftime for display purposes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 temp2 = temp2 + 80.0; // set center
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 if (temp2 < 0.0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174 temp2 = 0.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 if (temp2 > 255.0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 temp2 = 255.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 U8_tissue_N2_saturation[ci] = (U8)temp2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 // He saturation in multiples of halftime for display purposes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 temp4 = temp4 + 80.0; // set center
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 if (temp4 < 0.0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 temp4 = 0.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 if (temp4 > 255.0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 temp4 = 255.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 U8_tissue_He_saturation[ci] = (char)temp4;*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 return int_O_desaturation_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 }