mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added a configuration option to have gf_low apply at max depth instead of at deepest ceiling.
Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4c4a7a6d96
commit
fe2eabf375
9 changed files with 34 additions and 21 deletions
25
deco.c
25
deco.c
|
@ -27,8 +27,9 @@ struct buehlmann_config {
|
||||||
double gf_high; //! gradient factor high (at surface).
|
double gf_high; //! gradient factor high (at surface).
|
||||||
double gf_low; //! gradient factor low (at bottom/start of deco calculation).
|
double gf_low; //! gradient factor low (at bottom/start of deco calculation).
|
||||||
double gf_low_position_min; //! gf_low_position below surface_min_shallow.
|
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 };
|
struct buehlmann_config buehlmann_config = { 1.0, 1.01, 0, 0.75, 0.35, 2.0, FALSE };
|
||||||
|
|
||||||
const double buehlmann_N2_a[] = {1.1696, 1.0, 0.8618, 0.7562,
|
const double buehlmann_N2_a[] = {1.1696, 1.0, 0.8618, 0.7562,
|
||||||
0.62, 0.5043, 0.441, 0.4,
|
0.62, 0.5043, 0.441, 0.4,
|
||||||
|
@ -75,8 +76,6 @@ const double buehlmann_He_factor_expositon_one_second[] = {
|
||||||
#define WV_PRESSURE 0.0627 // water vapor pressure in bar
|
#define WV_PRESSURE 0.0627 // water vapor pressure in bar
|
||||||
#define DECO_STOPS_MULTIPLIER_MM 3000.0
|
#define DECO_STOPS_MULTIPLIER_MM 3000.0
|
||||||
|
|
||||||
#define GF_LOW_AT_MAXDEPTH 0
|
|
||||||
|
|
||||||
double tissue_n2_sat[16];
|
double tissue_n2_sat[16];
|
||||||
double tissue_he_sat[16];
|
double tissue_he_sat[16];
|
||||||
int ci_pointing_to_guiding_tissue;
|
int ci_pointing_to_guiding_tissue;
|
||||||
|
@ -94,7 +93,6 @@ static double tissue_tolerance_calc(const struct dive *dive)
|
||||||
double gf_high = buehlmann_config.gf_high;
|
double gf_high = buehlmann_config.gf_high;
|
||||||
double gf_low = buehlmann_config.gf_low;
|
double gf_low = buehlmann_config.gf_low;
|
||||||
double surface = get_surface_pressure_in_mbar(dive, TRUE) / 1000.0;
|
double surface = get_surface_pressure_in_mbar(dive, TRUE) / 1000.0;
|
||||||
double lowest_ceiling;
|
|
||||||
|
|
||||||
for (ci = 0; ci < 16; ci++)
|
for (ci = 0; ci < 16; ci++)
|
||||||
{
|
{
|
||||||
|
@ -106,12 +104,12 @@ static double tissue_tolerance_calc(const struct dive *dive)
|
||||||
|
|
||||||
/* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
|
/* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
|
||||||
|
|
||||||
#if !GF_LOW_AT_MAXDEPTH
|
if (!buehlmann_config.gf_low_at_maxdepth) {
|
||||||
lowest_ceiling = (buehlmann_inertgas_b * tissue_inertgas_saturation - gf_low * buehlmann_inertgas_a * buehlmann_inertgas_b) /
|
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);
|
((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b);
|
||||||
if (lowest_ceiling > gf_low_pressure_this_dive)
|
if (lowest_ceiling > gf_low_pressure_this_dive)
|
||||||
gf_low_pressure_this_dive = lowest_ceiling;
|
gf_low_pressure_this_dive = lowest_ceiling;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
tolerated = (-buehlmann_inertgas_a * buehlmann_inertgas_b * (gf_high * gf_low_pressure_this_dive - gf_low * surface) -
|
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 +
|
(1.0 - buehlmann_inertgas_b) * (gf_high - gf_low) * gf_low_pressure_this_dive * surface +
|
||||||
|
@ -139,10 +137,8 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s
|
||||||
double ppn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - fhe) / 1000.0;
|
double ppn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - fhe) / 1000.0;
|
||||||
double pphe = (pressure - WV_PRESSURE) * fhe / 1000.0;
|
double pphe = (pressure - WV_PRESSURE) * fhe / 1000.0;
|
||||||
|
|
||||||
#if GF_LOW_AT_MAXDEPTH
|
if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive)
|
||||||
if (pressure > gf_low_pressure_this_dive)
|
|
||||||
gf_low_pressure_this_dive = pressure;
|
gf_low_pressure_this_dive = pressure;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ccpo2) { /* CC */
|
if (ccpo2) { /* CC */
|
||||||
double rel_o2_amb, f_dilutent;
|
double rel_o2_amb, f_dilutent;
|
||||||
|
@ -268,10 +264,11 @@ unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressur
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_gf(short gflow, short gfhigh)
|
void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth)
|
||||||
{
|
{
|
||||||
if (gflow != -1)
|
if (gflow != -1)
|
||||||
buehlmann_config.gf_low = (double)gflow / 100.0;
|
buehlmann_config.gf_low = (double)gflow / 100.0;
|
||||||
if (gfhigh != -1)
|
if (gfhigh != -1)
|
||||||
buehlmann_config.gf_high = (double)gfhigh / 100.0;
|
buehlmann_config.gf_high = (double)gfhigh / 100.0;
|
||||||
|
buehlmann_config.gf_low_at_maxdepth = gf_low_at_maxdepth;
|
||||||
}
|
}
|
||||||
|
|
2
dive.h
2
dive.h
|
@ -715,7 +715,7 @@ extern double add_segment(double pressure, const struct gasmix *gasmix, int peri
|
||||||
extern void clear_deco(double surface_pressure);
|
extern void clear_deco(double surface_pressure);
|
||||||
extern void dump_tissues(void);
|
extern void dump_tissues(void);
|
||||||
extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
|
extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
|
||||||
extern void set_gf(short gflow, short gfhigh);
|
extern void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth);
|
||||||
extern void cache_deco_state(double, char **datap);
|
extern void cache_deco_state(double, char **datap);
|
||||||
extern double restore_deco_state(char *data);
|
extern double restore_deco_state(char *data);
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b
|
||||||
int gaschangenr;
|
int gaschangenr;
|
||||||
unsigned int *stoplevels = NULL;
|
unsigned int *stoplevels = NULL;
|
||||||
|
|
||||||
set_gf(diveplan->gflow, diveplan->gfhigh);
|
set_gf(diveplan->gflow, diveplan->gfhigh, default_prefs.gf_low_at_maxdepth);
|
||||||
if (!diveplan->surface_pressure)
|
if (!diveplan->surface_pressure)
|
||||||
diveplan->surface_pressure = SURFACE_PRESSURE;
|
diveplan->surface_pressure = SURFACE_PRESSURE;
|
||||||
if (*divep)
|
if (*divep)
|
||||||
|
|
3
pref.h
3
pref.h
|
@ -31,9 +31,8 @@ struct preferences {
|
||||||
short calc_ndl_tts;
|
short calc_ndl_tts;
|
||||||
short gflow;
|
short gflow;
|
||||||
short gfhigh;
|
short gfhigh;
|
||||||
int map_provider;
|
bool gf_low_at_maxdepth;
|
||||||
short display_invalid_dives;
|
short display_invalid_dives;
|
||||||
short show_invalid;
|
|
||||||
short unit_system;
|
short unit_system;
|
||||||
struct units units;
|
struct units units;
|
||||||
short show_sac;
|
short show_sac;
|
||||||
|
|
|
@ -564,6 +564,13 @@ bool MainWindow::askSaveChanges()
|
||||||
else \
|
else \
|
||||||
prefs.field = default_prefs.field
|
prefs.field = default_prefs.field
|
||||||
|
|
||||||
|
#define GET_TXT(name, field) \
|
||||||
|
v = s.value(QString(name)); \
|
||||||
|
if (v.isValid()) \
|
||||||
|
prefs.field = strdup(v.toString().toUtf8().constData()); \
|
||||||
|
else \
|
||||||
|
prefs.field = default_prefs.field
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::initialUiSetup()
|
void MainWindow::initialUiSetup()
|
||||||
{
|
{
|
||||||
|
@ -623,7 +630,8 @@ void MainWindow::readSettings()
|
||||||
GET_BOOL("calcalltissues", calc_all_tissues);
|
GET_BOOL("calcalltissues", calc_all_tissues);
|
||||||
GET_INT("gflow", gflow);
|
GET_INT("gflow", gflow);
|
||||||
GET_INT("gfhigh", gfhigh);
|
GET_INT("gfhigh", gfhigh);
|
||||||
set_gf(prefs.gflow, prefs.gfhigh);
|
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
|
||||||
|
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
|
||||||
GET_BOOL("show_sac", show_sac);
|
GET_BOOL("show_sac", show_sac);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
|
|
||||||
ui.gflow->setValue(prefs.gflow);
|
ui.gflow->setValue(prefs.gflow);
|
||||||
ui.gfhigh->setValue(prefs.gfhigh);
|
ui.gfhigh->setValue(prefs.gfhigh);
|
||||||
|
ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
|
||||||
|
|
||||||
// units
|
// units
|
||||||
if (prefs.unit_system == METRIC)
|
if (prefs.unit_system == METRIC)
|
||||||
|
@ -111,7 +112,7 @@ void PreferencesDialog::syncSettings()
|
||||||
s.setValue("pn2threshold", ui.pn2Threshold->value());
|
s.setValue("pn2threshold", ui.pn2Threshold->value());
|
||||||
SB("ead", ui.ead_end_eadd);
|
SB("ead", ui.ead_end_eadd);
|
||||||
SB("mod", ui.mod);
|
SB("mod", ui.mod);
|
||||||
s.setValue("modppo2", ui.maxppo2->value());
|
s.setValue("modppO2", ui.maxppo2->value());
|
||||||
SB("dcceiling", ui.dc_reported_ceiling);
|
SB("dcceiling", ui.dc_reported_ceiling);
|
||||||
SB("redceiling", ui.red_ceiling);
|
SB("redceiling", ui.red_ceiling);
|
||||||
SB("calcceiling", ui.calculated_ceiling);
|
SB("calcceiling", ui.calculated_ceiling);
|
||||||
|
@ -120,6 +121,7 @@ void PreferencesDialog::syncSettings()
|
||||||
SB("calcalltissues", ui.all_tissues);
|
SB("calcalltissues", ui.all_tissues);
|
||||||
s.setValue("gflow", ui.gflow->value());
|
s.setValue("gflow", ui.gflow->value());
|
||||||
s.setValue("gfhigh", ui.gfhigh->value());
|
s.setValue("gfhigh", ui.gfhigh->value());
|
||||||
|
SB("gf_low_at_maxdepth", ui.gf_low_at_maxdepth);
|
||||||
SB("show_sac", ui.show_sac);
|
SB("show_sac", ui.show_sac);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ public slots:
|
||||||
private:
|
private:
|
||||||
explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||||
void setUiFromPrefs();
|
void setUiFromPrefs();
|
||||||
void setUIFromSettings();
|
|
||||||
Ui::PreferencesDialog ui;
|
Ui::PreferencesDialog ui;
|
||||||
struct preferences oldPrefs;
|
struct preferences oldPrefs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -763,6 +763,13 @@
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QSpinBox" name="gfhigh"/>
|
<widget class="QSpinBox" name="gfhigh"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="gf_low_at_maxdepth">
|
||||||
|
<property name="text">
|
||||||
|
<string>GFLow at max depth</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -25,6 +25,7 @@ struct preferences default_prefs = {
|
||||||
.calc_ndl_tts = FALSE,
|
.calc_ndl_tts = FALSE,
|
||||||
.gflow = 30,
|
.gflow = 30,
|
||||||
.gfhigh = 75,
|
.gfhigh = 75,
|
||||||
|
.gf_low_at_maxdepth = FALSE,
|
||||||
.font_size = 14.0,
|
.font_size = 14.0,
|
||||||
.display_invalid_dives = FALSE,
|
.display_invalid_dives = FALSE,
|
||||||
.show_sac = FALSE,
|
.show_sac = FALSE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue