<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 29 October 2015 at 18:53, 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"><div dir="ltr">Robert,<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 29 October 2015 at 07:18, Robert C. Helling <span dir="ltr"><<a href="mailto:helling@atdotde.de" target="_blank">helling@atdotde.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Rick,<div><br></div><div>here are some more comments but I think we are converging on all the points.</div><div><br><div><span><blockquote type="cite"><div>On 28 Oct 2015, at 13:10, Rick Walsh <<a href="mailto:rickmwalsh@gmail.com" target="_blank">rickmwalsh@gmail.com</a>> wrote:</div><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><p dir="ltr">><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></div></div></div></div></div></div></blockquote><div><br></div></span><div>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.</div><span><br></span></div></div></div></blockquote></span><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div></div></div></div></blockquote><div><br></div><div>The attached patch keeps the deco_time calculation as it was. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><span><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div class="gmail_extra"><div class="gmail_quote"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><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><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></div></div></div></blockquote><div><br></div></span><div>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).</div><span><br></span></div></div></div></blockquote></span><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div></div></div></div></blockquote><div><br></div><div>It works, and a few lines of code have been removed.  No more first_ceiling_pressure_set.<br><br></div><div>I also made it so that first_ceiling is recalculated when iterating.  It makes a very small difference, but because the gradients are updated, the ceiling can change a little.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><span><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p dir="ltr"><span>><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></div></div></div></div></div></div></blockquote><div><br></div></span><div>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.</div></div><br></div></div></blockquote></span><div>It does only run once if running in the planner, or if using Buhlmann, but I should add a comment to explain.</div><div><br></div><div><div>+<span style="white-space:pre-wrap">     </span>while ((abs(prev_deco_time - deco_time) >= 30) && (count_iteration < 4)) {</div></div><div>...</div><div>...</div><div><br></div><div><span class=""><div>+<span style="white-space:pre-wrap">             </span>if (prefs.deco_mode == VPMB && !in_planner()) {</div></span><div>...</div><div>+<span style="white-space:pre-wrap">          </span>} else {<br></div><div>+<span style="white-space:pre-wrap">                      </span>prev_deco_time = deco_time = 0;</div><div> <span style="white-space:pre-wrap">                </span>}</div><div> <span style="white-space:pre-wrap">      </span>}</div></div><div><br></div><div>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.</div></div></div></div></blockquote><div><br></div><div>Comments added to commit <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><div>Cheers,</div><div><br></div><div>Rick</div></div></div></div>
</blockquote></div><br></div></div>