Fix deco calculations to correctly use GF values and add CC support

The old implementation was broken in several ways.

For one thing the GF values are percentages, so they should normally be
0 < GF < 1 (well, some crazy people like to go above that).

With this most of the Bühlmann config constants were wrong.

Furthermore, after we adjust the pressure tolerance based on the gradient
factors, we need to convert this back into a depth (instead of passing
back the unmodified depth - oops).

Finally, this commit adds closed circuit support to the deco calculations.

Major progress and much more useful at this stage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-01-03 23:56:10 -08:00
parent 75b970f7ac
commit 6dc247ff78
5 changed files with 34 additions and 20 deletions

View file

@ -834,8 +834,10 @@ static void add_dive_to_deco(struct dive *dive)
int j;
for (j = t0; j < t1; j++) {
int depth = 0.5 + psample->depth.mm + (j - t0) * (sample->depth.mm - psample->depth.mm) / (t1 - t0);
(void) add_segment(depth_to_mbar(depth, dive) / 1000.0, &dive->cylinder[sample->sensor].gasmix, 1);
int depth = 0.5 + psample->depth.mm + (j - t0) *
(sample->depth.mm - psample->depth.mm) / (t1 - t0);
(void) add_segment(depth_to_mbar(depth, dive) / 1000.0,
&dive->cylinder[sample->sensor].gasmix, 1, sample->po2 / 1000.0);
}
}
}
@ -879,7 +881,7 @@ void init_decompression(struct dive *dive)
printf("added dive #%d\n", pdive->number);
dump_tissues();
#endif
add_segment(surface_pressure, &air, surface_time);
add_segment(surface_pressure, &air, surface_time, 0.0);
#if DEBUG & 16
printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60));
dump_tissues();