summaryrefslogtreecommitdiffstats
path: root/core/gas-model.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-05-12 15:36:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-26 15:52:04 -0700
commitbb6ceba4ac0310c504f931674a71e9e77c0afa1c (patch)
tree2a060b136d32e7ecdfd5b8b0314415595e675cbe /core/gas-model.c
parente6d884cf26161df65c2b4b8c39d6b4133760537b (diff)
downloadsubsurface-bb6ceba4ac0310c504f931674a71e9e77c0afa1c.tar.gz
Compute and display gas density
This appears to be critical for work of breathing so it might be worthwhile to compute. So far only in infobox. For background, see https://www.youtube.com/watch?v=QBajM3xmOtc Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/gas-model.c')
-rw-r--r--core/gas-model.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/gas-model.c b/core/gas-model.c
index dd84e9b9d..49c677967 100644
--- a/core/gas-model.c
+++ b/core/gas-model.c
@@ -9,6 +9,8 @@
#define virial_m1(C, x1, x2, x3) (C[0]*x1+C[1]*x2+C[2]*x3)
/*
+ * Z = pV/nRT
+ *
* Cubic virial least-square coefficients for O2/N2/He based on data from
*
* PERRY’S CHEMICAL ENGINEERS’ HANDBOOK SEVENTH EDITION
@@ -73,3 +75,9 @@ double isothermal_pressure(struct gasmix *gas, double p1, int volume1, int volum
return p_ideal * gas_compressibility_factor(gas, p_ideal);
}
+
+inline double gas_density(struct gasmix *gas, int pressure) {
+ int density = gas->he.permille * HE_DENSITY + gas->o2.permille * O2_DENSITY + (1000 - gas->he.permille - gas->o2.permille) * N2_DENSITY;
+
+ return density * (double) pressure / gas_compressibility_factor(gas, pressure / 1000.0) / SURFACE_PRESSURE / 1000000.0;
+}