aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--deco.c27
-rw-r--r--deco.h3
2 files changed, 29 insertions, 1 deletions
diff --git a/deco.c b/deco.c
index 66182d9..42d3776 100644
--- a/deco.c
+++ b/deco.c
@@ -241,6 +241,33 @@ double ceiling(const decostate_t *ds, double gf)
return round_ceiling(ds, c);
}
+double gf99(const decostate_t *ds, double depth)
+{
+ double gf = 0;
+
+ for (int i = 0; i < 16; i++) {
+ /* n2 a and b values */
+ double an = ZHL16N[i].a[ALGO_VER];
+ double bn = ZHL16N[i].b;
+
+ /* he a and b values */
+ double ah = ZHL16He[i].a;
+ double bh = ZHL16He[i].b;
+
+ /* scale n2 and he values for a and b proportional to their pressure */
+ double pn2 = ds->pn2[i];
+ double phe = ds->phe[i];
+
+ double a = ((an * pn2) + (ah * phe)) / (pn2 + phe);
+ double b = ((bn * pn2) + (bh * phe)) / (pn2 + phe);
+
+ /* update gf99 */
+ gf = max(gf, (pn2 + phe - depth) / (a + depth / b - depth));
+ }
+
+ return gf * 100;
+}
+
void init_tissues(decostate_t *ds)
{
const double pn2 = 0.79 * (SURFACE_PRESSURE - P_WV);
diff --git a/deco.h b/deco.h
index 5860591..439626f 100644
--- a/deco.h
+++ b/deco.h
@@ -56,8 +56,9 @@ double add_segment_ascdec(decostate_t *ds, const double dstart, const double den
const gas_t *gas);
double add_segment_const(decostate_t *ds, const double depth, const double time, const gas_t *gas);
double get_gf(const decostate_t *ds, const double depth);
-double ceiling(const decostate_t *ds, double gf);
double round_ceiling(const decostate_t *ds, const double c);
+double ceiling(const decostate_t *ds, double gf);
+double gf99(const decostate_t *ds, double depth);
void init_decostate(decostate_t *ds, const unsigned char gflo, const unsigned char gfhi, const double ceil_multiple);