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

Rick Walsh rickmwalsh at gmail.com
Thu Oct 29 00:53:05 PDT 2015


Robert,

On 29 October 2015 at 07:18, Robert C. Helling <helling at atdotde.de> wrote:

> Hi Rick,
>
> here are some more comments but I think we are converging on all the
> points.
>
> On 28 Oct 2015, at 13:10, Rick Walsh <rickmwalsh at gmail.com> wrote:
>
>> >
>> > 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.
>>
> A problem with this approach is that with a deep -> shallow -> deeper
> (setting deepest ceiling) profile is that it would start counting deco time
> before we are in the real ascent phase and actual offgassing.  I don't
> believe we should be distributing the extra bubble volume allowed by the
> CVA over this section.  I have kept it as is, but happy to discuss further.
>
>
> This is really about how to interpret the (in itself not very logical)
> philosophy of the model. I would argue, that whenever the tissues are
> oversaturated compared to the ambient pressure we are adding gas to the
> bubbles and those are there to stay (their decay is supposed to have a half
> time of two weeks). So, there is „free gas“ no matter if we later go to
> greater depth again or not. So I would count it. Or, maybe more convincing:
> Imagine a dive where you do something which in the real world would be
> rather stupid: You do all you stops and when at last the 3m ceiling clears,
> you realise that the anchor needs to be freed. So you do a final bounce to
> the bottom and then ascent. In that case, you would want to count all the
> bubbles of the real deco not just those of the bounce.
>
> Yes, how should the philosophy of model be interpreted?  It's especially
hard when to my knowledge, nothing has been documented for interpreting
actual dives.

I was actually considering the case of a dive with a final bounce.  My
rationale was dropped equipment, rather than freeing an anchor, but the
profile is similar.  I think an important feature of a final bounce, after
clearing the ceiling (or nearly clearing the ceiling) from the main dive
would be that any deco ceiling from the bounce would be shallower than the
maximum ceiling of the main part of the dive.  If that weren't the case,
there'd be a significant deco obligation, the calculated deco time would be
much longer, and the boat captain would not be happy that we'd caused him
to wait an extra 45 minutes.

Assuming the bounce ceiling is shallower than the deepest ceiling, the deco
time calculated as [runtime when ceiling cleared] - [runtime of deepest
ceiling] does count all the bubbles of the real deco.  In fact it would be
a little bit longer than that calculated as [total offgassing time],
because the offgassing time wouldn't include the bounce descent.  In
practice, the difference will be very little - a minute here or there
doesn't make much difference to the CVA.

>
>
>> >
>> > 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.
>>
> I tried doing that.  But it messes up the setting of the gradients.  Until
> we reach the deepest ceiling, we want to use first_gradient, after setting
> the deepest ceiling, we want to use next_gradient (set once, when
> first_ceiling_pressure is set) with the approximated deco_time.  To
> distinguish, I have used the first_ceiling_pressure_set boolean variable.
>
>
> I don’t follow you here. Next gradient is about the next round of the CVA.
> What you say sounds more like you are talking about the Boyle compensation.
> Taking care of the latter is rather trivial: When entry->ceiling >=
> first_ceiling you don’t compensate and otherwise you do. (First ceiling is
> actually the max_ceiling up to that point).
>
> Sorry, I didn't explain that well at all.  The first pass is used to
calculate the deepest ceiling.  After the deepest ceiling is set, we are in
"ascent mode".  Like in the planner, the CVA calculations are based on this
point forward.  We want to run vpmb_next_gradient at this point, but not
after it (like in the planner, when it is run at the start of the CVA
loop).  I used first_ceiling_pressure_set as a marker for whether we should
update the gradients.

vpmb_next_gradient is set once only for the subsequent iteration(s) (at the
end of the previous iteration), so this is filtered out while looping
through the samples by testing for the bool first_iteration.

Looking at the code again, I agree that rather than testing for
!first_ceiling_pressure_set, we should be able to test for entry->ceiling
>= first_ceiling.  I'll have another go at this - if I can get it to work,
it should remove a few lines of code.

>
>
>> >
>> > 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.
>>
> I have reworked to loop through the code until it deco_time converges, or
> a max of 3 iterations.
>
>
> In a quick look, I could not see what the loop is run only once if we are
> not using VPM. But I need to do some more understanding and thinking here.
>
> It does only run once if running in the planner, or if using Buhlmann, but
I should add a comment to explain.

+ while ((abs(prev_deco_time - deco_time) >= 30) && (count_iteration < 4)) {
...
...

+ if (prefs.deco_mode == VPMB && !in_planner()) {
...
+ } else {
+ prev_deco_time = deco_time = 0;
  }
  }

Setting prev_deco_time = deco_time means that the while condition will
fail.  They don't need to be set to zero, but it seemed safer to set to
something, in case deco_time hadn't been initialized (even though it is),
and hadn't been set.

Cheers,

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20151029/0f833332/attachment.html>


More information about the subsurface mailing list