[PATCH 2/3] gas pressures: do not use gas compressibility for cylinder naming

Linus Torvalds torvalds at linux-foundation.org
Wed Feb 24 13:27:32 PST 2016


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Wed, 24 Feb 2016 11:31:03 -0800
Subject: [PATCH 2/3] gas pressures: do not use gas compressibility for cylinder naming

This actually didn't make a difference for the common case, since our
simplified gas compressibility model had a compressibility factor of 1.0
up to 200 bar, and increased smoothly from there.  As a result, the
common 2400 and 3000 psi workpressures didn't really see an effect from
this.

Not taking compressibility into account does kind of make sense for
cylinder naming, since the cylinder may be used for different gases with
very different compressibility characteristics.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
 subsurface-core/dive.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c
index b7beadce5765..f6fbc3261d91 100644
--- a/subsurface-core/dive.c
+++ b/subsurface-core/dive.c
@@ -973,10 +973,15 @@ void sanitize_gasmix(struct gasmix *mix)
 /*
  * See if the size/workingpressure looks like some standard cylinder
  * size, eg "AL80".
+ *
+ * NOTE! We don't take compressibility into account when naming
+ * cylinders. That makes a certain amount of sense, since the
+ * cylinder name is independent from the gasmix, and different
+ * gasmixes have different compressibility.
  */
 static void match_standard_cylinder(cylinder_type_t *type)
 {
-	double cuft;
+	double cuft, bar;
 	int psi, len;
 	const char *fmt;
 	char buffer[40], *p;
@@ -985,8 +990,9 @@ static void match_standard_cylinder(cylinder_type_t *type)
 	if (type->description)
 		return;
 
+	bar = type->workingpressure.mbar / 1000.0;
 	cuft = ml_to_cuft(type->size.mliter);
-	cuft *= surface_volume_multiplier(type->workingpressure);
+	cuft *= bar_to_atm(bar);
 	psi = to_PSI(type->workingpressure);
 
 	switch (psi) {
@@ -1040,10 +1046,11 @@ static void sanitize_cylinder_type(cylinder_type_t *type)
 		return;
 
 	if (xml_parsing_units.volume == CUFT) {
+		double bar = type->workingpressure.mbar / 1000.0;
 		/* confusing - we don't really start from ml but millicuft !*/
 		volume_of_air = cuft_to_l(type->size.mliter);
-		/* milliliters at 1 atm: "true size" */
-		volume = volume_of_air / surface_volume_multiplier(type->workingpressure);
+		/* milliliters at 1 atm: not corrected for compressibility! */
+		volume = volume_of_air / bar_to_atm(bar);
 		type->size.mliter = rint(volume);
 	}
 
-- 
2.7.2.334.g7c0da37



More information about the subsurface mailing list