summaryrefslogtreecommitdiffstats
path: root/core/gas.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-04 13:52:48 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-06-19 13:11:10 -0700
commit619d3fb1fd4b7ab532537b7eca78f668d2ce381b (patch)
tree7a4575845be7b5a196a1450c370b660a18ef9e13 /core/gas.h
parent83522747581500ef39005bc76b1048db1cd3bd29 (diff)
downloadsubsurface-619d3fb1fd4b7ab532537b7eca78f668d2ce381b.tar.gz
Cleanup: move gas-functions to own translation unit
But only functions that operate only on gases. Functions concerning cylinders or dives remain in dive.c or are moved to equipment.c Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/gas.h')
-rw-r--r--core/gas.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/core/gas.h b/core/gas.h
new file mode 100644
index 000000000..f5d948da0
--- /dev/null
+++ b/core/gas.h
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef GAS_H
+#define GAS_H
+
+#include "units.h"
+
+#ifdef __cplusplus
+extern "C" {
+#else
+#include <stdbool.h>
+#endif
+
+// o2 == 0 && he == 0 -> air
+// o2 < 0 -> invalid
+struct gasmix {
+ fraction_t o2;
+ fraction_t he;
+};
+static const struct gasmix gasmix_invalid = { { -1 }, { -1 } };
+static const struct gasmix gasmix_air = { { 0 }, { 0 } };
+
+struct icd_data { // This structure provides communication between function isobaric_counterdiffusion() and the calling software.
+ int dN2; // The change in fraction (permille) of nitrogen during the change
+ int dHe; // The change in fraction (permille) of helium during the change
+};
+
+extern bool isobaric_counterdiffusion(struct gasmix oldgasmix, struct gasmix newgasmix, struct icd_data *results);
+
+extern double gas_compressibility_factor(struct gasmix gas, double bar);
+extern double isothermal_pressure(struct gasmix gas, double p1, int volume1, int volume2);
+extern double gas_density(struct gasmix gas, int pressure);
+extern int same_gasmix(struct gasmix a, struct gasmix b);
+
+static inline int get_o2(struct gasmix mix)
+{
+ return mix.o2.permille ?: O2_IN_AIR;
+}
+
+static inline int get_he(struct gasmix mix)
+{
+ return mix.he.permille;
+}
+
+struct gas_pressures {
+ double o2, n2, he;
+};
+
+extern void sanitize_gasmix(struct gasmix *mix);
+extern int gasmix_distance(struct gasmix a, struct gasmix b);
+
+extern bool gasmix_is_air(struct gasmix gasmix);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif