aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jan Darowski <jan.darowski@gmail.com>2015-07-03 23:19:57 +0200
committerGravatar Jan Darowski <jan.darowski@gmail.com>2015-07-03 23:19:57 +0200
commitfad592e43a26343fdef9cd3e0703be10d9069b20 (patch)
treee978a40b545d46cd319b44e189a8c01f7f19fd25
parent500fbe499411bfa96192626c8a6213916190aaae (diff)
downloadsubsurface-fad592e43a26343fdef9cd3e0703be10d9069b20.tar.gz
VPM-B: add initial gradient calculation.
Calculate the max difference between tissue saturation and ambient pressure that can be accepted during the ascent. Partial results are kept for later improving in next CVA iterations Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
-rw-r--r--deco.c17
-rw-r--r--dive.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/deco.c b/deco.c
index 0b221c225..ada13fbb0 100644
--- a/deco.c
+++ b/deco.c
@@ -110,6 +110,10 @@ double n2_regen_radius[16]; // rs
double he_regen_radius[16];
double max_ambient_pressure; // last moment we were descending
+double allowable_n2_gradient[16];
+double allowable_he_gradient[16];
+double total_gradient[16];
+
static double tissue_tolerance_calc(const struct dive *dive)
{
@@ -206,6 +210,19 @@ double he_factor(int period_in_seconds, int ci)
return cache[ci].last_factor;
}
+void vpmb_start_gradient()
+{
+ int ci;
+ double gradient_n2, gradient_he;
+
+ for (ci = 0; ci < 16; ++ci) {
+ allowable_n2_gradient[ci] = 2.0 * (vpmb_config.surface_tension_gamma / vpmb_config.skin_compression_gammaC) * ((vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma) / n2_regen_radius[ci]);
+ allowable_he_gradient[ci] = 2.0 * (vpmb_config.surface_tension_gamma / vpmb_config.skin_compression_gammaC) * ((vpmb_config.skin_compression_gammaC - vpmb_config.surface_tension_gamma) / he_regen_radius[ci]);
+
+ 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 8f0f84832..d9885184e 100644
--- a/dive.h
+++ b/dive.h
@@ -784,6 +784,7 @@ extern void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth);
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();
/* this should be converted to use our types */
struct divedatapoint {