diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-25 15:23:16 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-25 16:48:16 -0800 |
commit | 308d71ec39a33a276362d93c0ff534575b8c293c (patch) | |
tree | 8334dd9e653e438dfad8da749d4288124b3e1380 /statistics.c | |
parent | d53bedbed6696cd7f9f79238d94189b0ed30c377 (diff) | |
download | subsurface-308d71ec39a33a276362d93c0ff534575b8c293c.tar.gz |
Take incompressibility of gas into account at higher pressures
This creates a helper function called "gas_volume()" that takes the
cylinder and a particular pressure, and returns the estimated volume of
the gas at surface pressure, including proper approximation of the
incompressibility of gas.
It very much is an approximation, but it's closer to reality than
assuming a pure ideal gas. See for example compressibility at
http://en.wikipedia.org/wiki/Compressibility_factor
Suggested-by: Jukka Lind <jukka.lind@iki.fi>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/statistics.c b/statistics.c index 9cbfcc72f..b6b618fbd 100644 --- a/statistics.c +++ b/statistics.c @@ -604,10 +604,10 @@ static void show_single_dive_stats(struct dive *dive) /* for the O2/He readings just create a list of them */ for (idx = 0; idx < MAX_CYLINDERS; idx++) { cylinder_t *cyl = &dive->cylinder[idx]; - unsigned int start, end; + pressure_t start, end; - start = cyl->start.mbar ? : cyl->sample_start.mbar; - end = cyl->end.mbar ? : cyl->sample_end.mbar; + start = cyl->start.mbar ? cyl->start : cyl->sample_start; + end = cyl->end.mbar ?cyl->sample_end : cyl->sample_end; if (!cylinder_none(cyl)) { /* 0% O2 strangely means air, so 21% - I don't like that at all */ int o2 = cyl->gasmix.o2.permille ? : O2_IN_AIR; @@ -621,8 +621,8 @@ static void show_single_dive_stats(struct dive *dive) } /* and if we have size, start and end pressure, we can * calculate the total gas used */ - if (cyl->type.size.mliter && start && end) - gas_used += cyl->type.size.mliter / 1000.0 * (start - end); + if (start.mbar && end.mbar) + gas_used += gas_volume(cyl, start) - gas_volume(cyl, end); } set_label(single_w.o2he, buf); if (gas_used) { |