diff options
author | Tim Segers <tsegers@pm.me> | 2022-09-30 12:23:30 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2022-09-30 12:23:30 +0200 |
commit | 33c34bfe13b312fcb41390b95d88c7756c97c6c1 (patch) | |
tree | 14810697d17eddcb98d357157d20bbca2068246f | |
parent | 91f3f33d72483c76b7073d33d90b4cd0ab945371 (diff) | |
download | opendeco-33c34bfe13b312fcb41390b95d88c7756c97c6c1.tar.gz |
Add GF99 function
-rw-r--r-- | deco.c | 27 | ||||
-rw-r--r-- | deco.h | 3 |
2 files changed, 29 insertions, 1 deletions
@@ -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); @@ -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); |