Hi,
I guess (as so often) Linus is right, we should reset the state between dives (except of course tissue saturations) to get rid of this anomaly, and if other code does that even better. I attach a patch that does this. |
From 0dc61249a304286cf7d06e88fec5e10ba070117d Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Tue, 7 Feb 2017 09:18:19 +0100 Subject: [PATCH] Reset VPM-B state between repetitive dives To: [email protected]
This resets the maximum crushing pressures and the maximal ambient pressure between repetitive dives to prevent anomalies that a dive produces a shorter deco when following another one than without. Reported-by: [email protected] Signed-off-by: Robert C. Helling <[email protected]> --- core/deco.c | 10 ++++++++++ core/dive.h | 1 + core/divelist.c | 1 + 3 files changed, 12 insertions(+) diff --git a/core/deco.c b/core/deco.c index dd5cfa0..5014f1b 100644 --- a/core/deco.c +++ b/core/deco.c @@ -559,9 +559,19 @@ void dump_tissues() printf("\n"); } +void clear_vpmb_state() { + int ci; + for (ci = 0; ci < 16; ci++) { + max_n2_crushing_pressure[ci] = 0.0; + max_he_crushing_pressure[ci] = 0.0; + } + max_ambient_pressure = 0; +} + void clear_deco(double surface_pressure) { int ci; + clear_vpmb_state(); for (ci = 0; ci < 16; ci++) { tissue_n2_sat[ci] = (surface_pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000; tissue_he_sat[ci] = 0.0; diff --git a/core/dive.h b/core/dive.h index 1b99fc3..4608e9d 100644 --- a/core/dive.h +++ b/core/dive.h @@ -872,6 +872,7 @@ void dump_plan(struct diveplan *diveplan); bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer); void calc_crushing_pressure(double pressure); void vpmb_start_gradient(); +void clear_vpmb_state(); void delete_single_dive(int idx); diff --git a/core/divelist.c b/core/divelist.c index b28dd5e..44401b7 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -423,6 +423,7 @@ unsigned int init_decompression(struct dive *dive) } add_dive_to_deco(pdive); laststart = pdive->when; + clear_vpmb_state(); #if DECO_CALC_DEBUG & 2 printf("added dive #%d\n", pdive->number); dump_tissues(); -- 2.10.1 (Apple Git-78)
There is probably no point in arguing about the original model since that IIIRC does not consider repetitive dives but I have to check the docs again. In any case, I would say this still shows how strange the model is: We have to artificially reset parameters between two dives. But of course „between dives“ can be somewhat arbitrary: If you only surface for a few minutes and then descend again, are these „two dives“ (which require a reset in between and how does your body know that it has to reset itself, after all this is what we are supposed to simulate) or is this a single dive (without reset)? What I take away is the impression that this does not make a lot of sense. But yes, please take this patch for master. Best Robert |
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
