summaryrefslogtreecommitdiffstats
path: root/deco.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-09-15 14:55:20 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-09-18 06:20:25 -0700
commitd6abb739d927285b55964f0644ee059be5f7db0b (patch)
treea9f68411ee735e2f03d8227eeb768e7cafdacbab /deco.c
parentae6b0468b16200dcc01f8e1cfd43260b63e830dc (diff)
downloadsubsurface-d6abb739d927285b55964f0644ee059be5f7db0b.tar.gz
Helper function for partial pressure calculation
This patch introduces a new structure holding partial pressures (doubles in bar) for all three gases and a helper function to compute them from gasmix (which holds fractions) and ambient pressure. Currentlty this works for OC and CCR, to be extended later to PSCR. Currently the dive_comp_type argument is unused. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'deco.c')
-rw-r--r--deco.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/deco.c b/deco.c
index ffa8ed4ba..2a0ae940c 100644
--- a/deco.c
+++ b/deco.c
@@ -188,28 +188,16 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s
{
int ci;
int fo2 = get_o2(gasmix), fhe = get_he(gasmix);
- double pn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - fhe) / 1000.0;
- double phe = (pressure - WV_PRESSURE) * fhe / 1000.0;
+ struct gas_pressures pressures;
+
+ fill_pressures(&pressures, pressure, gasmix, (double) ccpo2 / 1000.0, dive->dc.dctype);
if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive)
gf_low_pressure_this_dive = pressure;
- if (ccpo2) { /* CC */
- double rel_o2_amb, f_dilutent;
- rel_o2_amb = ccpo2 / pressure / 1000;
- f_dilutent = (1 - rel_o2_amb) / (1 - fo2 / 1000.0);
- if (f_dilutent < 0) { /* setpoint is higher than ambient pressure -> pure O2 */
- pn2 = 0.0;
- phe = 0.0;
- } else if (f_dilutent < 1.0) {
- pn2 *= f_dilutent;
- phe *= f_dilutent;
- }
- }
-
for (ci = 0; ci < 16; ci++) {
- double pn2_oversat = pn2 - tissue_n2_sat[ci];
- double phe_oversat = phe - tissue_he_sat[ci];
+ double pn2_oversat = pressures.n2 - tissue_n2_sat[ci];
+ double phe_oversat = pressures.he - tissue_he_sat[ci];
double n2_f = n2_factor(period_in_seconds, ci);
double he_f = he_factor(period_in_seconds, ci);
double n2_satmult = pn2_oversat > 0 ? buehlmann_config.satmult : buehlmann_config.desatmult;