diff options
author | Robert C. Helling <helling@atdotde.de> | 2021-10-01 15:50:21 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-10-01 08:50:36 -0700 |
commit | 41258647d232a24adca394202b44b204409b4c9f (patch) | |
tree | a1c0b94973d5e8795cd3b8dba44542c2efa2bdbb /core/gas-model.c | |
parent | 5e9ee9febb595ced1699e1f60a659e01266ec7e9 (diff) | |
download | subsurface-41258647d232a24adca394202b44b204409b4c9f.tar.gz |
Don't access gasmix.o2.fraction
Air is a special gas that does not contain oxygen according
to gasmix.o2.fraction. If you want to use the fo2, you
need to use get_o2() to treat this special case correctly.
This fixes a bug when setting the MND of a gas containing
21% oxygen when o2 is considered not narcotic.
Reported-by: Christoph Gruen <gruen.christoph@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/gas-model.c')
-rw-r--r-- | core/gas-model.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/gas-model.c b/core/gas-model.c index 44c64864a..115da0356 100644 --- a/core/gas-model.c +++ b/core/gas-model.c @@ -86,7 +86,9 @@ double isothermal_pressure(struct gasmix gas, double p1, int volume1, int volume 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; + int fo2 = get_o2(gas); + int fhe = get_he(gas); + int density = fhe * HE_DENSITY + fo2 * O2_DENSITY + (1000 - fhe - fo2) * N2_DENSITY; return density * (double) pressure / gas_compressibility_factor(gas, pressure / 1000.0) / SURFACE_PRESSURE / 1000000.0; } |