mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use our pressure type to avoid bar / mbar confusion
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
652f7e9864
commit
c7d8e72607
2 changed files with 10 additions and 10 deletions
8
deco.c
8
deco.c
|
@ -23,7 +23,7 @@
|
|||
|
||||
extern bool in_planner();
|
||||
|
||||
extern int first_stop_pressure;
|
||||
extern pressure_t first_stop_pressure;
|
||||
|
||||
//! Option structure for Buehlmann decompression.
|
||||
struct buehlmann_config {
|
||||
|
@ -351,7 +351,7 @@ 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 / 1000.0 + 2.0 * vpmb_config.surface_tension_gamma / first_radius) * cube(first_radius);
|
||||
double C = (first_stop_pressure.mbar / 1000.0 + 2.0 * vpmb_config.surface_tension_gamma / first_radius) * cube(first_radius);
|
||||
|
||||
double next_radius = solve_cubic(A, B, C);
|
||||
|
||||
|
@ -366,10 +366,10 @@ void boyles_law(double next_stop_pressure)
|
|||
return;
|
||||
|
||||
// This should be a tautology but prevents a numerical instability.
|
||||
if (IS_FP_SAME(next_stop_pressure, first_stop_pressure))
|
||||
if (IS_FP_SAME(next_stop_pressure, first_stop_pressure.mbar / 1000.0))
|
||||
return;
|
||||
|
||||
if (!first_stop_pressure)
|
||||
if (!first_stop_pressure.mbar)
|
||||
return;
|
||||
for (ci = 0; ci < 16; ++ci) {
|
||||
allowable_n2_gradient[ci] = update_gradient(next_stop_pressure, bottom_n2_gradient[ci]);
|
||||
|
|
12
planner.c
12
planner.c
|
@ -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;
|
||||
|
||||
int first_stop_pressure;
|
||||
pressure_t first_stop_pressure;
|
||||
|
||||
const char *disclaimer;
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
breaktime = -1;
|
||||
breakcylinder = 0;
|
||||
o2time = 0;
|
||||
first_stop_pressure = 0;
|
||||
first_stop_pressure.mbar = 0;
|
||||
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
||||
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
|
||||
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
||||
|
@ -1160,8 +1160,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
stopping = true;
|
||||
|
||||
// Boyles Law compensation
|
||||
if (first_stop_pressure == 0)
|
||||
first_stop_pressure = depth_to_mbar(depth, &displayed_dive);
|
||||
if (first_stop_pressure.mbar == 0)
|
||||
first_stop_pressure.mbar = depth_to_mbar(depth, &displayed_dive);
|
||||
boyles_law(depth_to_mbar(stoplevels[stopidx], &displayed_dive) / 1000.0);
|
||||
|
||||
/* Check we need to change cylinder.
|
||||
|
@ -1215,8 +1215,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
stopping = true;
|
||||
|
||||
// Boyles Law compensation
|
||||
if (first_stop_pressure == 0)
|
||||
first_stop_pressure = depth_to_mbar(depth, &displayed_dive);
|
||||
if (first_stop_pressure.mbar == 0)
|
||||
first_stop_pressure.mbar = depth_to_mbar(depth, &displayed_dive);
|
||||
boyles_law(depth_to_mbar(stoplevels[stopidx], &displayed_dive) / 1000.0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue