summaryrefslogtreecommitdiffstats
path: root/deco.c
diff options
context:
space:
mode:
authorGravatar Jan Darowski <jan.darowski@gmail.com>2015-08-15 14:36:07 +0200
committerGravatar Jan Darowski <jan.darowski@gmail.com>2015-08-15 14:36:07 +0200
commitcad866013b6ea8f4bdabc3371b5d319209713fa7 (patch)
tree470dfef0cf51e0ce232e2c80aabce09b24d35bb0 /deco.c
parent499ec9af2fd152ec5b608eaacf53b2df33eec1d3 (diff)
downloadsubsurface-cad866013b6ea8f4bdabc3371b5d319209713fa7.tar.gz
VPM-B: Add conservatism levels to deco.c
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
Diffstat (limited to 'deco.c')
-rw-r--r--deco.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/deco.c b/deco.c
index 59415d8a9..934818647 100644
--- a/deco.c
+++ b/deco.c
@@ -89,6 +89,8 @@ const double buehlmann_He_factor_expositon_one_second[] = {
1.00198406028040E-004, 7.83611475491108E-005, 6.13689891868496E-005, 4.81280465299827E-005
};
+const double conservatism_lvls[] = { 1.0, 1.05, 1.12, 1.22, 1.35 };
+
#define WV_PRESSURE 0.0627 // water vapor pressure in bar
#define DECO_STOPS_MULTIPLIER_MM 3000.0
#define NITROGEN_FRACTION 0.79
@@ -121,6 +123,20 @@ double bottom_he_gradient[16];
double initial_n2_gradient[16];
double initial_he_gradient[16];
+double get_crit_radius_He()
+{
+ if (prefs.conservatism_level <= 4)
+ return vpmb_config.crit_radius_He * conservatism_lvls[prefs.conservatism_level];
+ return vpmb_config.crit_radius_He;
+}
+
+double get_crit_radius_N2()
+{
+ if (prefs.conservatism_level <= 4)
+ return vpmb_config.crit_radius_N2 * conservatism_lvls[prefs.conservatism_level];
+ return vpmb_config.crit_radius_N2;
+}
+
static double tissue_tolerance_calc(const struct dive *dive)
{
int ci = -1;
@@ -328,11 +344,11 @@ void nuclear_regeneration(double time)
double crushing_radius_N2, crushing_radius_He;
for (ci = 0; ci < 16; ++ci) {
//rm
- crushing_radius_N2 = 1.0 / (max_n2_crushing_pressure[ci] / (2.0 * (vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma)) + 1.0 / vpmb_config.crit_radius_N2);
- crushing_radius_He = 1.0 / (max_he_crushing_pressure[ci] / (2.0 * (vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma)) + 1.0 / vpmb_config.crit_radius_He);
+ crushing_radius_N2 = 1.0 / (max_n2_crushing_pressure[ci] / (2.0 * (vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma)) + 1.0 / get_crit_radius_N2());
+ crushing_radius_He = 1.0 / (max_he_crushing_pressure[ci] / (2.0 * (vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma)) + 1.0 / get_crit_radius_He());
//rs
- n2_regen_radius[ci] = crushing_radius_N2 + (vpmb_config.crit_radius_N2 - crushing_radius_N2) * (1.0 - exp (-time / vpmb_config.regeneration_time));
- he_regen_radius[ci] = crushing_radius_He + (vpmb_config.crit_radius_He - crushing_radius_He) * (1.0 - exp (-time / vpmb_config.regeneration_time));
+ n2_regen_radius[ci] = crushing_radius_N2 + (get_crit_radius_N2() - crushing_radius_N2) * (1.0 - exp (-time / vpmb_config.regeneration_time));
+ he_regen_radius[ci] = crushing_radius_He + (get_crit_radius_He() - crushing_radius_He) * (1.0 - exp (-time / vpmb_config.regeneration_time));
}
}
@@ -386,8 +402,8 @@ void calc_crushing_pressure(double pressure)
if (max_ambient_pressure >= pressure)
return;
- n2_inner_pressure = calc_inner_pressure(vpmb_config.crit_radius_N2, crushing_onset_tension[ci], pressure);
- he_inner_pressure = calc_inner_pressure(vpmb_config.crit_radius_He, crushing_onset_tension[ci], pressure);
+ n2_inner_pressure = calc_inner_pressure(get_crit_radius_N2(), crushing_onset_tension[ci], pressure);
+ he_inner_pressure = calc_inner_pressure(get_crit_radius_He(), crushing_onset_tension[ci], pressure);
n2_crushing_pressure = pressure - n2_inner_pressure;
he_crushing_pressure = pressure - he_inner_pressure;