summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@lmu.de>2013-01-10 11:24:42 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-10 09:14:55 -0800
commit4c13f1f6b4ad7deb2071fb4848ddf43be0af4db7 (patch)
tree3321ab45971daa2a84c6d66045764c53adb4477e
parent1aa3c0d5147df7ef8846c955dffe7227257c5ca1 (diff)
downloadsubsurface-4c13f1f6b4ad7deb2071fb4848ddf43be0af4db7.tar.gz
Adjust GFlow to apply at deepest ceiling instead of at max depth
This moves the point where GF_low applies up which implies that at all shallower depth (i.e. during deco) a lower GF results which makes the deco longer compared to the previous implementation. Of course, "GF_low" applies at first deco stop is a bit tricky since the depth of the first deco stop again depends on GF_low, i.e. there is another equation to solve. You can do this by inverting the equation for the ambient pressure and use GF_low as the gradient factor. This yields amb = (b * M_value_corrected - GF_low * a * b) / ((1-b) * GF_low + b) Signed-off-by: Robert C. Helling helling@atdotde.de Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--deco.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/deco.c b/deco.c
index a313c05e9..0005ba18c 100644
--- a/deco.c
+++ b/deco.c
@@ -81,6 +81,8 @@ const double buehlmann_He_factor_expositon_one_second[] = {
#define N2_IN_AIR 0.7902
#define DECO_STOPS_MULTIPLIER_MM 3000.0
+#define GF_LOW_AT_MAXDEPTH 0
+
double tissue_n2_sat[16];
double tissue_he_sat[16];
double tissue_tolerated_ambient_pressure[16];
@@ -96,6 +98,7 @@ static double tissue_tolerance_calc(const struct dive *dive)
double gf_high = buehlmann_config.gf_high;
double gf_low = buehlmann_config.gf_low;
double surface = dive->surface_pressure.mbar / 1000.0;
+ double lowest_ceiling;
for (ci = 0; ci < 16; ci++)
{
@@ -105,6 +108,13 @@ static double tissue_tolerance_calc(const struct dive *dive)
/* tissue_tolerated_ambient_pressure[ci] = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
+#if !GF_LOW_AT_MAXDEPTH
+ lowest_ceiling = (buehlmann_inertgas_b * tissue_inertgas_saturation - gf_low * buehlmann_inertgas_a * buehlmann_inertgas_b) /
+ ((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b);
+ if(lowest_ceiling > gf_low_pressure_this_dive)
+ gf_low_pressure_this_dive = lowest_ceiling;
+#endif
+
tissue_tolerated_ambient_pressure[ci] = (-buehlmann_inertgas_a * buehlmann_inertgas_b * (gf_high * gf_low_pressure_this_dive - gf_low * surface) -
(1.0 - buehlmann_inertgas_b) * (gf_high - gf_low) * gf_low_pressure_this_dive * surface +
buehlmann_inertgas_b * (gf_low_pressure_this_dive - surface) * tissue_inertgas_saturation) /
@@ -129,8 +139,10 @@ double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds
double ppn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - gasmix->he.permille) / 1000.0;
double pphe = (pressure - WV_PRESSURE) * gasmix->he.permille / 1000.0;
+#if GF_LOW_AT_MAXDEPTH
if (pressure > gf_low_pressure_this_dive)
gf_low_pressure_this_dive = pressure;
+#endif
if (ccpo2 > 0.0) { /* CC */
double rel_o2_amb, f_dilutent;