<div dir="ltr">Robert,<br><div><div class="gmail_extra"><br><div class="gmail_quote">On 27 October 2015 at 08:09, Rick Walsh <span dir="ltr"><<a href="mailto:rickmwalsh@gmail.com" target="_blank">rickmwalsh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Thanks Roberts,</p></blockquote><div>(sorry for adding an s to your name) <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<p dir="ltr">On 27 Oct 2015 06:08, "Robert C. Helling" <<a href="mailto:helling@atdotde.de" target="_blank">helling@atdotde.de</a>> wrote:<br>
><br>
> Hi Rick,<br>
><br>
>> On 26 Oct 2015, at 10:25, Rick Walsh <<a href="mailto:rickmwalsh@gmail.com" target="_blank">rickmwalsh@gmail.com</a>> wrote:<br>
>><br>
>> 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.<br>
>><br>
>> See patches attached.  More testing is needed, and feedback welcome.<br>
><br>
><br>
> I think this makes much more sense. Just a few comments/questions for patch 1: <br>
><br>
> 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<br>
><br>
> bool off_gassing = false<br>
><br>
> and then in the loop<br>
><br>
> off_gassing ||= (pn2_oversat < 0) || (phe_oversat <0);<br>
><br>
> 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.</p>
</span><p dir="ltr">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.</p></blockquote><div>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.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<p dir="ltr">><br>
> 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<br>
><br>
> if (entry->ceiling > first_ceiling) {<br>
> first_ceiling = entry->ceiling;<br>
> first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);<br>
> }<br>
><br>
> This would give you the value for the maximum ceiling.</p>
</span><p dir="ltr">Yes, that's much simpler way to achieve the same thing.  I'll do that.<span class=""><br></span></p></blockquote><div>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.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"><span class="">
><br>
> 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.<br>
><br></span>
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.</p></blockquote><div>I have reworked to loop through the code until it deco_time converges, or a max of 3 iterations.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr"><span class="">> But all this in the end is cosmetic, I like what the code is doing.<br>
><br></span>
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.</p><br></blockquote><div>All I have really changed is that the code now loops, rather than copying code.  Please let me know if you can think of a better way to create the VPM-B ceiling.<br><br></div><div>Note that if you cut short a planned deco profile, skipping the final gas change, then the final_tts will be over-estimated because it doesn't consider using the final gas.  This alters the CVA calculation, so the calculated ceiling does change a little bit from that of the planned profile if it isn't cut short.  We could change this by altering the tts calculation to use all gasses in the cylinder list, but I think that would be worse.  For a real dive, we should only consider the gasses that were used in that dive.<br><br></div><div>Cheers,<br><br></div><div>Rick<br></div><div> </div></div></div></div></div>