aboutsummaryrefslogtreecommitdiffstats
path: root/deco.c
diff options
context:
space:
mode:
authorGravatar Jan Darowski <jan.darowski@gmail.com>2015-07-03 23:59:22 +0200
committerGravatar Jan Darowski <jan.darowski@gmail.com>2015-07-03 23:59:22 +0200
commitbfb9f1908050e4a42c2e626e00acde01c6c7d4da (patch)
tree64dfdfdb4554c13cd8cab8a1202ce5c5a2f9bd62 /deco.c
parent02f13399177d301c9a1242ce0d342b7c91dd28fd (diff)
downloadsubsurface-bfb9f1908050e4a42c2e626e00acde01c6c7d4da.tar.gz
VPM-B: add next gradient calculation.
It improves (increases) gradients for all the compartments, so more free gas can be created in the divers body. Next gradients will converge, so the volume won't exceed the safe limit, indicated by the crit_volume_lambda parameter. Function takes time of the last deco in seconds. Requires vpmb_start_gradient() to be run before. Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
Diffstat (limited to 'deco.c')
-rw-r--r--deco.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/deco.c b/deco.c
index 47b752ee8..f1bc8039f 100644
--- a/deco.c
+++ b/deco.c
@@ -238,6 +238,30 @@ void vpmb_start_gradient()
}
}
+void vpmb_next_gradient(double deco_time)
+{
+ int ci;
+ double gradient_n2, gradient_he;
+ double n2_b, n2_c;
+ double he_b, he_c;
+ deco_time /= 60.0 ;
+
+ for (ci = 0; ci < 16; ++ci) {
+ n2_b = allowable_n2_gradient[ci] + ((vpmb_config.crit_volume_lambda * vpmb_config.surface_tension_gamma) / (vpmb_config.skin_compression_gammaC * (deco_time + buehlmann_N2_t_halflife[ci] * 60.0 / log(2.0))));
+ he_b = allowable_he_gradient[ci] + ((vpmb_config.crit_volume_lambda * vpmb_config.surface_tension_gamma) / (vpmb_config.skin_compression_gammaC * (deco_time + buehlmann_He_t_halflife[ci] * 60.0 / log(2.0))));
+
+ n2_c = vpmb_config.surface_tension_gamma * vpmb_config.surface_tension_gamma * vpmb_config.crit_volume_lambda * max_n2_crushing_pressure[ci];
+ n2_c = n2_c / (vpmb_config.skin_compression_gammaC * vpmb_config.skin_compression_gammaC * (deco_time + buehlmann_N2_t_halflife[ci] * 60.0 / log(2.0)));
+ he_c = vpmb_config.surface_tension_gamma * vpmb_config.surface_tension_gamma * vpmb_config.crit_volume_lambda * max_he_crushing_pressure[ci];
+ he_c = he_c / (vpmb_config.skin_compression_gammaC * vpmb_config.skin_compression_gammaC * (deco_time + buehlmann_He_t_halflife[ci] * 60.0 / log(2.0)));
+
+ allowable_n2_gradient[ci] = 0.5 * ( n2_b + sqrt(n2_b * n2_b - 4.0 * n2_c));
+ allowable_he_gradient[ci] = 0.5 * ( he_b + sqrt(he_b * he_b - 4.0 * he_c));
+
+ total_gradient[ci] = ((allowable_n2_gradient[ci] * tissue_n2_sat[ci]) + (allowable_he_gradient[ci] * tissue_he_sat[ci])) / (tissue_n2_sat[ci] + tissue_he_sat[ci]);
+ }
+}
+
void nuclear_regeneration(double time)
{
time /= 60.0;