diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-02 19:58:36 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-03 10:29:15 -0700 |
commit | 23da23a53444d555f9211c9c5e6de1fb1bcd27de (patch) | |
tree | 6bae55c165306138d7ea486ed0b1475592f097f7 /core/dive.c | |
parent | 34730b898b41b19476eaa61f20273e267d63b7e8 (diff) | |
download | subsurface-23da23a53444d555f9211c9c5e6de1fb1bcd27de.tar.gz |
core: add N2 and general gas component accessors
There were helper functions to access O2 and He component fractions.
Add another one for N2. Indeed, this can be used in three cases, where
N2 was deduced indirectly.
Moreover, add a general accessor with a gas_component argument.
This will be used by the filter code to filter for gas components.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/dive.c b/core/dive.c index f79af7ed2..c3fd95bf1 100644 --- a/core/dive.c +++ b/core/dive.c @@ -2065,7 +2065,7 @@ void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, pressures->o2 = 0; if (get_o2(mix) != 1000) { pressures->he = (amb_pressure - pressures->o2) * get_he(mix) / (1000.0 - get_o2(mix)); - pressures->n2 = (amb_pressure - pressures->o2) * (1000 - get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix)); + pressures->n2 = (amb_pressure - pressures->o2) * get_n2(mix) / (1000.0 - get_o2(mix)); } else { pressures->he = pressures->n2 = 0; } @@ -2073,7 +2073,7 @@ void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, // Open circuit dives: no gas pressure values available, they need to be calculated pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure; // These calculations are also used if the CCR calculation above.. pressures->he = get_he(mix) / 1000.0 * amb_pressure; // ..returned a po2 of zero (i.e. o2 sensor data not resolvable) - pressures->n2 = (1000 - get_o2(mix) - get_he(mix)) / 1000.0 * amb_pressure; + pressures->n2 = get_n2(mix) / 1000.0 * amb_pressure; } } } @@ -3760,7 +3760,7 @@ depth_t gas_mnd(struct gasmix mix, depth_t end, const struct dive *dive, int rou int maxambient = prefs.o2narcotic ? (int)lrint(ppo2n2.mbar / (1 - get_he(mix) / 1000.0)) : - (int)lrint(ppo2n2.mbar * N2_IN_AIR / (1000 - get_he(mix) - get_o2(mix))); + (int)lrint(ppo2n2.mbar * N2_IN_AIR / get_n2(mix)); rounded_depth.mm = (int)lrint(((double)mbar_to_depth(maxambient, dive)) / roundto) * roundto; return rounded_depth; } |