## Dive Planner Recipes

This is really for my personal reference. If it helps you, I’m glad.

A couple of weeks ago, I wrote this tool (http://deco-planner.archisgore.com.) You can go read the history, motivation, etc. on that page and the github repo ad nauseum.

NOTE: Why is this important/useful? Don’t computers tell you how much deco you should do? Yes they do exactly that, and do it pretty well. Now here’s what a computer won’t tell you – how much deco would you be looking at _if_ you extended the dive by 10 minutes? Let’s say that by extending it 10 minutes, or pushing it down by 10 feet more, your obligation jumps from 30 minutes to 50 minutes. That is objectively two-thirds more gas than you planned for. This tool/post is about understanding what those shapes are so you can decide, even if you had your computer telling you what your deco was, whether you’re going to like doing it or not.

This post is about how to effectively use that tool with some pre-canned recipes to generate information cheap/easy than any other tool I know of or can think of.

The first recipe (and the primary reason I built the entire damn thing, is to get an idea of how ratio-deco changes over different bottom times. Does it grow linearly? Non-linearly? etc. Say you’re at 150 feet for “x” minutes longer than your plan, and you just don’t happen to have a computer to do your math. Do you have a vague idea how the shape of increments changes?)

Let’s find the answer to that very question quickly.

Deco time change as a ratio of bottom time:

```//This function is a utility to get total dive time out of all segments
var calculateDiveTime = function(diveplan) {
var totalTime = 0;
for (var index = 0; index < diveplan.length; index++) {
var segment = diveplan[index];
totalTime = totalTime + segment.time;
}
}

//In this loop we'll run a 150 foot dive for bottom times between 1 to 120
// minutes and calculate total dive time, find deco time (by subtracting
// bottom time), and store it in the array.
for (var time = 1; time <= 120; time++) {
var buhlmann = dive.deco.buhlmann();
var plan = new buhlmann.plan(buhlmann.ZH16BTissues);
var decoPlan = plan.calculateDecompression(false, 0.2, 0.8, 1.6, 30);
var totalTime = calculateDiveTime(decoPlan);
var decoTime = totalTime - time;
console.log(decoTime);
}
```

What’s really cool is, I can now chart that decoTimes array using Excel or Numbers or whatever your spreadsheet is. I just paste it in plot.ly, and get this:

Deco Time change as a ratio of depth:

Now let’s look at how does decompression change if my depth came out different than anticipated? We can generate deco schedules for that too:

```//This function is a utility to get total dive time out of all segments
var calculateDiveTime = function(diveplan) {
var totalTime = 0;
for (var index = 0; index < diveplan.length; index++) {
var segment = diveplan[index];
totalTime = totalTime + segment.time;
}
}

//In this loop we'll run a 150 foot dive for bottom times between 1 to 120
// minutes and calculate total dive time, find deco time (by subtracting
// bottom time), and store it in the array.
for (var depth = 120; depth <= 180; depth++) {
var buhlmann = dive.deco.buhlmann();
var plan = new buhlmann.plan(buhlmann.ZH16BTissues);
var decoPlan = plan.calculateDecompression(false, 0.2, 0.8, 1.6, 30);
var totalTime = calculateDiveTime(decoPlan);
var decoTime = totalTime - 30;
console.log(decoTime);
}
```

And we get this:

Finally, let’s plot how VPM-B compares to Buhlmann. In this case, we have to add a depth change from 0 feet to 150 feet, because VPM is very sensitive to the slopes unlike Buhlmann which only worries about tissue loading (more on this later, I promise.)

Here’s the code to generate Buhlmann vs VPM deco times for the same dive profile:

```//This function is a utility to get total dive time out of all segments
var calculateDiveTime = function(diveplan) {
var totalTime = 0;
for (var index = 0; index < diveplan.length; index++) {
var segment = diveplan[index];
totalTime = totalTime + segment.time;
}
}

//In this loop we'll run a 150 foot dive for bottom times between 1 to 120
// minutes and calculate total dive time, find deco time (by subtracting
// bottom time), and store it in the array.
for (var time = 1; time <= 120; time++) {
var buhlmann = dive.deco.buhlmann();
var bplan = new buhlmann.plan(buhlmann.ZH16BTissues);
var bdecoPlan = bplan.calculateDecompression(false, 0.2, 0.8, 1.6, 30);
var btotalTime = calculateDiveTime(bdecoPlan);
var bdecoTime = btotalTime - time - 5;

var vpm = dive.deco.vpm();
var vplan = new vpm.plan();