aboutsummaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-02-24 10:01:18 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-24 10:49:26 -0800
commitf4bf16d5db5151a9b1a2fc1523ec930baf98e9b3 (patch)
tree86c570a70e8ac3626b0cd72b98935fd642e38cd4 /divelist.c
parent1f20d5feed41ce509601435cb32645b473436ec8 (diff)
downloadsubsurface-f4bf16d5db5151a9b1a2fc1523ec930baf98e9b3.tar.gz
Fix up SAC calculations for ATM/bar confusion
We even documented that we did SAC in bar*l/min, but the "S" in SAC stands for "Surface". So we should normalize SAC rate to surface pressure, not one bar. It's a tiny 1% difference, and doesn't actually matter in practice, but it's noticeable when you want to explicitly test for SAC-rate by creating a test-dive that averages exactly 10m. Suddenly you don't get the round numbers you expect. [ Side note: 10m is not _exactly_ one extra atmosphere according to our calculations, but it's darn close in sea water: the standard salinity of 1.03 kg/l together with the standard acceleration of 9.81m/s^2 gives an additional pressure of 1.01 bar, which is within a fraction of a percent of one ATM. Of course, divers have likely chosen that value exactly for the math to come out that way, since the true average salinity of seawater is actually slightly lower ] So here's a few test-dives, along with the SAC rate fixup to make them look right. (There's also a one-liner to dive.c that makes the duration come out right if the last sample has a non-zero depth, and the previous sample did not: one of my original test-dives did the "average 10m depth" by starting at 0 and ending at 20m, and dive.c got a tiny bit confused about that ;) [ The rationale for me testing our SAC rate calculations in the first place was that on snorkkeli.net user "Poltsi" reported that our SAC rate calculations differ from the ones that Suunto DM4 reports. So I wanted to verify that we did things right. Note that Poltsi reported differences larger than the difference of BAR/ATM, so this is not the cause. I'll continue to look at this. ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/divelist.c b/divelist.c
index 85fb535ed..143f4d43c 100644
--- a/divelist.c
+++ b/divelist.c
@@ -749,8 +749,8 @@ static int calculate_sac(struct dive *dive)
}
}
}
- /* Mean pressure in bar (SAC calculations are in bar*l/min) */
- pressure = depth_to_mbar(dc->meandepth.mm, dive) / 1000.0;
+ /* Mean pressure in ATM (SAC calculations are in atm*l/min) */
+ pressure = (double) depth_to_mbar(dc->meandepth.mm, dive) / SURFACE_PRESSURE;
sac = airuse / pressure * 60 / duration;
/* milliliters per minute.. */