summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-12-30 23:28:55 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-10 17:27:24 -0800
commit93eb386ba998b3351a9dff81fa8a4d6ad0715e25 (patch)
treed57a837605a3890ac8f8bf58ac3cb1a8f08b86c4 /dive.c
parentd01c6c824b1e6114a58ac84f387cd437a2c2ac02 (diff)
downloadsubsurface-93eb386ba998b3351a9dff81fa8a4d6ad0715e25.tar.gz
Prepare for PSCR calculations
Calculations for passive semi-closed rebreathers are pretty much like OC except the pO2 is lower bey a certain (SAC dependent) factor. This patch introduces the corresponding calculations in case dctype == PSCR which is so far never set and there is currently no UI for these calculations. As pO2 is SAC dependent it takes a certain attempt at getting it and drops to defaults from the prefs otherwise. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index 711392c5a..17b67a590 100644
--- a/dive.c
+++ b/dive.c
@@ -1663,10 +1663,17 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre
pressures->n2 = amb_pressure - pressures->o2 - pressures->he;
}
}
- } else { // Open circuit dives: no gas pressure values available, they need to be calculated
+ } else {
+ if (dctype == PSCR) { /* The steady state approximation should be good enough */
+ pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - (1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (sac * prefs.pscr_ratio / 1000.0);
+ 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));
+ } 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..
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;
+ }
}
}