summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deco.c45
-rw-r--r--divelist.c2
-rw-r--r--qt-ui/profile/diveprofileitem.cpp4
3 files changed, 32 insertions, 19 deletions
diff --git a/deco.c b/deco.c
index f5ffb8958..ffa8ed4ba 100644
--- a/deco.c
+++ b/deco.c
@@ -29,7 +29,7 @@ struct buehlmann_config {
double gf_low_position_min; //! gf_low_position below surface_min_shallow.
bool gf_low_at_maxdepth; //! if true, gf_low applies at max depth instead of at deepest ceiling.
};
-struct buehlmann_config buehlmann_config = { 1.0, 1.01, 0, 0.75, 0.35, 2.0, false };
+struct buehlmann_config buehlmann_config = { 1.0, 1.01, 0, 0.75, 0.35, 1.0, false };
const double buehlmann_N2_a[] = { 1.1696, 1.0, 0.8618, 0.7562,
0.62, 0.5043, 0.441, 0.4,
@@ -90,38 +90,49 @@ double tolerated_by_tissue[16];
static double tissue_tolerance_calc(const struct dive *dive)
{
int ci = -1;
- double tissue_inertgas_saturation, buehlmann_inertgas_a, buehlmann_inertgas_b;
+ double tissue_inertgas_saturation[16], buehlmann_inertgas_a[16], buehlmann_inertgas_b[16];
double ret_tolerance_limit_ambient_pressure = 0.0;
double gf_high = buehlmann_config.gf_high;
double gf_low = buehlmann_config.gf_low;
double surface = get_surface_pressure_in_mbar(dive, true) / 1000.0;
+ double lowest_ceiling = 0.0;
+ double tissue_lowest_ceiling[16];
for (ci = 0; ci < 16; ci++) {
- double tolerated;
+ tissue_inertgas_saturation[ci] = tissue_n2_sat[ci] + tissue_he_sat[ci];
+ buehlmann_inertgas_a[ci] = ((buehlmann_N2_a[ci] * tissue_n2_sat[ci]) + (buehlmann_He_a[ci] * tissue_he_sat[ci])) / tissue_inertgas_saturation[ci];
+ buehlmann_inertgas_b[ci] = ((buehlmann_N2_b[ci] * tissue_n2_sat[ci]) + (buehlmann_He_b[ci] * tissue_he_sat[ci])) / tissue_inertgas_saturation[ci];
- tissue_inertgas_saturation = tissue_n2_sat[ci] + tissue_he_sat[ci];
- buehlmann_inertgas_a = ((buehlmann_N2_a[ci] * tissue_n2_sat[ci]) + (buehlmann_He_a[ci] * tissue_he_sat[ci])) / tissue_inertgas_saturation;
- buehlmann_inertgas_b = ((buehlmann_N2_b[ci] * tissue_n2_sat[ci]) + (buehlmann_He_b[ci] * tissue_he_sat[ci])) / tissue_inertgas_saturation;
/* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
+ tissue_lowest_ceiling[ci] = (buehlmann_inertgas_b[ci] * tissue_inertgas_saturation[ci] - gf_low * buehlmann_inertgas_a[ci] * buehlmann_inertgas_b[ci]) /
+ ((1.0 - buehlmann_inertgas_b[ci]) * gf_low + buehlmann_inertgas_b[ci]);
+ if (tissue_lowest_ceiling[ci] > lowest_ceiling)
+ lowest_ceiling = tissue_lowest_ceiling[ci];
if (!buehlmann_config.gf_low_at_maxdepth) {
- double 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;
}
+ }
+ for (ci = 0; ci <16; ci++) {
+ double tolerated;
+
+ if ((surface / buehlmann_inertgas_b[ci] + buehlmann_inertgas_a[ci] - surface) * gf_high + surface <
+ (gf_low_pressure_this_dive / buehlmann_inertgas_b[ci] + buehlmann_inertgas_a[ci] - gf_low_pressure_this_dive) * gf_low + gf_low_pressure_this_dive)
+ tolerated = (-buehlmann_inertgas_a[ci] * buehlmann_inertgas_b[ci] * (gf_high * gf_low_pressure_this_dive - gf_low * surface) -
+ (1.0 - buehlmann_inertgas_b[ci]) * (gf_high - gf_low) * gf_low_pressure_this_dive * surface +
+ buehlmann_inertgas_b[ci] * (gf_low_pressure_this_dive - surface) * tissue_inertgas_saturation[ci]) /
+ (-buehlmann_inertgas_a[ci] * buehlmann_inertgas_b[ci] * (gf_high - gf_low) +
+ (1.0 - buehlmann_inertgas_b[ci]) * (gf_low * gf_low_pressure_this_dive - gf_high * surface) +
+ buehlmann_inertgas_b[ci] * (gf_low_pressure_this_dive - surface));
+ else
+ tolerated = ret_tolerance_limit_ambient_pressure;
- tolerated = (-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) /
- (-buehlmann_inertgas_a * buehlmann_inertgas_b * (gf_high - gf_low) +
- (1.0 - buehlmann_inertgas_b) * (gf_low * gf_low_pressure_this_dive - gf_high * surface) +
- buehlmann_inertgas_b * (gf_low_pressure_this_dive - surface));
tolerated_by_tissue[ci] = tolerated;
- if (tolerated > ret_tolerance_limit_ambient_pressure) {
+ if (tolerated >= ret_tolerance_limit_ambient_pressure) {
ci_pointing_to_guiding_tissue = ci;
ret_tolerance_limit_ambient_pressure = tolerated;
}
@@ -231,7 +242,9 @@ void clear_deco(double surface_pressure)
tissue_n2_sat[ci] = (surface_pressure - WV_PRESSURE) * N2_IN_AIR / 1000;
tissue_he_sat[ci] = 0.0;
}
- gf_low_pressure_this_dive = surface_pressure + buehlmann_config.gf_low_position_min;
+ gf_low_pressure_this_dive = surface_pressure;
+ if (!buehlmann_config.gf_low_at_maxdepth)
+ gf_low_pressure_this_dive += buehlmann_config.gf_low_position_min;
}
void cache_deco_state(double tissue_tolerance, char **cached_datap)
diff --git a/divelist.c b/divelist.c
index ff493393d..81dd16e87 100644
--- a/divelist.c
+++ b/divelist.c
@@ -345,7 +345,7 @@ int get_divenr(struct dive *dive)
return -1;
}
-static struct gasmix air = { .o2.permille = O2_IN_AIR };
+static struct gasmix air = { .o2.permille = O2_IN_AIR, .he.permille = 0 };
/* take into account previous dives until there is a 48h gap between dives */
double init_decompression(struct dive *dive)
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 0e8b63533..c63f9ecc4 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -167,9 +167,9 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
int max = maxCeiling(i);
- if (entry->depth < max) {
+ // Don't screem if we violate the ceiling by a few cm
+ if (entry->depth < max - 100)
profileColor = QColor(Qt::red);
- }
}
}