[PATCH 1/2] Calculate VPM-B ceiling outside of planner

Rick Walsh rickmwalsh at gmail.com
Mon Oct 26 14:09:19 PDT 2015


Thanks Roberts,

On 27 Oct 2015 06:08, "Robert C. Helling" <helling at atdotde.de> wrote:
>
> Hi Rick,
>
>> On 26 Oct 2015, at 10:25, Rick Walsh <rickmwalsh at gmail.com> wrote:
>>
>> So, using your observation that it converges fast, I realized we don't
actually need to calculate tts for every sample point.  We just need to
calculate tts for the final sample, iif the ceiling has been broken.  We
can then take deco_time = time from max ceiling depth until the ceiling
clears, or would have cleared.
>>
>> See patches attached.  More testing is needed, and feedback welcome.
>
>
> I think this makes much more sense. Just a few comments/questions for
patch 1:
>
> 1) I think deco_time is defined, at least in the prose of the VPM-B
documents as the time at which at least one tissue is off-gassing. Given
that we have to go through all samples, can’t we just detect off-gassing in
add_segment by checking if at least one oversat is negative, i.e. start with
>
> bool off_gassing = false
>
> and then in the loop
>
> off_gassing ||= (pn2_oversat < 0) || (phe_oversat <0);
>
> and finally change add_segment from void to bool by returning
off_gassing. Then we can simply add all the time for all segments the we
added which return true.

This would work, but will achieve almost the same outcome.  Taking deco
time as time from max ceiling until time of clear ceiling implies that at
least one tissues, the leading tissue, is off-gassing.  With a very deep
(setting deepest ceiling) to shallow (shallower ceiling) to deep (all
tissues on-gas and ceiling deepens but not to max), there could be a small
difference in calculated deco time.

>
> 2) I don’t really understand what you are doing
with first_ceiling_pressure_set. It seems to me you want to pick up the
first step after the maximum of the ceiling. So you look for a segment
where the ceiling goes up but in the previous step it didn’t. Why don’t you
simply memorise the last step where the ceiling gets deeper (it should be
the previous), by getting rid of first_ceiling_pressure_set and simply doing
>
> if (entry->ceiling > first_ceiling) {
> first_ceiling = entry->ceiling;
> first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
> }
>
> This would give you the value for the maximum ceiling.

Yes, that's much simpler way to achieve the same thing.  I'll do that.
>
> 3) I am a bit worried that the last hunk copies quite a bit of
non-trivial code. Wouldn’t it be possible to factor this out, i.e. do it
with a loop or as a separate function that the logic is in the source only
once? Otherwise, we are almost guaranteed that when changing the code in
the future we will end up with two inconsistent copies.
>
Yes, at first glance I thought only a little bit of code needed to be
repeated so I thought copying it would be better.  But it turns out I
needed to copy most of it.  I loop is better.

> But all this in the end is cosmetic, I like what the code is doing.
>
Thanks.  I'll resubmit addressing your second and third points at least.  I
need to think about the effect (or not) of calculating deco time as you
suggested.

Cheers,

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20151027/4734d964/attachment-0001.html>


More information about the subsurface mailing list