(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 74653, 1692]*) (*NotebookOutlinePosition[ 75964, 1732]*) (* CellTagsIndexPosition[ 75823, 1725]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[StyleBox["Varying Permeability Model Decompression", FontColor->GrayLevel[1]]], "Title", CellFrame->True, Background->RGBColor[0, 0, 1]], Cell[TextData[{ StyleBox["All code copyright 1994-2004 by Eric Maiken.\n", FontColor->RGBColor[0, 0, 1]], StyleBox["Extends the 1986 algorithm of D. Yount and D. Hofmann to multiple \ mixed gases.", FontSize->16, FontColor->RGBColor[0, 0, 1]], StyleBox["\n", FontColor->RGBColor[0, 0, 1]], StyleBox["\nVersion (mmddyy): 012504", FontSize->16] }], "Subtitle"], Cell[TextData[{ StyleBox["THIS PROGRAM IMPLEMENTS AN OBSOLETE VERSION OF A VPM-BASED \ DECOMPRESSION ALGORITHM. It precedes the Yount/Maiken/Baker algorithm that \ was published in 2000. I have edited the code so that it runs in ", FontColor->RGBColor[0, 0, 1]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[" V5.0. Unfortunately, to do this, I have barbarically stripped \ out lots of comments and formatting.\n\nThe program is written in a top-down \ format, with all functions explicitly defined in-line as the calculations \ progress.\n\nOnce the dive mixes, depths, and times are set in the ", FontColor->RGBColor[0, 0, 1]], StyleBox["Define Dive ", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], StyleBox[" subsection, you can run the notebook either cell-by-cell, or by \ selecting the rightmost cell bracket and runing the whole program \ (shift-enter on a PC). The output is a simple table in the ", FontColor->RGBColor[0, 0, 1], Background->None], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox["Decompression Schedule ", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], StyleBox[" subsection at the bottom of the notebook. \n\nThe program tracks \ tensions and allowed supersaturations analytically. So, for example, if you \ remove the \";\" line terminator at the definition: ", FontColor->RGBColor[0, 0, 1], Background->None], "ppTotalTable[t] = ppN2Table[t] + ppHeTable[t]; ", StyleBox[", you will find the analytic expressions for 16 compartments vs. \ time. This has been done as an ", FontColor->RGBColor[0, 0, 1]], StyleBox[ButtonBox["example (click --hyperlink!)", ButtonData:>"Arrays of Pressure Functions", ButtonStyle->"Hyperlink"], Background->RGBColor[0, 1, 0]], StyleBox[" in the subsection ", FontColor->RGBColor[0, 0, 1]], StyleBox["Arrays of Pressure Functions to Track ppHe and ppN2 During Dive \ Stages ", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], StyleBox["\n\nAs another ", FontColor->RGBColor[0, 0, 1]], StyleBox[ButtonBox["example", ButtonData:>"Decompression Calculation", ButtonStyle->"Hyperlink"], Background->RGBColor[0, 1, 0]], StyleBox[", the terminator was removed from the list that tracks PssNew at \ the end of each stage in the subsection ", FontColor->RGBColor[0, 0, 1]], StyleBox["Decompression Calculation", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], StyleBox[" .\n\nThis notebook is a \"manual\" implementation of the Varying \ Permeability Model. In other words, you must manually iterate the \ calculations after selecting which of the ", FontColor->RGBColor[0, 0, 1]], StyleBox["Subsubsections", Background->GrayLevel[0.666667]], StyleBox[" of the ", FontColor->RGBColor[0, 0, 1]], StyleBox["Ascent Limiting Bubble Constants", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->GrayLevel[1], Background->None], StyleBox["subsection applies to your dive. For any significant \ decompression dive, only 1 iteration of either the ", FontColor->RGBColor[0, 0, 1], Background->None], StyleBox["permeable", Background->GrayLevel[0.666667]], StyleBox[" or ", FontColor->RGBColor[0, 0, 1], Background->None], StyleBox["impermeable", Background->GrayLevel[0.666667]], StyleBox[" ", FontColor->RGBColor[0, 0, 1], Background->GrayLevel[0.666667]], StyleBox["subsubsections is required anyway. This corresponds to a constant \ bubble number calculation with N = Nsafe.\n\nAs usual, the VPM applies to a \ single (nonrepetitive) dive. \n", FontColor->RGBColor[0, 0, 1], Background->None], StyleBox["\nPlease send questions, comments, and corrections to: \ EricMaiken@msn.com", FontColor->RGBColor[0, 0, 1]] }], "Text"], Cell[CellGroupData[{ Cell["Preliminaries", "Subsection", GeneratedCell->False, FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[BoxData[{ \(Off[General::"\"]\), "\n", \(\(\(Off[General::"\"]\)\(\[IndentingNewLine]\) \)\), "\n", \(\(\(Clear[fO2Mix, fN2Mix, fO2DecoMix1, fN2DecoMix1, fO2DecoMix2, fN2DecoMix2, fO2DecoMix3, fN2DecoMix3, fN2DecoMix4, fO2DecoMix4, fN2DecoMix5, fO2DecoMix5, maxPPO2Mix1, maxPPO2Mix2, maxPPO2Mix3, maxPPO2Mix4, maxPPO2Mix5, descentRate, ascentRate, tsurfacedive, start, diveTime, diveDepth, stopIncrement]\)\(\n\)\(\[IndentingNewLine]\) \) (*set\ of\ Buhlmann\ ZHL16\ N2\ half - times*) \), "\[IndentingNewLine]", \(\(\(nZHL16N2 = {4. , 8. , 12.5, 18.5, 27. , 38.3, 64.3, 77. , 109. , 146. , 187. , 239. , 305. , 390. , 498. , 635. };\)\(\n\) \)\), "\[IndentingNewLine]", \(halftN2 = nZHL16N2; (*\([min]\)*) halftHe = N[halftN2/\((\[Sqrt]\((28/ 4)\))\)]; (*conventional\ diffusivity\ scaling\ of\ He\ \ half - times[min]*) \[IndentingNewLine]\), "\[IndentingNewLine]", \(\(nCompartments = Length[halftN2];\)\), "\[IndentingNewLine]", \(\(pH2OCO2 = N[102/760];\)\[IndentingNewLine] (*PCO2 + PH2O\ in\ Lungs[Atmospheres]*) \[IndentingNewLine] (*102/ 760\ is\ according\ to\ Yount\ and\ Hoffman, but\ rather\ large*) \[IndentingNewLine]\[IndentingNewLine] (*Surface\ \ conditions*) \[IndentingNewLine] (*program\ hasn' t\ been\ checked\ for\ altitude\ diving*) \), "\[IndentingNewLine]", \(\(pSurface = 1. ;\)\[IndentingNewLine] (*\([Atmospheres]\)*) \ \[IndentingNewLine]\), "\[IndentingNewLine]", \(\(startDepth = 33. \ \((pSurface - 1. )\);\)\), "\[IndentingNewLine]", \(\(fO20 = 0.21;\)\), "\[IndentingNewLine]", \(\(fN20 = 0.79;\)\)}], "Input", GeneratedCell->False] }, Closed]], Cell[CellGroupData[{ Cell["Define Dive", "Subsection", CellFrame->False, FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[TextData[StyleBox["All the dive parameters are defined in this \ subsubsection. All of the mix gas fractions, depths, ascent / descent rates \ are hi-lited in red to call attention to their values. \n\nAs many as 5 deco \ mixes can be specified, with the order 1->5 from deepest to shallowest. If \ less than 5 mixes are used, then set the deepest mixes equal to the bottom \ gas fractions.\nNote that the helium mix fraction fHe is derived from the \ nitrogen and oxygen fractions in this calculation: fHe = 1 - fO2 - fN2. \ All gas switch depths are calculated by the MODs below\n\nTo illustrate the \ mixes the default dive settings are for a single-level 60 min dive on Trimix \ 19/30 to 200 ft, with nitrox 50/50 and oxygen deco gasses.", FontColor->RGBColor[0, 0, 1]]], "Text"], Cell[BoxData[ \(\(\( (*This\ is\ the\ decent\ \ mix*) \)\(\[IndentingNewLine]\)\(\(fO2TravelMix = 0.18;\) (*Oxygen\ fraction . No\ checking\ of\ ppO2*) \[IndentingNewLine]\[IndentingNewLine] \(\(\(fN2TravelMix = 0.37\) \)\(;\)\( (*Nitrogen\ fraction*) \)\(\[IndentingNewLine]\)\(\ \[IndentingNewLine]\)\( (*fHe = 1 - fO2 - fN2*) \)\)\)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Travel Gas Mix ", Inherited}, {Inherited, Inherited}}, FontFamily->"Courier", Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\( (*This\ is\ the\ dive\ mix*) \)\(\[IndentingNewLine]\)\(\(fO2Mix = 0.18;\) (*the\ program\ does\ not\ check\ ppO2*) \[IndentingNewLine] \(fN2Mix = 0.37;\)\)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Bottom Gas Mix ", Inherited}, {Inherited, Inherited}}, FontFamily->"Courier", Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\( (*This\ is\ the\ deepest\ \((1 st)\)\ deco\ mix*) \)\(\[IndentingNewLine]\)\( (*usually\ use\ \ the\ same\ settings\ as\ bottom\ \ mix*) \)\(\[IndentingNewLine]\)\(\(fO2DecoMix1 = 0.18;\)\n \(fN2DecoMix1 = 0.37;\)\n \(\(\(\(maxPPO2Mix1 = 1.6\) \);\)\( (*maxPPO2\ controls\ this\ ascent\ gas' s\ Max\ Operating\ Depth\ \((MOD)\)*) \)\)\)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Decompression Mix 1", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\(\(fO2DecoMix2 = 0.18;\)\n \(fN2DecoMix2 = 0.37;\)\n \(\(\(maxPPO2Mix2 = 1.6\) \);\)\)\( (*maxPPO2\ controls\ this\ ascent\ gas' s\ Max\ Operating\ Depth*) \)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Decompression Mix 2", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\(\(fO2DecoMix3 = 0.18;\)\n \(fN2DecoMix3 = 0.37;\)\n \(\(\(maxPPO2Mix3 = 1.6\) \);\)\)\( (*maxPPO2\ controls\ this\ ascent\ gas' s\ Max\ Operating\ Depth*) \)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Decompression Mix 3", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\(\(fO2DecoMix4 = 0.5;\)\n \(fN2DecoMix4 = 0.5;\)\n \(maxPPO2Mix4 = 1.6;\)\)\( (*maxPPO2\ controls\ this\ ascent\ gas' s\ Max\ Operating\ Depth*) \)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Decompression Mix 4", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\(\(fO2DecoMix5 = 1.0;\) (*This\ is\ the\ shallowest\ deco\ mix*) \[IndentingNewLine] \(fN2DecoMix5 = 0.0;\) (*maxPPO2\ controls\ ascent\ this\ gas' s\ Max\ Operating\ Depth*) \[IndentingNewLine] \(maxPPO2Mix5 = 1.61;\)\)\( (*use\ 1.61\ to\ allow\ O2\ at\ 20\ feet*) \)\)\)], \ "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Decompression Mix 5", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(fO2SurfaceMix = 0.21; (*default\ setting\ is\ for\ an\ air\ surface\ mix*) fN2SurfaceMix = 0.79;\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Post Dive Surface Mix", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]], Cell[BoxData[ \(\(\( (*Multilevel\ dive\ sequence\ of\ stage\ \(DTMs : DTM\) = {Depth, Time, {Mix}}, where\ {Mix} = \(\({fO2, fN2}\)\(.\)\)*) \)\( (*This\ multilevel\ list\ of\ dive\ stage\ \ DTM\ arrays\ {DTM1, DTM2, \(\(...\)\(.\)\), DTMn}\ is\ entered\ in\ array\ dive*) \)\( (*As\ an\ example, a\ dive\ depth/ time\ is\ defined\ for\ a\ single\ \ level*) \)\(\[IndentingNewLine]\)\( (*For\ a\ multilevel\ dive, use\ DTM\ arrays\ to\ specify\ sequence*) \)\(\[IndentingNewLine]\)\(\ \[IndentingNewLine]\)\(\(diveDepth = 200. ;\) (*\([feet]\)*) \[IndentingNewLine] diveTime = 120. ; (*\([min]\)*) \[IndentingNewLine]start = {{startDepth, 0.0, {fO20, fN20}}};\[IndentingNewLine]\[IndentingNewLine] (*list\ of\ 1\ \ surface\ DTM\ array*) \[IndentingNewLine] \(\(\(dive = {{diveDepth, diveTime, {fO2Mix, fN2Mix}}}\) \)\(;\)\( (*this\ array\ is\ for\ a\ single\ \ \(level : dive\) = {DTM1}*) \)\(\[IndentingNewLine]\)\(\(descentRate = 100. \) \)\(;\)\( (*\([feet/ min]\)*) \)\(\[IndentingNewLine]\)\(\(ascentRate = 33. \) \)\(;\)\( (*\([feet/min]\)\ magnitude\ should\ be < or = to\ the\ first\ stop\ \ depth*) \)\(\[IndentingNewLine]\)\(\(stopIncrement = 10. \) \)\(;\)\( (*staged\ ascent\ steps\ in[ feet]*) \)\(\[IndentingNewLine]\)\(\(tsurface = 0.0\) \)\(;\)\( (*\([min]\)\ length\ of\ time\ to\ track\ in\ Plot . nb\ after\ surfacing*) \)\)\)\)\)], "Input", CellFrame->True, CellMargins->{{100, Inherited}, {Inherited, Inherited}}, CellFrameLabels->{{ "Multilevel Dive ", Inherited}, {Inherited, Inherited}}, Background->GrayLevel[0.849989]] }, Closed]], Cell[CellGroupData[{ Cell["Build DTM List for Descent and Dive", "Subsection", CellFrame->False, FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[CellGroupData[{ Cell[BoxData[{ \(\(\(Clear[dtm, depth, descentDepths, descentTime, descentTimes, descentMix, descentList, dropDescentList, pDeepest, pressure, time, mix, ptm, nStages]\)\(\n\)\(\t\)\(\n\)\( (*Build\ descent\ {depth, \ time, \ {mix}}\ list*) \)\(\n\)\( (*the\ descent\ partial\ \ pressures\ are\ calculated\ by\ stages\ rather\ than\ analytically*) \)\(\n\) \)\), "\n", \(descentTime\ = \ Floor[dive[\([1, 1]\)]\/descentRate]; \ (*approximate\ descent\ time\ \ to\ first\ dive\ stage*) \[IndentingNewLine]\n descentDepths\ = \ N[Table[descentRate\ i, {i, descentTime}]]; (*list\ of\ descent\ depths\ at\ 1\ min\ \ intervals*) \[IndentingNewLine]descentTimes\ = \ N[Table[i, {i, Length[descentDepths]}]]; (*list\ of\ 1\ min\ descent\ intervals\ *) \ndescentMix\ = \ Table[{fO2TravelMix, fN2TravelMix}, {descentTime}]; (*list\ of\ travel\ mixes\ *) \[IndentingNewLine]descentList\ = \ Transpose[{descentDepths, descentTimes, descentMix\ }]; (*list\ of\ descent\ Depth, \ Time, \ and\ Mix*) \), "\n", \(\(dropDescentList\ = \ If[Last[descentDepths] === \(First[dive]\)[\([1]\)]\ , Drop[descentList, \(-1\)], descentList];\) (*avoid\ redundancy*) \n\), "\n", \(dtm\ = \ Join[start, dropDescentList, dive]; \ (*list\ of\ depth, \ time, \ mix\ arrays\ through\ last\ dive\ stage*) \[IndentingNewLine]\n depth\ = \ \(Transpose[ dtm]\)[\([1]\)]; (*list\ of\ stage\ depths*) \), "\n", \(\(pressure\ = \((\(Transpose[dtm]\)[\([1]\)]/33. \ + \ pSurface)\);\)\ (*list\ of\ stage\ ambient\ pressures*) \), "\ \[IndentingNewLine]", \(time\ = \ \(Transpose[dtm]\)[\([2]\)]; \ (*list\ of\ stage\ run - times*) \[IndentingNewLine]mix\ \ = \ \(Transpose[ dtm]\)[\([3]\)]; (*list\ of\ stage\ mixes\ {fO2, fN2}*) \n\n (*ptm\ = \ {{\((pAmbient - pH2OCO2)\), \ time, \ {fO2, fN2}}}*) \[IndentingNewLine]ptm\ = \ Transpose[{\((pressure\ - \ pH2OCO2)\), time, mix}]\ ;\ \n (*p\ == \ alveolar\ pressure*) \[IndentingNewLine]\), "\n", \(\(pDeepest\ = \ N[Max[pressure]];\)\ (*max\ hydrostatic\ pressure\ reached\ during\ \ dive*) \), "\[IndentingNewLine]", \(nStages\ = \ \((Length[pressure]\ - \ 1)\); \ (*number\ of\ dive\ stages\ including\ descent*) \n nDStages\ = \ \((nStages\ - 0)\); (*number\ of\ descent\ stages*) \n\[IndentingNewLine] \ (*print\ dive\ profile\ to\ check\ DTM\ definition*) \n\n Print["\<_______Dive_______\>"];\), "\n", \(\(\(Print["\"];\)\(\n\) \)\), "\[IndentingNewLine]", \(\(\(TableForm[dtm]\)\(\n\) \)\t\), "\n", \(Null\)}], "Input"], Cell[BoxData[ \("_______Dive_______"\)], "Print"], Cell[BoxData[ \("depth, time, fO2/fN2"\)], "Print"], Cell[BoxData[ InterpretationBox[GridBox[{ {"0.`", "0.`", GridBox[{ {"0.21`"}, {"0.79`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"100.`", "1.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"200.`", "120.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ {{0.0, 0.0, {.20999999999999999, .79000000000000004}}, {.1*^3, 1.0, {.17999999999999999, .37}}, {.2*^3, .12*^3, {.17999999999999999, \ 37}}}]]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Arrays of Pressure Functions to Track ppHe and ppN2 During Dive Stages\ \>", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[CellGroupData[{ Cell[BoxData[{ \(\(\(Clear[tf, ti, kHe, kN2, pf, po, pN2i, pN2f, \ pN20, pHe0, pHei, pHef, dt, pt, outFactor, ppN2Table, ppHeTable]\)\(\n\)\(\n\)\( (*PN2[t]\ = \ Table\ of\ N2Pressure[t]\ by\ Stage*) \)\(\n\)\( (*PHe[t]\ = \ Table\ of\ HePressure[ t]\ by\ Stage*) \)\(\n\)\( (*Elements : \ \(\(ptm[\([stage]\)]\)[\ \([alveolar\ \(pressure : \ 1\); \ time : \ 2; \ mix\ = \ 3]\)]\)[\([fO2 : \ 1; \ \ fN2 : \ 2]\)]*) \)\(\n\)\(\n\) \) (*Track\ N2\ During\ Dive\ Stages*) \), "\[IndentingNewLine]", \(\(\(Clear[pN2, k, pf, po, ti]\)\(\n\) \)\), "\[IndentingNewLine]", \(\(Module[{i, ppN2Stage}, \[IndentingNewLine]pN2[ t] = \ {}; \[IndentingNewLine]po\ = \ ptm[\([1, 3, 2]\)]\ ptm[\([1, 1]\)]; \[IndentingNewLine]\n For[i\ = \ 1, i\ <= \ nStages\ , \(i++\), \n\t\((\[IndentingNewLine]\(AppendTo[ pN2[t], \n\t\tppN2Stage\ = \ \((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. {\n\t\tpf -> ptm[\([i + 1, 3, 2]\)]* ptm[\([i + 1, 1]\)], \n\t\tk\ -> kN2, \ \n\t\tti\ -> \ ptm[\([i, 2]\)]\n\t\t}];\)\n\t\(Clear[ po];\)\n\t\(po\ = \ ppN2Stage /. t -> ptm[\([i\ + \ 1, 2]\)];\)\t\n)\)]\ ;\n];\)\), "\n", \(\(pN2[ t];\)\n\t\n (*Table\ of\ N2\ tensions\ by\ stage\ and\ by\ \ \(compartment : \ ppN2Table[\([compartment, \ stage]\)]\)*) \[IndentingNewLine]\), "\n", \(Clear[ppN2Table]\), "\n", \(\(Module[{i}, ppN2Table[t] = Table[pN2[t] /. kN2 \[Rule] \(\(Log[2]\)\(\ \)\)/halftN2[\([i]\)], {i, 1, nCompartments}]];\)\), "\n", \(\(ppN2Table[t];\)\n\n\n (*Track\ He\ During\ Dive\ Stages*) \), "\n", \(\(\(Clear[pHe, k, pf, po, ti]\)\(\n\) \)\), "\[IndentingNewLine]", \(\(Module[{i, ppHeStage}, \npo\ = \ 0. ; \npHe[t] = \ {}; \n For[i\ = \ 1, i\ <= nStages\ , \(i++\), \n\t\((\[IndentingNewLine]\(AppendTo[ pHe[t], \n\t\tppHeStage\ = \ \((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. {\n\t\tpf -> \((1\ - \ ptm[\([i + 1, 3, 2]\)]\ - \ ptm[\([i + 1, 3, 1]\)])\)* ptm[\([i + 1, 1]\)], \n\t\tk\ -> kHe, \ \n\t\tti\ -> \ ptm[\([i, 2]\)]\n\t\t}];\)\n\t\(Clear[ po];\)\n\t\(po\ = \ ppHeStage /. t -> ptm[\([i\ + \ 1, 2]\)];\)\n)\)]\ ;\ \n];\)\), "\n", \(\(pHe[ t];\)\n\n (*Table\ of\ He\ Pressure\ by\ Stage\ and\ by\ \ \(nCompartment : \ \(ppN2Table[\([compartment]\)]\)[\([stage]\)]\)*) \), "\n\ ", \(\(\(Clear[ppHeTable]\)\(\[IndentingNewLine]\) \)\), "\n", \(\(Module[{i}, ppHeTable[t] = Table[pHe[t] /. kHe \[Rule] Log[2]/halftHe[\([i]\)], {i, 1, nCompartments}]];\)\), "\n", \(\(ppHeTable[ t];\)\n\n (*Build\ list\ of\ total\ inert\ gas\ partial\ pressures\ \ for\ all\ stages*) \), "\n", \(\(\(Clear[ppTotalTable]\)\(\[IndentingNewLine]\) \)\), "\n", \(\(ppTotalTable[t]\ = \ ppN2Table[t]\ + \ ppHeTable[t]\ ;\)\n\n (*here' s\ a\ clean\ list\ of\ total\ inert\ pps . \ Stages\ are\ columns; \ compartments\ are\ rows*) \), "\n", \(TableForm[Chop[ppTotalTable[t]]]\ \), "\n", \(\)}], "Input", CellTags->"Arrays of Pressure Functions"], Cell[BoxData[ TagBox[GridBox[{ {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.4584737654317999`\)\ t\) - 0.7575805422647526`\ \[ExponentialE]\^\(\(-0.17328679513998632`\ \)\ t\)\), \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 2.4721196443654003`\ \ \[ExponentialE]\^\(\(-0.4584737654317999`\)\ \((\(-1.`\) + t)\)\) - 1.7582588834685167`\ \[ExponentialE]\^\(\(-0.17328679513998632`\ \)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \[ExponentialE]\^\(\(-0.22923688271589995`\ \)\ t\) - 0.7575805422647526`\ \[ExponentialE]\^\(\(-0.08664339756999316`\ \)\ t\)\), \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 2.7577091846825286`\ \[ExponentialE]\^\(\(-0.22923688271589995`\ \)\ \((\(-1.`\) + t)\)\) - 1.8159165415220864`\ \[ExponentialE]\^\(\(-0.08664339756999316`\ \)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \[ExponentialE]\^\(\(-0.14671160493817598`\ \)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.055451774444795626`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 2.8776358680291954`\ \[ExponentialE]\^\(\(-0.14671160493817598`\ \)\ \((\(-1.`\) + t)\)\) - 1.8379269862322136`\ \ \[ExponentialE]\^\(\(-0.055451774444795626`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \[ExponentialE]\^\(\(-0.09912946279606485`\ \)\ t\) - 0.7575805422647526`\ \[ExponentialE]\^\(\(-0.03746741516540245`\ \)\ t\)\), \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 2.95141661073162`\ \[ExponentialE]\^\(\(-0.09912946279606485`\)\ \ \((\(-1.`\) + t)\)\) - 1.8509332479502665`\ \[ExponentialE]\^\(\(-0.03746741516540245`\ \)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \[ExponentialE]\^\(\(-0.06792203932322961`\ \)\ t\) - 0.7575805422647526`\ \[ExponentialE]\^\(\(-0.02567211779851649`\ \)\ t\)\), \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.0017484195269706`\ \[ExponentialE]\^\(\(-0.06792203932322961`\ \)\ \((\(-1.`\) + t)\)\) - 1.859591488511933`\ \ \[ExponentialE]\^\(\(-0.02567211779851649`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.047882377590788505`\)\ t\) - 0.7575805422647526`\ \[ExponentialE]\^\(\(-0.01809783761253121`\ \)\ t\)\), \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.0349067623348533`\ \ \[ExponentialE]\^\(\(-0.047882377590788505`\)\ \((\(-1.`\) + t)\)\) - 1.8652054146089247`\ \[ExponentialE]\^\(\(-0.01809783761253121`\ \)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \[ExponentialE]\^\(\(-0.02852091853386003`\ \)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.010779893943389508`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.067580278528916`\ \ \[ExponentialE]\^\(\(-0.02852091853386003`\)\ \((\(-1.`\) + t)\)\) - 1.8706698855793662`\ \ \[ExponentialE]\^\(\(-0.010779893943389508`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.023816818983470125`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.009001911435843446`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.07561468283589`\ \ \[ExponentialE]\^\(\(-0.023816818983470125`\)\ \((\(-1.`\) + t)\)\) - 1.8720035936780453`\ \ \[ExponentialE]\^\(\(-0.009001911435843446`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.016824725336946785`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.006359148445504085`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.0876269420459224`\ \ \[ExponentialE]\^\(\(-0.016824725336946785`\)\ \((\(-1.`\) + t)\)\) - 1.8739903817435821`\ \ \[ExponentialE]\^\(\(-0.006359148445504085`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.012560925080323287`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.004747583428492776`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.094993386881095`\ \[ExponentialE]\^\(\(-0.012560925080323287`\ \)\ \((\(-1.`\) + t)\)\) - 1.8752045109150985`\ \ \[ExponentialE]\^\(\(-0.004747583428492776`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.009806925463781816`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.0037066694147590653`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.0997681152414116`\ \ \[ExponentialE]\^\(\(-0.009806925463781816`\)\ \((\(-1.`\) + t)\)\) - 1.8759897607776805`\ \ \[ExponentialE]\^\(\(-0.0037066694147590653`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.007673201095092885`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.0029001974082006076`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.1034764967921538`\ \ \[ExponentialE]\^\(\(-0.007673201095092885`\)\ \((\(-1.`\) + t)\)\) - 1.876598713333756`\ \ \[ExponentialE]\^\(\(-0.0029001974082006076`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.0060127706941875405`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.002272613706753919`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.1063677799649208`\ \ \[ExponentialE]\^\(\(-0.0060127706941875405`\)\ \((\(-1.`\) + t)\)\) - 1.877072930437161`\ \[ExponentialE]\^\(\(-0.002272613706753919`\ \)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.004702295030069743`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.0017773004629742187`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.1086530841658284`\ \ \[ExponentialE]\^\(\(-0.004702295030069743`\)\ \((\(-1.`\) + t)\)\) - 1.8774474110413695`\ \ \[ExponentialE]\^\(\(-0.0017773004629742187`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.0036825202042714846`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.0013918618083533037`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.110433515953484`\ \ \[ExponentialE]\^\(\(-0.0036825202042714846`\)\ \((\(-1.`\) + t)\)\) - 1.8777389495355512`\ \ \[ExponentialE]\^\(\(-0.0013918618083533037`\)\ \((\(-1.`\) + t)\)\)\)}, {\(\(\(3.1947958532695373`\)\(\[InvisibleSpace]\)\) - 1.7532416267942583`\ \ \[ExponentialE]\^\(\(-0.0028880237192554325`\)\ t\) - 0.7575805422647526`\ \ \[ExponentialE]\^\(\(-0.001091570363086528`\)\ t\)\), \ \(\(\(5.679644338118022`\)\(\[InvisibleSpace]\)\) - 3.111821891607793`\ \ \[ExponentialE]\^\(\(-0.0028880237192554325`\)\ \((\(-1.`\) + t)\)\) - 1.8779661621835113`\ \ \[ExponentialE]\^\(\(-0.001091570363086528`\)\ \((\(-1.`\) + t)\)\)\)} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], Function[ BoxForm`e$, TableForm[ BoxForm`e$]]]], "Output", CellTags->"Arrays of Pressure Functions"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Ascent Limiting Bubble Constants\n", StyleBox["CHECK CELL EVALUATION PROPERTIES", FontColor->RGBColor[1, 1, 0]] }], "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[CellGroupData[{ Cell[TextData[{ "1st Iteration Permeable Range (DEFAULT)\n", StyleBox["Check Cell Evaluation Setting", FontColor->RGBColor[1, 0, 0]] }], "Subsubsection", CellFrame->True, Background->GrayLevel[0.849989]], Cell[TextData[StyleBox["This Subsubsection is set as \"Evaluatable\" by \ default. If you want to calculate iterations, or do an impermeable \ calculation, you need to deselect this cell by the menu sequence: Cell->Cell \ Properties->Cell Evaluatable, and then set the corresponding cell that you \ want to use as \"Evaluatable.\"", FontColor->RGBColor[0, 0, 1]]], "Text"], Cell[BoxData[ \(\(\(\ \)\( (*VPM\ constants*) \)\(\n\)\(\n\)\(Clear[\[Gamma], \[Gamma]c\ \ , \[Lambda], r0N2, r0He\ , rMinN2, rMinHe, tSkinN2, tSkinHe, pSSminN2, pSSminHe, pSSnewN2, pSSnewHe, pSSnew, tR, IterationTag]\n\n \(IterationTag\ = \ "\<1st Iteration\>";\)\n\n units\ = \ 1000. /101325. ; \ (*with\ \(conversion : \ \(dyne/cm\)/ um\) = \(1000\ Pa\ = \ 1000/101325 atm\)*) \n\[Gamma]\ = \ 17.9; \ (*dyne/cm*) \n\[Gamma]c\ = \ 257; \ (*dyne/cm*) \n\[Lambda]\ = \ 7180. /33. ; (*\([fsw/\(fsw/atm\)\ = \ atm]\); \ use\ 7500\ ffw*) \n tR\ = \ 20160. ; \ (*regeneration\ time\ [ min]*) \n\n\n (*calculate\ max\ allowed\ Nitrogen\ supersaturation\ \ gradients*) \n r0N2ata\ = \ 1.0\ ; (*r0\ at\ 1\ Ata\ range\ = \ 0.8 - 1.2\ \[Mu]m . \ Use\ large\ r0\ for\ deco\ dives*) \n r0N2\ = \ \((\(\(1\)\(\ \)\)\/r0N2ata\ + \((\ pSurface\ - 1.0)\)\/\(2. \ \ units\ \((\[Gamma]c\ - \ \[Gamma])\)\))\)\^\(-1\); \ (*modified\ for\ \ altitude*) \n rMinN2o\ = \ \((\(\(1\)\(\ \)\)\/r0N2ata\ + \((\ \ pDeepest\ - \ \ pSurface)\)\/\(2. \ units\ \((\[Gamma]c\ - \ \[Gamma])\)\))\)\^\(-1\);\n \(rMinN2\ = \ rMinN2o + \((r0N2 - rMinN2o)\)\ \((1. - \ Exp[\(-\ t\)/tR])\) /. t -> diveTime;\)\n \(pSSminN2\ = \ \(\(\ \)\(2. \ \[Gamma]\ units\ \((\[Gamma]c\ - \ \ \[Gamma])\)\)\)\/\(\(\[Gamma]c\)\(\ \)\(rMinN2\)\(\ \)\);\)\n\n\n (*calculate\ \ max\ allowed\ Helium\ supersaturation\ gradients*) \n r0Heata\ = \ 0.8; \ (*r0He\ is\ expected\ to\ be\ <= \ r0N2*) \n r0He\ = \ \ \((\(\(1\)\(\ \)\)\/r0Heata\ + \(\(\ \)\((pSurface\ - 1.0)\ \)\)\/\(2. \ units\ \((\[Gamma]c\ - \ \[Gamma])\)\))\)\^\(-1\)\ ; \ \ (*modified\ for\ altitude*) \n rMinHeo\ = \ \ \ \((\(\(1\)\(\ \)\)\/r0Heata\ + \(\(\ \)\((\ pDeepest\ \ - \ pSurface)\)\)\/\(2. \ units\ \((\[Gamma]c\ - \ \[Gamma])\)\))\)\^\(-1\);\ \n \(rMinHe\ = \ rMinHeo + \((r0He - rMinHeo)\)\ \((1. - \ Exp[\(-\ t\)/tR])\) /. t -> diveTime;\)\n \(pSSminHe\ = \ \(\(\ \)\(2. \ \[Gamma]\ units\ \((\[Gamma]c\ - \ \ \[Gamma])\)\)\)\/\(\(\[Gamma]c\)\(\ \)\(rMinHe\)\(\ \)\);\)\n\n (*calculate\ \ total\ supersaturation\ gradient\ allowed\ for\ sum\ of\ compartment\ \ tensions*) \n (*for\ ea . \ compartment, \ weight\ each\ N2\ and\ He\ gradient\ by\ a\ fraction\ corrosponding\ to\ \ each\ gas' s\ partial\ tension*) \n \ \(pSSmin\ = \((\ pSSminN2\ \(Transpose[ Evaluate[ppN2Table[t]] /. t -> Last[ time]\ ]\)[\([nStages]\)]\ + \n\t\tpSSminHe\ \ \(Transpose[Evaluate[ppHeTable[t]] /. t -> Last[time]\ ]\)[\([nStages]\)])\)/\((\(Transpose[ Evaluate[ppTotalTable[t]] /. t -> Last[time]\ ]\)[\([nStages]\)])\);\)\n\n pSSnew\ = \ pSSmin; \ (*these\ are\ true\ only\ for\ first\ iteration*) \n pSSnewHe = pSSminHe;\n \(pSSnewN2 = pSSminN2;\)\)\)\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Iterations Permeable Range\n", StyleBox["Check Cell Evaluation Setting", FontColor->RGBColor[1, 0, 0]] }], "Subsubsection", CellFrame->True, Background->GrayLevel[0.849989]], Cell[TextData[{ StyleBox[ "This Subsubsection is NOT set as \"Evaluatable\" by default. If you want \ to calculate iterations, you need to first run the notebook through the first \ iteration calculation. Then, deselect the above ", FontColor->RGBColor[0, 0, 1]], StyleBox["First Iteration Permeable", Background->GrayLevel[0.666667]], StyleBox[ " cell under the menu sequence: Cell->Cell Properties->Cell Evaluatable, \ and set the following cell as Evaluatable.\n\nRun this cell and the cells \ below sequentially until tDeco converges. Note the red text below defining \ tDeco. This must be updated manually for each iteration.", FontColor->RGBColor[0, 0, 1]] }], "Text"], Cell[BoxData[{ \(\(Clear[pSSnewN2, pSSnewHe, bN2, cN2, bHe, cHe, tDeco, pSSnew, IterationTag];\)\n\), "\n", \(\(IterationTag\ = \ "\";\)\n\), "\n", \(tDeco\ = \(\(1\)\(.\)\); \ (*This\ must\ be\ updated\ at\ each\ step\ \ of\ an\ iterative\ \(calculation!\)*) \n\n (*allowed\ Nitrogen\ \ supersaturation\ gradients*) \n bN2\ = \ pSSminN2\ + \ Table[\((\ \(\[Lambda]\ \[Gamma]\)\/\(\[Gamma]c\ \((tDeco\ + \ \ halftN2[\([i]\)]\/Log[2])\)\))\), {i, nCompartments}]; (*\([atm]\)*) \n cN2\ = \ \((\(\(\ \)\(\[Gamma]\)\)\/\[Gamma]c)\)\^2\ Table[\((\ \(\ \[Lambda]\ \((pDeepest\ - \ pSurface)\)\)\/\((tDeco\ + \ \ halftN2[\([i]\)]\/Log[2])\))\), {i, nCompartments}]; (*\([atm]\)*) \n\n pSSnewN2\ = 1. \/2. \ \((bN2\ + \ \@\(bN2\^2\ - 4. \ cN2\))\);\n\n\n (*allowed\ \ Helium\ supersaturation\ gradients*) \), "\n", \(bHe\ = \ pSSminHe\ + \ Table[\((\ \(\[Lambda]\ \[Gamma]\)\/\(\[Gamma]c\ \((tDeco\ + \ \ halftHe[\([i]\)]\/Log[2])\)\))\), {i, nCompartments}]; (*\([atm]\)*) \n cHe\ = \ \((\(\(\ \)\(\[Gamma]\)\)\/\[Gamma]c)\)\^2\ Table[\((\ \(\ \[Lambda]\ \((pDeepest\ - \ pSurface)\)\)\/\((tDeco\ + \ \ halftHe[\([i]\)]\/Log[2])\))\), {i, nCompartments}]; (*\([atm]\)*) \n\n pSSnewHe\ = 1. \/2. \ \((bHe\ + \ \@\(bHe\^2\ - 4. \ cHe\))\);\n\n\n (*weight\ N2\ \ and\ He\ gradients\ according\ to\ compartment\ tensions*) \), "\n", \(\(pSSnew\ = \ \((pSSnewN2\ \(Transpose[ Evaluate[ppN2Table[t]] /. t -> Last[ time]\ ]\)[\([nStages]\)]\ + \n\t\tpSSnewHe\ \ \(Transpose[Evaluate[ppHeTable[t]] /. t -> Last[time]\ ]\)[\([nStages]\)])\)/\((\(Transpose[ Evaluate[ppTotalTable[t]] /. t -> Last[time]\ ]\)[\([nStages]\)])\)\ ;\)\), "\n", \(\)}], "Input", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Impermeable Range\n", StyleBox["Check Cell Evaluation Setting", FontColor->RGBColor[1, 0, 0]] }], "Subsubsection", CellFrame->True, Background->GrayLevel[0.849989]], Cell["\<\ For Impermeable range diving (pAmbient ~> 8 or 9 atmospheres)\ \>", "Text", Evaluatable->False, FontColor->RGBColor[0, 0, 1]], Cell[BoxData[{ \(\(Clear[\[Gamma], \[Gamma]c, r0N2, r0He, tSkinN2, tSkinHe, pSSminN2, pSSminHe, pSSnewN2, tensionPI, pSSnewHe, pSSnew, pImpermeable, rStarN2, rStarHe, rBarN2, rBarHe, BrN2, BrHe, r0N2ata, r0Heata, IterationTag];\)\n\), "\n", \(\(IterationTag\ = \ "\";\)\n\), "\n", \(units\ = \ 1000. /101325. ; \ (*with\ \(conversion : \ \(dyne/cm\)/ um\) = \(1000\ Pa\ = \ 1000/101325 atm\)*) \n\[Gamma]\ = \ 17.9; \ (*\([dyne/cm]\)*) \n\[Gamma]c\ = \ 257; \ (*\([dyne/cm]\)*) \n\npImpermeable = 9.2; (*\([atm]\)*) \n tensionPI = 1. \ pSurface;\n\n\n\ (*allowed\ Nitrogen\ supersaturation\ gradients*) \ \), "\n", \(\(r0N2ata = 1.2;\)\), "\n", \(\(r0N2 = 1. \/\((1. \/r0N2ata + \(pSurface - 1. \)\/\(2. \ units\ \((\[Gamma]c \ - \[Gamma])\)\))\);\)\), "\n", \(\(tSkinN2 = \(units\ 2. \ \[Gamma]\)\/r0N2;\)\), "\n", \(\(rStarN2 = \(units\ 2. \ \((\[Gamma]c - \[Gamma])\)\)\/\(pImpermeable \ - pSurface + \(units\ 2. \ \((\[Gamma]c - \[Gamma])\)\)\/r0N2\);\)\n\), "\n", \ \(\(Module[{l}, l = \n\t\tLast[ Solve[\((\(pDeepest - pImpermeable + tensionPI\)\/\(units\ 2. \ \ \((\[Gamma]c - \[Gamma])\)\) + 1. \/rStarN2)\)\ rmN2\^3 - rmN2\^2 - \(tensionPI\ rStarN2\^3\)\/\(units\ 2. \ \((\ \[Gamma]c - \[Gamma])\)\) == 0. , rmN2]\n\t\t]; \n\t\n\t rMaxN2 = rmN2 /. l;];\)\n\), "\n", \(\(rBarN2 = rStarN2\^2\/rMaxN2;\)\n\), "\n", \(\(BrN2 = \(units\ 2. \ \((\[Gamma]c - \[Gamma])\)\)\/\(tensionPI\ \ \((rStarN2\/rMaxN2 + rMaxN2\/rStarN2 + 1. )\)\);\)\n\), "\n", \(\(pSSminN2 = tSkinN2\ \((1. - \[Gamma]\/\[Gamma]c)\) + \(\(\[Gamma]\)\(\ \)\)\/\ \[Gamma]c\ \((pImpermeable - tensionPI + \(pDeepest - pImpermeable\)\/\(1. + rBarN2\/BrN2\ \))\);\)\), "\n", \(\(pSSnewN2 = Table[pSSminN2, {nCompartments}];\)\n\n\n\n (*allowed\ Helium\ \ supersaturation\ gradients*) \), "\n", \(\(r0Heata = 1.0;\)\), "\n", \(\(r0He = 1. \/\((1. \/r0Heata + \(pSurface - 1. \)\/\(2. \ units\ \((\[Gamma]c \ - \[Gamma])\)\))\);\)\), "\n", \(\(tSkinHe = \(units\ 2. \ \[Gamma]\)\/r0He;\)\), "\n", \(\(rStarHe = \(units\ 2. \ \((\[Gamma]c - \[Gamma])\)\)\/\(pImpermeable \ - pSurface + \(units\ 2\ \((\[Gamma]c - \[Gamma])\)\)\/r0He\);\)\n\), "\n", \(\(Module[{l}, l = \n\t\tLast[ Solve[\((\(pDeepest - pImpermeable + tensionPI\)\/\(units\ 2. \ \ \((\[Gamma]c - \[Gamma])\)\) + 1. \/rStarHe)\)\ rmHe\^3 - rmHe\^2 - \(tensionPI\ rStarHe\^3\)\/\(units\ 2. \ \((\ \[Gamma]c - \[Gamma])\)\) == 0. , rmHe]]; \n\t rMaxHe = rmHe /. l];\)\n\), "\n", \(\(rBarHe = rStarHe\^2\/rMaxHe;\)\), "\n", \(\(BrHe = \(units\ 2. \ \((\[Gamma]c - \[Gamma])\)\)\/\(tensionPI\ \ \((rStarHe\/rMaxHe + rMaxHe\/rStarHe + 1. )\)\);\)\), "\n", \(\(pSSminHe = tSkinHe\ \((1. - \[Gamma]\/\[Gamma]c)\) + \(\(\(\[Gamma]\)\(\ \)\)\/\ \(\(\[Gamma]c\)\(\ \)\)\) \((pImpermeable - tensionPI + \(pDeepest - pImpermeable\)\/\(1. + rBarHe\/BrHe\ \))\);\)\n\), "\n", \(\(pSSnewHe = Table[pSSminHe, {nCompartments}];\)\n\n\n\n (*weight\ N2\ and\ He\ \ gradients\ according\ to\ compartment\ tensions*) \), "\n", \(\(pSSnew = \((pSSnewN2\ \(Transpose[ Evaluate[ ppN2Table[t] /. t \[Rule] Last[time]]]\)\[LeftDoubleBracket]nStages\ \[RightDoubleBracket] + pSSnewHe\ \(Transpose[ Evaluate[ ppHeTable[t] /. t \[Rule] Last[time]]]\)\[LeftDoubleBracket]nStages\ \[RightDoubleBracket])\)/\(Transpose[ Evaluate[ ppTotalTable[t] /. t \[Rule] Last[time]]]\)\[LeftDoubleBracket]nStages\ \[RightDoubleBracket];\)\n\t\t\), "\n", \(\t\)}], "Input", Evaluatable->False] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Calculate Ascent to First Stop", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[BoxData[ \(\(\(\n\)\(Clear[stopSelect, lFlag, seriesCeiling, dFirst, ascentTimeList, ascentTime, ascentToStop, ascentDepths, ascentMix, ascentList, ascentDTM, ascentPressures, PN2Ascent, PHeAscent, nAscentStops\n]\n\n stopSelect\ = \ Select[\n\t\t\t\t33. \ \((\((\(Transpose[ Evaluate[ ppTotalTable[t] /. t -> Last[time]\ ]]\)[\([nStages]\)])\)\ - \ pSSnew\ - \ Table[pSurface, {nCompartments}])\), \n\t\t\t\t#\ > \ 0. \ &]; (*list\ of\ minimum, \ non\ negative\ allowed\ ascent\ depths\ for\ compartments*) \n\n lFlag\ = \ Length[stopSelect];\n If[lFlag\ > \ 0, seriesCeiling\ = \ Ceiling[Max[stopSelect]], seriesCeiling\ = \ 0.0]; (*define\ ascent\ ceiling\ for\ deco\ and\ nodeco*) \n\n dFirstS\ = \ stopIncrement\ Ceiling[ seriesCeiling/ stopIncrement]\ ; (*Depth\ of\ first\ series\ stop\ rounded\ to\ \ increment*) \n\n\n (*now, \ build\ DTM\ matrix\ for\ ascent\ off\ bottom\ to\ first\ stop*) \n\n ascentTime\ = \ If[\n\t\t\((\(Last[dtm]\)[\([1]\)]\ - \ dFirstS)\) >= ascentRate, \n\t\tFloor[\((\(Last[dtm]\)[\([1]\)]\ - \ dFirstS)\)/ ascentRate], \n\t\t1. ]; (*time \((min)\)\ to\ ascend\ to\ first\ \ \(\(stop\)\(.\)\)*) \n\n ascentTimeToStop\ = \ Ceiling[\((\(Last[dtm]\)[\([1]\)]\ - \ dFirstS)\)/ ascentRate]; (*time \((min)\)\ to\ add\ to\ bottom\ time\ at\ \ start\ of\ deco\ \(\(stages\)\(.\)\)*) \ \n\n ascentDepths\ = \ Table[\((\(Last[dtm]\)[\([1]\)]\ - \ ascentRate\ i)\), {i, ascentTime}];\n \(ascentPressures\ = \ \((1. \ + \ ascentDepths/33. )\);\)\n \(ascentTimeList\ = \ Table[\((\(Last[dtm]\)[\([2]\)] + \ i)\), {i, ascentTime}];\)\n ascentMix\ = \ Table[{fO2Mix, fN2Mix}, {ascentTime}]; (*may\ not\ be\ optimal\ \(mix\ --\) assume\ no\ switch\ ' til\ stop*) \n\n ascentDTM\ = \ Transpose[{ascentDepths, ascentTimeList, ascentMix\ }];\n \(ascentList\ = \ Transpose[{ascentPressures, ascentTimeList, ascentMix\ }];\)\n \(nAscentStops\ = \ Length[ascentList];\)\n\n\n (*now\ calculate\ in\ and\ out\ gasing\ \ on\ way\ up\ to\ first\ stop*) \n\n (*Start\ with\ tensions\ at\ end\ of\ \ dive\ stages*) \n \(pN2Ascent\ = \ Evaluate[\ \(Transpose[ppN2Table[t]]\)[\([nStages]\)] /. t -> \ Last[time]];\)\n \(pHeAscent\ = \ \ Evaluate[\(Transpose[ppHeTable[t]]\)[\([nStages]\)] /. t -> \ Last[time]];\)\n\n Module[{i}, \n For[i\ = \ 1, i <= \ \((nAscentStops\ )\), \(i++\), \[IndentingNewLine]\((\n\t \ (*Outgas/ingas\ N2\ up\ to\ first\ stop*) \t\[IndentingNewLine]Clear[ TemppN2Ascent, k, pf, po, ti]; \[IndentingNewLine]TemppN2Ascent\ = \ {}; \n\ \[IndentingNewLine]Module[{m}, \t\n\t For[m\ = \ 1, m <= \ nCompartments, \(m++\), \n\t\tAppendTo[ TemppN2Ascent, \n\t\t\t\((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. \n\t\t\t{pf\ -> \ ascentList[\([\((i\ )\), 3, 2]\)]\ ascentList[\([\((i)\), 1]\)], \n\t\t\tpo\ -> \ pN2Ascent[\([m]\)], \n\t\t\tk\ -> \ Log[2]/halftN2[\([m]\)], \n\t\t\tt -> \ ascentTimeList[\([i]\)]\ , \n\t\t\tti\ -> \ \(Last[ dtm]\)[\([2]\)]\n\t\t}]; \n\t pN2Ascent[\([m]\)]\ = \ TemppN2Ascent[\([m]\)];\t\n\t]\ \ ; \ (*m\ loop\ over\ \ compartments*) \n\t]; \ (*m\ module*) \n\n\t\t\n\t (*Outgas/ ingas\ He\ up\ to\ first\ stop*) \t\n\t Clear[TemppHeAscent, k, pf, po, ti]; \n\t TemppHeAscent\ = \ {}; \n\t Module[{m}, \n\t For[m\ = \ 1, m <= \ nCompartments, \(m++\), \n\t\tAppendTo[ TemppHeAscent, \n\t\t\t\((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. \n\t\t\t{pf\ -> \((1\ - \ ascentList[\([\((i)\), 3, 1]\)]\ - \ ascentList[\([\((i)\), 3, 2]\)])\)\ ascentList[\([\((i\ )\), 1]\)], \n\t\t\tpo\ -> \ pHeAscent[\([m]\)], \n\t\t\tk\ -> \ Log[2]/halftHe[\([m]\)], \n\t\t\tt -> \ ascentTimeList[\([i]\)]\ , \n\t\t\tti\ -> \ \(Last[ dtm]\)[\([2]\)]\n\t\t}]; \n\t pHeAscent[\([m]\)]\ = \ TemppHeAscent[\([m]\)];\t\t\n\t]\ ; \ \ (*m\ loop\ over\ \ compartments*) \n\t]; \ \ (*m\ module*) \n)\)\t\n]; \ \ \ (*i\ loop\ over\ \ stops*) \n]; (*\ i\ module*) \t\t\t\n\n\n pN2Ascent; \t (*ppN2\ after\ ascent\ to\ 1 st\ stop*) \n pHeAscent; \t (*ppHe\ after\ ascent\ to\ 1 st\ stop*) \n\n ppTotalAscent\ = \ pN2Ascent + pHeAscent;\n\n (*recalculate\ ceiling\ to\ adjust\ for\ ascent\ to\ 1 st\ stop*) \n (*this\ is\ not\ entirely\ self\ \(consistent\ --\) but\ is\ ok\ for\ updating\ the\ tensions*) \n \(Clear[seriesCeiling, dFirstS, lFlag, stopSelect];\)\n\n \(stopSelect\ = \ Select[\n\t\t33. \ \((\((\(Transpose[ Evaluate[ ppTotalTable[t] /. t -> Last[time]\ ]]\)[\([nStages]\)])\)\ - \ pSSnew\ - \ Table[pSurface, {nCompartments}])\), \n\t\t\t\t#\ > \ 0. \ &];\)\n\n\n \(lFlag\ = \ Length[stopSelect];\)\n \(If[lFlag\ > \ 0, seriesCeiling\ = \ Ceiling[Max[stopSelect]], seriesCeiling\ = \ 0.0];\)\n\n \(\(\(dFirstS\ = \ stopIncrement\ Ceiling[ seriesCeiling/ stopIncrement]\) \)\(;\)\(\ \)\( (*Depth\ of\ first\ series\ \ stop\ rounded\ to\ increment*) \)\(\n\)\(\n\)\)\)\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Build Array of Deco stops and mixes", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[BoxData[ \(\(\(\(\(Clear[decoM, maxOD1, maxOD2, maxOD3, maxOD4, maxOD5, nStops, decoDepth, decoPressure, decoMix\ , decoPM]\)\(\n\)\(\n\) \) (*list\ of\ deco\ gases*) \n \(decoM\ = \ {\n\t{fO2DecoMix1, fN2DecoMix1}, \[IndentingNewLine]{fO2DecoMix2, fN2DecoMix2}, \[IndentingNewLine]{fO2DecoMix3, fN2DecoMix3}, \[IndentingNewLine]{fO2DecoMix4, fN2DecoMix4}, \[IndentingNewLine]{fO2DecoMix5, fN2DecoMix5}\n\t\t};\)\n\n\n (*determine\ maximum\ operating\ \ depths\ of\ 5\ deco\ mixes*) \n (*it' s\ possible\ to\ force\ a\ gas\ mix\ by\ entering\ a\ \(constant : \ \ maxODn\)\ = \ constant*) \n maxOD1\ = \ stopIncrement\ Floor[\ 33. \/stopIncrement\ \((maxPPO2Mix1\/fO2DecoMix1\ - \ 1. )\)]; \ (*Rounds\ MOD\ down\ in\ stopIncrement*) \n\t\t\n maxOD2\ = \ stopIncrement\ Floor[\ 33. \/stopIncrement\ \((maxPPO2Mix2\/fO2DecoMix2\ - \ 1. )\)];\ \n\n \(\(maxOD3\ = \ \ stopIncrement\ Floor[\ \(33. \/stopIncrement\) \ \((maxPPO2Mix3\/fO2DecoMix3\ - \ 1. )\)]\ ;\)\(\n\) \)\t\t\n \(\(maxOD4\ = \ \ stopIncrement\ Floor[\ \(33. \/stopIncrement\) \ \((maxPPO2Mix4\/fO2DecoMix4\ - \ 1. )\)]\ ;\)\(\n\) \)\n maxOD5\ = \ \ stopIncrement\ Floor[\ \(33. \/stopIncrement\) \ \((maxPPO2Mix5\/fO2DecoMix5\ - \ 1. )\)]\ ; (*Rounds\ MOD\ down*) \n\n\n (*By\ Analogy\ to\ \ diveLevels, \ Start\ Building\ Deco\ DTM\ array\ with\ calculation\ of\ Pressure/ Mix\ list*) \n nStops\ = \((\(\(\ \)\(dFirstS\)\)\/stopIncrement\ + \ 1)\); (*\(+1\)\ counts\ the\ surface\ desaturation\ as\ the\ last\ \ deco\ \(stop\ --\) Different\ from\ VPM . bas*) \n\t\n decoDepth\ = \ Table[\((dFirstS\ - \ stopIncrement\ i)\), {i, 0, \((nStops\ - 1)\), 1}];\n decoPressure\ = \ N[\((decoDepth\/33. \ + \ pSurface)\)]; \ (*Hydrostatic\ pressure\ at\ deco\ stop*) \n\n \ (*list\ of\ deco\ mixes\ determined\ by\ MODs*) \n decoMix\ = \ Join[\n\t\tTable[{fO2Mix, fN2Mix}, {i, \ dFirstS, \((maxOD1\ + \ stopIncrement)\), \(-stopIncrement\)}], \n\t\t\ Table[{fO2DecoMix1, fN2DecoMix1}, {i, Min[{dFirstS, maxOD1}], \((maxOD2\ + \ stopIncrement)\), \(-stopIncrement\)}], \n\t\t\ Table[{fO2DecoMix2, fN2DecoMix2}, {i, Min[{dFirstS, maxOD2}], \((maxOD3\ + \ stopIncrement)\), \(-stopIncrement\)}], \n\t\t\ Table[{fO2DecoMix3, fN2DecoMix3}, {i, Min[{dFirstS, maxOD3}], \((maxOD4\ + \ stopIncrement)\), \(-stopIncrement\)}], \n\t\t\ Table[{fO2DecoMix4, fN2DecoMix4}, {i, Min[{dFirstS, maxOD4}], \((maxOD5\ + \ stopIncrement)\), \(-stopIncrement\)}], \t\t\n\t\t\ Table[{fO2DecoMix5, fN2DecoMix5}, {i, Min[{dFirstS, maxOD5}], stopIncrement, \(-stopIncrement\)}], \t\n\t\t{{fO2SurfaceMix, fN2SurfaceMix}}\n\t];\ \n\n\n (*\(decoPM[\([deco\ stage]\)]\)\(\ \ \)\([\)\([\ 1\ = \ alveolar\ pressure; \ 2\ = \ mix[\([1\ = \ fO2; \ 2\ = \ fN2]\)]\ ]\)*) \n (*now\ we\ just\ need\ to\ solve\ for\ \ the\ time\ at\ each\ stop*) \n \(\(decoPM\ = \ Transpose[{\((decoPressure - \ pH2OCO2)\), decoMix\ }]\)\(\ \)\); \)\( (*asymptotic\ alveolar\ \ pressures*) \)\(\n\)\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Decompression Calculation", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(\(\(Clear[pTo, pN2o, pHeo]\)\(\n\)\(\n\)\( (*List\ of\ compartment\ ppTotals\ at\ end\ of\ \ sequence\ of\ dive\ stages\ and\ ascent\ up\ to\ 1 st\ stop*) \)\(\n\) \) (*these\ are\ the\ initial\ tensions\ for\ calculating\ deco*) \n \(pTo\ = \ \ pN2Ascent\ + \ pHeAscent;\)\n \(pN2o\ = \ pN2Ascent;\)\n \(pHeo\ = \ \ pHeAscent;\)\n\n (*compartments\ with\ ppTotal\ > \ pStop\ need\ to\ outgas\ at\ \(\(stop\)\(.\)\)\ *) \n (*\(the\ \ situation\ may\ be\ different\ for\ individual\ compartment' s\ ppHe\ and\ ppN2\)\()\)*) \n (*although\ deco\ times\ are\ set\ \ by\ ppTotal, \ must\ outgas\ He\ and\ N2\ separately*) \n\n \(\(Clear[decoTimes, trackPssNew, tempTrackPssNew, trackPN2o, tempTrackPN2o, trackPHeo\ , tempTrackPHeo]\)\(\n\) \)\n \(decoTimes\ = \ {};\)\n \(trackPssNew\ = \ {};\)\n \(tempTrackPssNew\ = \ {};\)\n \(trackPN2o\ = \ {};\)\n \(tempTrackPN2o\ = \ {};\)\n \(trackPHeo\ = \ {};\)\n \(\(tempTrackPHeo\ = \ {};\)\(\n\) \)\n \(Module[{i}, \n\(For[i\ = \ 1, i < \ nStops\ , \(i++\), \n\n\t Clear[stopTimes, tStop]; \n\tstopTimes\ = \ {}; \n\t Module[{x, n}, \n\t\(For[n\ = \ 1, n\ <= \ nCompartments\ , \(n++\), \n\t\n\tClear[x]; \n\t x\ = \ 0; \ \n\t While[\n\t\t\((pSSnew[\([n]\)]\ - stopIncrement/ 33. \ \ - \ \((1. \ - \ \ decoPM[\([i\ , 2, 1]\)])\)\ decoPM[\([i, 1]\)]\ + \ decoPM[\([i, 1]\)])\)\ <= \n\t\t\t\((\((\((pN2o[\([n]\)]\ \ - \ decoPM[\([i, 2, 2]\)]\ decoPM[\([i, 1]\)]\ )\)\ \ Exp[\(-kN2\)\ ts] /. \ {kN2 -> Log[2]\/halftN2[\([n]\)], ts -> x})\)\ \ + \ \n\t\t\((\((pHeo[\([n]\)]\ - \ \((1\ - \ decoPM[\([i, 2, 1]\)]\ - \ decoPM[\([i, 2, 2]\)])\)\ decoPM[\([i, 1]\)]\ )\)\ Exp[\(-kHe\)\ ts] /. {kHe \ -> Log[2]\/halftHe[\([n]\)], ts -> x})\))\), \n\t\t\t\t\(x++\)\n\t\t]; \n\n\t AppendTo[stopTimes, x]; \n\tClear[x];\n\t];\)\n\t]; \n\n\n\t tStop\ = \ Max[stopTimes]\ ; \n\t AppendTo[decoTimes, tStop\ ]; \n\t\n\t Clear[TemppN2o, k, pf, po, ti]; \n\t TemppN2o\ = \ {}; \n\t\[IndentingNewLine]Module[{m}, \ \[IndentingNewLine]\(For[m\ = \ 1, m <= \ nCompartments, \(m++\), \n\t\tAppendTo[ TemppN2o, \n\t\t\t\((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. \n\t\t\t\ {pf\ -> \ decoPM[\([\((i\ )\), 2, 2]\)]\ decoPM[\([\((i)\), 1]\)], \n\t\t\tpo\ -> \ pN2o[\([m]\)], \n\t\t\tk\ -> \ Log[2]/halftN2[\([m]\)], \n\t\t\tt -> \ decoTimes[\([i]\)], \n\t\t\tti\ -> \ 0. \[IndentingNewLine]}]; \n\t\t\tpN2o[\([m]\)]\ = \ \ TemppN2o[\([m]\)];\t\t\t\t\n\t]\ ;\)\ \n\t]; \n\n\t Clear[TemppHeo, k, pf, po, ti]; \n\t TemppHeo\ = \ {}; \n\t\[IndentingNewLine]Module[{m}, \ \[IndentingNewLine]\(For[m\ = \ 1, m <= \ nCompartments, \(m++\), \n\t AppendTo[ TemppHeo, \n\t\t\t\((pf\ - \ \((pf\ - \ po)\)\ Exp[\(-k\)\ \((t\ - \ ti)\)])\) /. \n\t\t\t\t\ {pf\ -> \((1\ \ - \ decoPM[\([\((i)\), 2, 2]\)]\ - \ decoPM[\([\((i)\), 2, 1]\)])\)\ decoPM[\([\((i)\), 1]\)], \n\t\t\t\tpo\ -> \ pHeo[\([m]\)], \n\t\t\t\tk\ -> \ Log[2]/halftHe[\([m]\)], \n\t\t\t\tt -> \ decoTimes[\([i]\)]\ , \n\t\t\t\tti\ -> \ 0. \[IndentingNewLine]}]; \n\t\t\tpHeo[\([m]\)]\ = \ \ TemppHeo[\([m]\)];\t\t\n\t]\ ;\)\ \n\t]; \n\t\t\n\t Clear[pSSnew]; \t\n\t\t\n\t pSSnew\ = \((pSSnewN2\ pN2o\ + \ pSSnewHe\ pHeo)\)/\((pHeo\ + \ pN2o)\); \ \n\t\t\t\t\n\t trackPssNew\ = \ AppendTo[tempTrackPssNew, pSSnew]; \n\t trackPN2o\ = \ AppendTo[tempTrackPN2o, pN2o]; \n\t trackPHeo\ = \ AppendTo[tempTrackPHeo, pHeo];\n\t\t\n];\)\ \n];\)\n\n\ (*a\ list\ of\ all\ the\ \ compartment\ pSSnew\ for\ each\ stage, \ reflecting\ change\ in\ tensions\ in\ each\ of\ the\ compartments*) \n TableForm[ trackPssNew]\ (*\ "\<;\>"\ line\ terminator\ removed\ for\ example*) \n\ \(\(Length[trackPssNew];\)\(\n\) \)\n \(\(stopTimes\)\(\t\)\); (*list\ of\ each\ compartment' s\ required\ stop\ times\ after\ last\ stop*) \n\(\(decoTimes\) \); \ \)\(\ \)\( (*final\ list\ of\ times\ at\ each\ stop*) \)\(\n\)\)\)], "Input", CellTags->"Decompression Calculation"], Cell[BoxData[ TagBox[GridBox[{ {"0.7879875555057052`", "0.7883595851642515`", "0.7888806022674302`", "0.7894430385990608`", "0.7902826719345288`", "0.7915195764850189`", "0.7939380233646687`", "0.7947341042049996`", "0.795848648748081`", "0.7961570563546586`", "0.795877985232149`", "0.795079409633303`", "0.7937618946662046`", "0.7919120331262948`", "0.7895770041792124`", "0.7868092379505932`"}, {"0.7887137829894829`", "0.7875061868816023`", "0.787544949761083`", "0.7880737184441903`", "0.7890512808166891`", "0.7904643349564544`", "0.7931755939956984`", "0.7940790626174354`", "0.7953981266975805`", "0.7958674340242766`", "0.795713424409175`", "0.795028509365064`", "0.7938144010859309`", "0.7920594854490064`", "0.7898090916738214`", "0.7871143295924168`"}, {"0.7893954057151391`", "0.7876723372545404`", "0.7870451443747374`", "0.7872000645783338`", "0.7880596854787442`", "0.7895090143455793`", "0.7924212922073584`", "0.793418266910783`", "0.7949273100540294`", "0.7955512445576612`", "0.7955183747141837`", "0.7949434710323747`", "0.7938290820147633`", "0.79216540262744`", "0.7899962402309638`", "0.7873717504963647`"}, {"0.7899910744788596`", "0.7883577869517863`", "0.7870986586975853`", "0.7865738404004282`", "0.7869917312898426`", "0.7882885164920196`", "0.7913328943016941`", "0.7924407175838271`", "0.7942023744731427`", "0.795044421739353`", "0.7951854350346461`", "0.794769015126593`", "0.7937980580999487`", "0.7922652489155968`", "0.7902124792231643`", "0.7876889548016884`"}, {"0.7903009530116503`", "0.78914110523773`", "0.787706226946626`", "0.7865401100403058`", "0.7862413936729471`", "0.787087641632081`", "0.7900184918127452`", "0.791213560378714`", "0.7932406874245024`", "0.7943423234294639`", "0.7946986948012132`", "0.7944812969006687`", "0.7936911269194515`", "0.7923232450568294`", "0.7904171821891912`", "0.7880213650430004`"}, {"0.7904024654004203`", "0.7896078696272798`", "0.7883605621275831`", "0.7869187390063642`", "0.7859647243160816`", "0.7861821679124564`", "0.7886926500023612`", "0.7899110582949266`", "0.7921476211833784`", "0.793506560792429`", "0.7940909006644492`", "0.7940894127304631`", "0.7934971184255787`", "0.7923101236224875`", "0.7905650797472179`", "0.7883098761566444`"}, {"0.7472878635945486`", "0.7572516112500232`", "0.7655807981592007`", "0.7713170005919671`", "0.7753869667947629`", "0.7787747571713716`", "0.7842431684262121`", "0.7861724672174605`", "0.7894648123454993`", "0.7914631044299488`", "0.7924560006110214`", "0.7927689777855911`", "0.7924224485909519`", "0.7914336135488036`", "0.7898493556539047`", "0.7877273108543408`"}, {"0.7451746087114923`", "0.7465854617282005`", "0.7510931568730544`", "0.7576343742013514`", "0.764441451245246`", "0.7704412244985086`", "0.7789219891581103`", "0.7816560067191483`", "0.7861957140373595`", "0.7889738316584972`", "0.7904710481422691`", "0.7911733257040189`", "0.7911304277990454`", "0.7903851292054772`", "0.7889970719522238`", "0.7870362484274508`"}, {"0.7451511374736026`", "0.7452319946111909`", "0.746163395489938`", "0.7492908455777015`", "0.7549824334676858`", "0.7617586163635273`", "0.7725653468473632`", "0.7761319305003553`", "0.7820999753725617`", "0.7858366991713409`", "0.7879716115655119`", "0.7891714434730237`", "0.7895174176048244`", "0.7890830130710306`", "0.7879438202224097`", "0.7861858863955835`"}, {"0.7451510692527421`", "0.7451522699621225`", "0.7452231231097619`", "0.7458958628286562`", "0.7484650671779026`", "0.7534864314655149`", "0.764688575462301`", "0.7689426705625204`", "0.776469818879604`", "0.7814419550138457`", "0.7844536193464707`", "0.7863567486672625`", "0.7872585009825684`", "0.7872689767060804`", "0.78648429147484`", "0.7850132071268704`"}, {"0.7451510692397493`", "0.7451510738609306`", "0.7451532569772517`", "0.7452256895752813`", "0.7458872898058543`", "0.7482659735975314`", "0.7570614494444097`", "0.7613355634131747`", "0.76984156533368`", "0.7760398396272592`", "0.7800590800806118`", "0.7828230710713898`", "0.784425521533541`", "0.7850031120009355`", "0.7846705373161565`", "0.7835633183369242`"}, {"0.7451510692397492`", "0.7451510693038592`", "0.7451512108180575`", "0.7451628128740838`", "0.7453596737612601`", "0.7464546776098868`", "0.7525873748775247`", "0.7563108550374561`", "0.7647643120288009`", "0.7716509702473405`", "0.7764259936671672`", "0.779906624344367`", "0.7821178744308063`", "0.7831931972209356`", "0.7832536157556236`", "0.7824558581840849`"}, {"0.7451510692397492`", "0.7451510692398401`", "0.7451510713671531`", "0.7451517578985464`", "0.7451810065201158`", "0.7454862314311151`", "0.7486124939290789`", "0.7511991726650468`", "0.7584761440342116`", "0.7656287598990194`", "0.7711789188175445`", "0.7755723166647562`", "0.7786377108652508`", "0.7804452570715474`", "0.7810971551992766`", "0.7807697293816607`"} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], Function[ BoxForm`e$, TableForm[ BoxForm`e$]]]], "Output", CellTags->"Decompression Calculation"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Construct Output", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[BoxData[ \(\(\(\(\(Clear[totalTdeco, runTimes, tDecoPTM, decoPTM, tDecoDTM, decoDTM, nDropStages, totalTascent]\)\(\n\) \)\n \(runTimes\ = \ {};\)\n \(\(Module[{n, i}, \[IndentingNewLine]\n Do[\n\tAppendTo[ runTimes, \((Last[ascentTimeList]\ + \ Sum[decoTimes[\([n]\)], {n, i}])\)], \[IndentingNewLine]{i, Length[decoTimes]}]\n];\)\(\n\) \)\n totalTDeco\ = \ Apply[Plus, decoTimes]; \ (*Sum\ of\ individual\ decoTimes*) \n totalAscentTime\ \ = \ totalTDeco\ + ascentTime;\n\n \(\(If[Length[runTimes] > 0, \n\t totalTascent = Append[runTimes, runTimes[\([nStops\ - 1]\)]\ + \ tsurface], totalTascent = Append[runTimes, \ Last[ascentTimeList] + \ tsurface]\n];\)\(\n\) \)\n \(\(tDecoPTM\ = \ {\(Transpose[decoPM]\)[\([1]\)], totalTascent, \(Transpose[decoPM]\)[\([2]\)]\ };\)\(\n\) \)\n decoPTM\ = \ Transpose[tDecoPTM]; (*array\ of\ deco\ pressure, \ time\ and\ mix*) \n tDecoDTM\ = \ {\((tDecoPTM[\([1]\)]\ - 1. \ + \ pH2OCO2)\)\ 33. , tDecoPTM[\([2]\)], tDecoPTM[\([3]\)]\ };\n\t\n decoDTM\ = \ Transpose[tDecoDTM]\ ; (*array\ of\ deco\ pressure, \ time\ and\ mix*) \n\n (*avoid\ deco\ runtimes\ redundancy . \ Also\ need\ to\ drop\ corresponding\ stage\ in\ trackPssNew\ and\ \ decoDepth\ arrays\ *) \ \n trackPssNew\ = \ If[\((N[Last[\(Transpose[ascentDTM]\)[\([2]\)]]] === N[First[\(Transpose[decoDTM]\)[\([2]\)]]])\), Drop[trackPssNew, 1], trackPssNew]\ ;\n\n \(\(decoDepth\ = \ If[\((N[Last[\(Transpose[ascentDTM]\)[\([2]\)]]] === N[First[\(Transpose[decoDTM]\)[\([2]\)]]])\), Drop[decoDepth, 1], decoDepth]\ ;\)\(\n\) \)\n \(\(dropDecoDTM\ = \ \n If[\((N[Last[\(Transpose[ascentDTM]\)[\([2]\)]]] === N[First[\(Transpose[decoDTM]\)[\([2]\)]]])\), Drop[decoDTM, 1], decoDTM]\ ;\)\(\n\) \)\n \(\(TotalDiveDTM\ = \ Join[dtm, ascentDTM, dropDecoDTM];\)\(\n\) \)\n \(\(dive1DTM\ = \ TotalDiveDTM\) \); (*this\ is\ for\ tracking\ purposes\ used\ for\ \ repetitive\ diving*) \n\n\(\(nDropStages\ = \ nStages\) \); \)\(\ \)\( (*drop\ the\ descent\ and\ the\ surface\ \ then\ pass\ #\ to\ Plot . nb*) \)\(\ \)\( (*check\ for\ multilevel\ dive*) \)\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Decompression Schedule", "Subsection", FontColor->GrayLevel[1], Background->RGBColor[0, 0, 1]], Cell[CellGroupData[{ Cell[BoxData[{ \(\(Print[IterationTag];\)\), "\n", \(\(Print[totalTDeco, "\< min Total Decompression\>"];\)\), "\n", \(\(Print[totalAscentTime, "\< min Total Ascent\>"];\)\), "\n", \(\(Print["\<_______Dive_______\>"];\)\), "\n", \(\(Print["\"];\)\), "\n", \(\(\(Print[TableForm[TotalDiveDTM]]\)\(\n\)\(\n\) \)\)}], "Input"], Cell[BoxData[ \("1st Iteration"\)], "Print"], Cell[BoxData[ InterpretationBox[\(200\[InvisibleSpace]" min Total Decompression"\), SequenceForm[ 200, " min Total Decompression"], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(202\[InvisibleSpace]" min Total Ascent"\), SequenceForm[ 202, " min Total Ascent"], Editable->False]], "Print"], Cell[BoxData[ \("_______Dive_______"\)], "Print"], Cell[BoxData[ \("depth, Run time, fO2/fN2"\)], "Print"], Cell[BoxData[ InterpretationBox[GridBox[{ {"0.`", "0.`", GridBox[{ {"0.21`"}, {"0.79`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"100.`", "1.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"200.`", "120.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"167.`", "121.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"134.`", "122.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"130.`", "124.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"120.00000000000001`", "130.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"110.00000000000001`", "136.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"100.`", "145.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"90.00000000000001`", "157.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"80.`", "171.`", GridBox[{ {"0.18`"}, {"0.37`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"70.`", "179.`", GridBox[{ {"0.5`"}, {"0.5`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"60.00000000000001`", "189.`", GridBox[{ {"0.5`"}, {"0.5`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"50.`", "202.`", GridBox[{ {"0.5`"}, {"0.5`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"39.99999999999999`", "221.`", GridBox[{ {"0.5`"}, {"0.5`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"30.`", "246.`", GridBox[{ {"0.5`"}, {"0.5`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"19.999999999999993`", "276.`", GridBox[{ {"1.`"}, {"0.`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"9.999999999999995`", "322.`", GridBox[{ {"1.`"}, {"0.`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {"0.`", "322.`", GridBox[{ {"0.21`"}, {"0.79`"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ {{0.0, 0.0, {.20999999999999999, .79000000000000004}}, {.1*^3, 1.0, {.17999999999999999, .37}}, {.2*^3, .12*^3, {.17999999999999999, \ 37}}, {167.0, 121.0, {.17999999999999999, .37}}, {134.0, 122.0, {.17999999999999999, .37}}, {.13*^3, 124.0, {.17999999999999999, .37}}, { 120.00000000000001, .13*^3, {.17999999999999999, .37}}, { 110.00000000000001, 136.0, {.17999999999999999, .37}}, {.1*^3, 145.0, {.17999999999999999, .37}}, {90.000000000000014, 157.0, {.17999999999999999, .37}}, {.8*^2, 171.0, {.17999999999999999, .37}}, {.7*^2, 179.0, {.5, .5}}, { 60.000000000000007, 189.0, {.5, .5}}, {.5*^2, 202.0, {.5, .5}}, { 39.999999999999993, 221.0, {.5, .5}}, {.3*^2, 246.0, {.5, .5}}, { 19.999999999999993, 276.0, {1.0, 0.0}}, {9.9999999999999947, 322.0, { 1.0, 0.0}}, {0.0, 322.0, {.20999999999999999, .79000000000000004}}}]]], "Print"] }, Open ]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1152}, {0, 811}}, AutoGeneratedPackage->Automatic, WindowSize->{986, 635}, WindowMargins->{{116, Automatic}, {Automatic, 22}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, ShowCellLabel->False ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{ "Arrays of Pressure Functions"->{ Cell[19261, 484, 3881, 79, 1370, "Input", CellTags->"Arrays of Pressure Functions"], Cell[23145, 565, 8586, 166, 313, "Output", CellTags->"Arrays of Pressure Functions"]}, "Decompression Calculation"->{ Cell[53234, 1205, 5244, 94, 2087, "Input", CellTags->"Decompression Calculation"], Cell[58481, 1301, 6350, 111, 217, "Output", CellTags->"Decompression Calculation"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Arrays of Pressure Functions", 75385, 1711}, {"Decompression Calculation", 75610, 1716} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 156, 3, 111, "Title"], Cell[1935, 58, 386, 11, 111, "Subtitle"], Cell[2324, 71, 3923, 93, 413, "Text"], Cell[CellGroupData[{ Cell[6272, 168, 119, 3, 54, "Subsection"], Cell[6394, 173, 1776, 31, 513, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[8207, 209, 113, 3, 46, "Subsection"], Cell[8323, 214, 794, 10, 147, "Text"], Cell[9120, 226, 611, 13, 146, "Input"], Cell[9734, 241, 433, 9, 86, "Input"], Cell[10170, 252, 617, 13, 126, "Input"], Cell[10790, 267, 423, 10, 86, "Input"], Cell[11216, 279, 423, 10, 86, "Input"], Cell[11642, 291, 401, 9, 86, "Input"], Cell[12046, 302, 542, 12, 86, "Input"], Cell[12591, 316, 345, 8, 46, "Input"], Cell[12939, 326, 1783, 35, 326, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[14759, 366, 137, 3, 46, "Subsection"], Cell[CellGroupData[{ Cell[14921, 373, 2852, 55, 764, "Input"], Cell[17776, 430, 53, 1, 25, "Print"], Cell[17832, 433, 57, 1, 25, "Print"], Cell[17892, 436, 1135, 34, 93, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[19076, 476, 160, 4, 46, "Subsection"], Cell[CellGroupData[{ Cell[19261, 484, 3881, 79, 1370, "Input", CellTags->"Arrays of Pressure Functions"], Cell[23145, 565, 8586, 166, 313, "Output", CellTags->"Arrays of Pressure Functions"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[31780, 737, 214, 6, 64, "Subsection"], Cell[CellGroupData[{ Cell[32019, 747, 215, 6, 62, "Subsubsection"], Cell[32237, 755, 374, 5, 52, "Text"], Cell[32614, 762, 3064, 56, 872, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[35715, 823, 202, 6, 62, "Subsubsection"], Cell[35920, 831, 696, 14, 90, "Text"], Cell[36619, 847, 1936, 35, 706, "Input", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[38592, 887, 193, 6, 56, "Subsubsection"], Cell[38788, 895, 139, 4, 33, "Text", Evaluatable->False], Cell[38930, 901, 4067, 83, 1521, "Input", Evaluatable->False] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[43046, 990, 112, 2, 46, "Subsection"], Cell[43161, 994, 6244, 121, 2130, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[49442, 1120, 117, 2, 46, "Subsection"], Cell[49562, 1124, 3503, 70, 1060, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[53102, 1199, 107, 2, 46, "Subsection"], Cell[CellGroupData[{ Cell[53234, 1205, 5244, 94, 2087, "Input", CellTags->"Decompression Calculation"], Cell[58481, 1301, 6350, 111, 217, "Output", CellTags->"Decompression Calculation"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[64880, 1418, 98, 2, 46, "Subsection"], Cell[64981, 1422, 2450, 52, 810, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[67468, 1479, 104, 2, 46, "Subsection"], Cell[CellGroupData[{ Cell[67597, 1485, 383, 7, 170, "Input"], Cell[67983, 1494, 48, 1, 25, "Print"], Cell[68034, 1497, 175, 3, 25, "Print"], Cell[68212, 1502, 161, 3, 25, "Print"], Cell[68376, 1507, 53, 1, 25, "Print"], Cell[68432, 1510, 59, 1, 25, "Print"], Cell[68494, 1513, 6119, 174, 537, "Print"] }, Open ]] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)