diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-08-19 23:14:00 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-20 07:28:00 -0700 |
commit | 0bb65a17cb77084a345f12581b5b39f4dafcae4a (patch) | |
tree | 51cbce1e73959117fd43f174c97c19413227fa2a /deco.c | |
parent | 2a5073113927f5ab5e6f38a7ac6382bd44e7ad5b (diff) | |
download | subsurface-0bb65a17cb77084a345f12581b5b39f4dafcae4a.tar.gz |
Use boyle_compensation in profile
otherwise VPM-B planned profiles seem to violate the ceiling. This needs
the first_stop_pressure to be available also in the profile, so I made
it global in planner.c
Important lesson: If you want to use deco_allowed_depth on a tissue_tolerance
that comes from a VPM-B planned dive, you have to call boyles_law() before
add_segment()!
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'deco.c')
-rw-r--r-- | deco.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -23,6 +23,8 @@ extern bool in_planner(); +extern int first_stop_pressure; + //! Option structure for Buehlmann decompression. struct buehlmann_config { double satmult; //! safety at inert gas accumulation as percentage of effect (more than 100). @@ -344,24 +346,27 @@ double solve_cubic(double A, double B, double C) } -double update_gradient(double first_stop_pressure, double next_stop_pressure, double first_gradient) +double update_gradient(double next_stop_pressure, double first_gradient) { double first_radius = 2.0 * vpmb_config.surface_tension_gamma / first_gradient; double A = next_stop_pressure; double B = -2.0 * vpmb_config.surface_tension_gamma; - double C = (first_stop_pressure + 2.0 * vpmb_config.surface_tension_gamma / first_radius) * cube(first_radius); + double C = (first_stop_pressure / 1000.0 + 2.0 * vpmb_config.surface_tension_gamma / first_radius) * cube(first_radius); double next_radius = solve_cubic(A, B, C); return 2.0 * vpmb_config.surface_tension_gamma / next_radius; } -void boyles_law(double first_stop_pressure, double next_stop_pressure) +void boyles_law(double next_stop_pressure) { int ci; + + if (!first_stop_pressure) + return; for (ci = 0; ci < 16; ++ci) { - allowable_n2_gradient[ci] = update_gradient(first_stop_pressure, next_stop_pressure, bottom_n2_gradient[ci]); - allowable_he_gradient[ci] = update_gradient(first_stop_pressure, next_stop_pressure, bottom_he_gradient[ci]); + allowable_n2_gradient[ci] = update_gradient(next_stop_pressure, bottom_n2_gradient[ci]); + allowable_he_gradient[ci] = update_gradient(next_stop_pressure, bottom_he_gradient[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]); } |