mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
planner: pass in_planner argument to vpmb_next_gradient()
To remove reliance on global state, pass an "in_planner" argument to vpmb_next_gradient(). Thus, calls to in_planner() can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
93ecad1b04
commit
8103e947aa
4 changed files with 9 additions and 9 deletions
|
@ -308,9 +308,9 @@ static double factor(int period_in_seconds, int ci, enum gas_component gas)
|
|||
return 1.0 - exp(-period_in_seconds * 1.155245301e-02 / buehlmann_He_t_halflife[ci]);
|
||||
}
|
||||
|
||||
static double calc_surface_phase(double surface_pressure, double he_pressure, double n2_pressure, double he_time_constant, double n2_time_constant)
|
||||
static double calc_surface_phase(double surface_pressure, double he_pressure, double n2_pressure, double he_time_constant, double n2_time_constant, bool in_planner)
|
||||
{
|
||||
double inspired_n2 = (surface_pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
|
||||
double inspired_n2 = (surface_pressure - ((in_planner && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
|
||||
|
||||
if (n2_pressure > inspired_n2)
|
||||
return (he_pressure / he_time_constant + (n2_pressure - inspired_n2) / n2_time_constant) / (he_pressure + n2_pressure - inspired_n2);
|
||||
|
@ -334,7 +334,7 @@ void vpmb_start_gradient(struct deco_state *ds)
|
|||
}
|
||||
}
|
||||
|
||||
void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure)
|
||||
void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure, bool in_planner)
|
||||
{
|
||||
int ci;
|
||||
double n2_b, n2_c;
|
||||
|
@ -343,7 +343,7 @@ void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_
|
|||
deco_time /= 60.0;
|
||||
|
||||
for (ci = 0; ci < 16; ++ci) {
|
||||
desat_time = deco_time + calc_surface_phase(surface_pressure, ds->tissue_he_sat[ci], ds->tissue_n2_sat[ci], log(2.0) / buehlmann_He_t_halflife[ci], log(2.0) / buehlmann_N2_t_halflife[ci]);
|
||||
desat_time = deco_time + calc_surface_phase(surface_pressure, ds->tissue_he_sat[ci], ds->tissue_n2_sat[ci], log(2.0) / buehlmann_He_t_halflife[ci], log(2.0) / buehlmann_N2_t_halflife[ci], in_planner);
|
||||
|
||||
n2_b = ds->initial_n2_gradient[ci] + (vpmb_config.crit_volume_lambda * vpmb_config.surface_tension_gamma) / (vpmb_config.skin_compression_gammaC * desat_time);
|
||||
he_b = ds->initial_he_gradient[ci] + (vpmb_config.crit_volume_lambda * vpmb_config.surface_tension_gamma) / (vpmb_config.skin_compression_gammaC * desat_time);
|
||||
|
|
|
@ -60,7 +60,7 @@ extern void cache_deco_state(struct deco_state *source, struct deco_state **data
|
|||
extern void restore_deco_state(struct deco_state *data, struct deco_state *target, bool keep_vpmb_state);
|
||||
extern void nuclear_regeneration(struct deco_state *ds, double time);
|
||||
extern void vpmb_start_gradient(struct deco_state *ds);
|
||||
extern void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure);
|
||||
extern void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure, bool in_planner);
|
||||
extern double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure);
|
||||
extern void calc_crushing_pressure(struct deco_state *ds, double pressure);
|
||||
extern void vpmb_start_gradient(struct deco_state *ds);
|
||||
|
|
|
@ -849,7 +849,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
decostopcounter = 0;
|
||||
is_final_plan = (decoMode() == BUEHLMANN) || (previous_deco_time - ds->deco_time < 10); // CVA time converges
|
||||
if (ds->deco_time != 10000000)
|
||||
vpmb_next_gradient(ds, ds->deco_time, diveplan->surface_pressure / 1000.0);
|
||||
vpmb_next_gradient(ds, ds->deco_time, diveplan->surface_pressure / 1000.0, true);
|
||||
|
||||
previous_deco_time = ds->deco_time;
|
||||
restore_deco_state(bottom_cache, ds, true);
|
||||
|
|
|
@ -1055,7 +1055,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
vpmb_start_gradient(ds);
|
||||
/* For CVA iterations, calculate next gradient */
|
||||
if (!first_iteration || !planner_ds)
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0);
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner);
|
||||
}
|
||||
entry->ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, !prefs.calcceiling3m);
|
||||
if (prefs.calcceiling3m)
|
||||
|
@ -1078,7 +1078,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
converges correctly, so add 30min*/
|
||||
if (!planner_ds)
|
||||
ds->deco_time = pi->maxtime - t1 + 1800;
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0);
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner);
|
||||
}
|
||||
}
|
||||
// Use the point where the ceiling clears as the end of deco phase for CVA calculations
|
||||
|
@ -1161,7 +1161,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
* comes typically 10-60s after the end of the bottom time, so add 20s to the calculated
|
||||
* deco time. */
|
||||
ds->deco_time = ROUND_UP(time_clear_ceiling - time_deep_ceiling + 20, 60) + 20;
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0);
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner);
|
||||
final_tts = 0;
|
||||
last_ndl_tts_calc_time = 0;
|
||||
first_ceiling = 0;
|
||||
|
|
Loading…
Reference in a new issue