diff options
-rw-r--r-- | deco.c | 8 | ||||
-rw-r--r-- | dive.h | 2 | ||||
-rw-r--r-- | divelist.c | 16 | ||||
-rw-r--r-- | planner.c | 4 | ||||
-rw-r--r-- | profile.c | 2 |
5 files changed, 16 insertions, 16 deletions
@@ -72,7 +72,7 @@ const double buehlmann_He_factor_expositon_one_second[] = { 2.80360036664540E-004, 2.09299583354805E-004, 1.63410794820518E-004, 1.27869320250551E-004, 1.00198406028040E-004, 7.83611475491108E-005, 6.13689891868496E-005, 4.81280465299827E-005}; -#define WV_PRESSURE 0.0627 /* water vapor pressure */ +#define WV_PRESSURE 0.0627 // water vapor pressure in bar #define DECO_STOPS_MULTIPLIER_MM 3000.0 #define GF_LOW_AT_MAXDEPTH 0 @@ -126,7 +126,7 @@ static double tissue_tolerance_calc(const struct dive *dive) } /* add period_in_seconds at the given pressure and gas to the deco calculation */ -double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds, double ccpo2, const struct dive *dive) +double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds, int ccpo2, const struct dive *dive) { int ci; int fo2 = gasmix->o2.permille ? gasmix->o2.permille : O2_IN_AIR; @@ -138,9 +138,9 @@ double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds gf_low_pressure_this_dive = pressure; #endif - if (ccpo2 > 0.0) { /* CC */ + if (ccpo2) { /* CC */ double rel_o2_amb, f_dilutent; - rel_o2_amb = ccpo2 / pressure; + rel_o2_amb = ccpo2 / pressure / 1000; f_dilutent = (1 - rel_o2_amb) / (1 - fo2 / 1000.0); if (f_dilutent < 0) { /* setpoint is higher than ambient pressure -> pure O2 */ ppn2 = 0.0; @@ -599,7 +599,7 @@ extern void subsurface_command_line_exit(gint *, gchar ***); #define FRACTION(n,x) ((unsigned)(n)/(x)),((unsigned)(n)%(x)) -extern double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds, double setpoint, const struct dive *dive); +extern double add_segment(double pressure, struct gasmix *gasmix, int period_in_seconds, int setpoint, const struct dive *dive); extern void clear_deco(double surface_pressure); extern void dump_tissues(void); extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth); diff --git a/divelist.c b/divelist.c index f7ed6e14d..e50039110 100644 --- a/divelist.c +++ b/divelist.c @@ -646,18 +646,18 @@ static int calculate_otu(struct dive *dive, struct divecomputer *dc) for (i = 1; i < dc->samples; i++) { int t; - double po2; + int po2; struct sample *sample = dc->sample + i; struct sample *psample = sample - 1; t = sample->time.seconds - psample->time.seconds; if (sample->po2) { - po2 = sample->po2 / 1000.0; + po2 = sample->po2; } else { int o2 = active_o2(dive, dc, sample->time); - po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive) / 1000.0; + po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive); } - if (po2 >= 0.5) - otu += pow(po2 - 0.5, 0.83) * t / 30.0; + if (po2 >= 500) + otu += pow((po2 - 500) / 1000.0, 0.83) * t / 30.0; } return otu + 0.5; } @@ -741,7 +741,7 @@ static void add_dive_to_deco(struct dive *dive) for (j = t0; j < t1; j++) { int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0); (void) add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[sample->sensor].gasmix, 1, sample->po2 / 1000.0, dive); + &dive->cylinder[sample->sensor].gasmix, 1, sample->po2, dive); } } } @@ -802,7 +802,7 @@ double init_decompression(struct dive *dive) if (pdive->when > lasttime) { surface_time = pdive->when - lasttime; lasttime = pdive->when + pdive->dc.duration.seconds; - tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0.0, dive); + tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive); #if DECO_CALC_DEBUG & 2 printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60)); dump_tissues(); @@ -813,7 +813,7 @@ double init_decompression(struct dive *dive) if (lasttime && dive->when > lasttime) { surface_time = dive->when - lasttime; surface_pressure = (dive->dc.surface_pressure.mbar ? dive->dc.surface_pressure.mbar : SURFACE_PRESSURE) / 1000; - tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0.0, dive); + tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive); #if DECO_CALC_DEBUG & 2 printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60)); dump_tissues(); @@ -112,7 +112,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap) for (j = t0; j < t1; j++) { int depth = interpolate(lastdepth, sample->depth.mm, j - t0, t1 - t0); tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[gasidx].gasmix, 1, sample->po2 / 1000.0, dive); + &dive->cylinder[gasidx].gasmix, 1, sample->po2, dive); } psample = sample; t0 = t1; @@ -139,7 +139,7 @@ int time_at_last_depth(struct dive *dive, int next_stop, char **cached_data_p) while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) { wait++; tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[gasidx].gasmix, 1, sample->po2 / 1000.0, dive); + &dive->cylinder[gasidx].gasmix, 1, sample->po2, dive); } return wait; } @@ -1877,7 +1877,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d for (j = t0+1; j <= t1; j++) { int depth = interpolate(entry[-1].depth, entry[0].depth, j - t0, t1 - t0); double min_pressure = add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[cylinderindex].gasmix, 1, entry->po2, dive); + &dive->cylinder[cylinderindex].gasmix, 1, entry->po2 * 1000, dive); tissue_tolerance = min_pressure; } if (t0 == t1) |