Prepare global state of VPM-B when starting to plan

Otherwise, the results of the calculations tend to be rather
random and irreproducible...

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2015-08-23 16:04:59 +02:00 committed by Dirk Hohndel
parent cb375623f9
commit 41349c29dd
3 changed files with 13 additions and 1 deletions

2
deco.c
View file

@ -508,6 +508,8 @@ void clear_deco(double surface_pressure)
tissue_he_sat[ci] = 0.0; tissue_he_sat[ci] = 0.0;
max_n2_crushing_pressure[ci] = 0.0; max_n2_crushing_pressure[ci] = 0.0;
max_he_crushing_pressure[ci] = 0.0; max_he_crushing_pressure[ci] = 0.0;
n2_regen_radius[ci] = get_crit_radius_N2();
he_regen_radius[ci] = get_crit_radius_He();
} }
gf_low_pressure_this_dive = surface_pressure; gf_low_pressure_this_dive = surface_pressure;
if (!buehlmann_config.gf_low_at_maxdepth) if (!buehlmann_config.gf_low_at_maxdepth)

3
dive.h
View file

@ -830,6 +830,9 @@ struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix,
void dump_plan(struct diveplan *diveplan); void dump_plan(struct diveplan *diveplan);
#endif #endif
bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer); bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
void calc_crushing_pressure(double pressure);
void vpmb_start_gradient();
void delete_single_dive(int idx); void delete_single_dive(int idx);
struct event *get_next_event(struct event *event, const char *name); struct event *get_next_event(struct event *event, const char *name);

View file

@ -997,6 +997,13 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
create_dive_from_plan(diveplan, is_planner); create_dive_from_plan(diveplan, is_planner);
return(false); return(false);
} }
calc_crushing_pressure(depth_to_mbar(depth, &displayed_dive) / 1000.0);
nuclear_regeneration(clock);
clear_deco(displayed_dive.surface_pressure.mbar / 1000.0);
vpmb_start_gradient();
previous_deco_time = 100000000;
deco_time = 10000000;
tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap); tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap);
displayed_dive.surface_pressure.mbar = diveplan->surface_pressure; displayed_dive.surface_pressure.mbar = diveplan->surface_pressure;
@ -1124,7 +1131,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0); vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0);
previous_deco_time = deco_time; previous_deco_time = deco_time;
restore_deco_state(bottom_cache); tissue_tolerance = restore_deco_state(bottom_cache);
depth = bottom_depth; depth = bottom_depth;
gi = bottom_gi; gi = bottom_gi;