mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Prevent 0/0 in partial pressure calculation
If for some reason the diluent is pure oxygen, there is a zero divided by zero error in the partial pressure calculation. This patch prevents it. Fixes #774 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bf20c251ab
commit
767fd39ca0
1 changed files with 6 additions and 2 deletions
8
dive.c
8
dive.c
|
@ -1637,8 +1637,12 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre
|
|||
pressures->n2 = pressures->he = 0.0;
|
||||
} else {
|
||||
pressures->o2 = po2;
|
||||
pressures->he = (amb_pressure - pressures->o2) * (double)get_he(mix) / (1000 - get_o2(mix));
|
||||
pressures->n2 = amb_pressure - pressures->o2 - pressures->he;
|
||||
if (get_o2(mix) == 1000) {
|
||||
pressures->he = pressures->n2 = 0;
|
||||
} else {
|
||||
pressures->he = (amb_pressure - pressures->o2) * (double)get_he(mix) / (1000 - get_o2(mix));
|
||||
pressures->n2 = amb_pressure - pressures->o2 - pressures->he;
|
||||
}
|
||||
}
|
||||
} else { // 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..
|
||||
|
|
Loading…
Add table
Reference in a new issue