diff options
author | Rick Walsh <rickmwalsh@gmail.com> | 2015-09-12 12:10:54 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-12 08:20:10 -0700 |
commit | 304edb63ced5e3c47a854bebf373751e05d1b321 (patch) | |
tree | cc07f11e475a75f65b77ffdf5e85ff98b49b5b96 /planner.c | |
parent | af66ad9b6dcb331faf2073904c6c48813eb46c26 (diff) | |
download | subsurface-304edb63ced5e3c47a854bebf373751e05d1b321.tar.gz |
VPM-B: Calculate ceiling in deepest portion of dive
The Boyle's law compensation compares the ambient pressure to a baseline value,
and adjusts the theory bubble radius accordingly. Currently we use the ceiling
at the last user-entered waypoint (the start of the decompression phase) as the
baseline value. However, in a deep to shallow multi-level dive, decompression
can start earlier, and taking a shallower ceiling leads to a more aggressive
ascent. This is particularly noticeable if the user enters stops during ascent.
With this commit, we take the baseline ambient pressure for Boyle's law
compensation as the deeper of the:
(1) Ceiling prior to ascending during a user-entered portion of the dive, and
(2) Ceiling at the start of the last user-entered waypoint.
This makes the calculated profile more conservative for some deep to shallow
multi-level dives.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -33,7 +33,7 @@ int decostoplevels_imperial[] = { 0, 3048, 6096, 9144, 12192, 15240, 18288, 2133 double plangflow, plangfhigh; bool plan_verbatim, plan_display_runtime, plan_display_duration, plan_display_transitions; -pressure_t first_ceiling_pressure; +pressure_t first_ceiling_pressure, max_bottom_ceiling_pressure = {}; const char *disclaimer; @@ -141,6 +141,30 @@ void tissue_at_end(struct dive *dive, char **cached_datap) get_gas_at_time(dive, dc, t0, &gas); if (i > 0) lastdepth = psample->depth; + + /* The ceiling in the deeper portion of a multilevel dive is sometimes critical for the VPM-B + * Boyle's law compensation. We should check the ceiling prior to ascending during the bottom + * portion of the dive. The maximum ceiling might be reached while ascending, but testing indicates + * that it is only marginally deeper than the ceiling at the start of ascent. + * Do not set the first_ceiling_pressure variable (used for the Boyle's law compensation calculation) + * at this stage, because it would interfere with calculating the ceiling at the end of the bottom + * portion of the dive. + * Remember the value for later. + */ + if ((prefs.deco_mode == VPMB) && (lastdepth.mm > sample->depth.mm)) { + pressure_t ceiling_pressure; + nuclear_regeneration(t0.seconds); + vpmb_start_gradient(); + ceiling_pressure.mbar = depth_to_mbar(deco_allowed_depth(tissue_tolerance_calc(dive, + depth_to_bar(lastdepth.mm, dive)), + dive->surface_pressure.mbar / 1000.0, + dive, + 1), + dive); + if (ceiling_pressure.mbar > max_bottom_ceiling_pressure.mbar) + max_bottom_ceiling_pressure.mbar = ceiling_pressure.mbar; + } + interpolate_transition(dive, t0, t1, lastdepth, sample->depth, &gas, sample->setpoint); psample = sample; t0 = t1; @@ -1133,6 +1157,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool &displayed_dive, 1), &displayed_dive); + if (max_bottom_ceiling_pressure.mbar > first_ceiling_pressure.mbar) + first_ceiling_pressure.mbar = max_bottom_ceiling_pressure.mbar; last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time); if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) { |