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 /deco.c | |
parent | 91f3f33d72483c76b7073d33d90b4cd0ab945371 (diff) | |
download | opendeco-33c34bfe13b312fcb41390b95d88c7756c97c6c1.tar.gz |
Add GF99 function
Diffstat (limited to 'deco.c')
-rw-r--r-- | deco.c | 27 |
1 files changed, 27 insertions, 0 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); |