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>
This commit is contained in:
Robert C. Helling 2014-09-15 14:55:20 +02:00 committed by Dirk Hohndel
parent ae6b0468b1
commit d6abb739d9
8 changed files with 61 additions and 60 deletions

22
deco.c
View file

@ -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;