From bfb9f1908050e4a42c2e626e00acde01c6c7d4da Mon Sep 17 00:00:00 2001 From: Jan Darowski Date: Fri, 3 Jul 2015 23:59:22 +0200 Subject: 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 --- deco.c | 24 ++++++++++++++++++++++++ dive.h | 1 + 2 files changed, 25 insertions(+) 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; diff --git a/dive.h b/dive.h index 9b44700e7..042878c1b 100644 --- a/dive.h +++ b/dive.h @@ -785,6 +785,7 @@ extern void cache_deco_state(double, char **datap); extern double restore_deco_state(char *data); extern void nuclear_regeneration(double time); extern void vpmb_start_gradient(); +extern void vpmb_next_gradient(double deco_time); extern bool is_vpmb_ok(double pressure); /* this should be converted to use our types */ -- cgit v1.2.3-70-g09d2