Return-Path: Date: Tue, 8 Jan 91 13:03:46 est From: Dan Schwartz To: JJB0391@MARS.LERC.NASA.GOV, pbhyg!pacbell!rwmackl@PacBell.COM, bomgard@iuvax.cs.indiana.edu, duis%bent.esd.sgi.com@SGI.COM, eckhouse@ATHENA.MIT.EDU, gps@apple.com, gt0248c@prism.gatech.edu, horst@tasman.cc.utas.edu.au, ncr-sd!mtunion.SanDiego.NCR.COM!davem@hp-sdd.sdd.hp.com, amdahl!kafka@hplabs, jagrogan@vax1.tcd.ie, jimsa@u.washington.edu, mjs@hubcap.clemson.edu, ohara@brahms.AMD.COM, oivindt@ulrik.uio.no, r31510k@kaira.hut.fi, rasmuse@mist.CS.ORST.EDU, stephenf@softway.sw.oz.au, whipple@brahms.udel.edu, zeke@cdc.com Subject: Re: divecomp for DOS now available The following shell archive contains an MSDOS EXE file which is a port of Dave Waller's divecomp program (version 2.5). It was compiled with Microsoft Quick C 2.0, and uses the PC Curses library. The program simulates the operation of a dive computer, and shows nitrogen loading in all of the compartments during the course of simulated dives. Anyone interested in the source code should consult rec.scuba, or the scubasearch archive, for Dave's original posting. Dan Schwartz dans@hpnjld.hp.com Hewlett-Packard, New Jersey Division ------------------------------------------------------------------------------------------- * Revision 2.5 90/12/12 15:30:02 15:30:02 dave (Dave Waller) Changes as of revision 2.5: New features (lots!): Now checks for "LINES" or "WIDTH" environment variable set, truncating the compartment bar graph appropriately (for those of you who simulate DEEP dives :-)) New option, -P, displays compartments as absolute pressure instead of tissue loading %age. The pressure is in sea water absolute, where is whatever units have been specified with the -u option. Default is feet. -P also causes the compartment values logged to an optional log file (specified with -l) to be in absolute pressure instead of loading %age. Graph can be toggled between loading display and absolute pressure display by pressing the 't' key WHILE THE PROGRAM IS CALCULATING, not while it is wating for input. For example, if you are running interactive and you enter a depth of 100 ft for 20 minutes, 't' can be used while the 20 minutes are elapsing to toggle the screen. 't' does not affect initial -P option. Changed the transition depth between bottom time and surface interval counting to 3 feet from 5 feet. This was necessary for decompression stuff (more later). 'q' can be pressed during calculations to abort the calculated run. For instance, when calculating a long decompression in autodecompression mode (more on this later), you can press 'q' to return to the input prompt. Similarly when calculating a long depth/duration combination entered from the keyboard. No Decompression Limits are now displayed and continuously updated along side the dive profile for each depth displayed. When NDLs are exceeded, the stats line now displays a ceiling, and a time to surface assuming proper following of the ceiling in 5 foot stops. For example, after 20 minutes at 200 feet, the stats line might display "Ceiling: 75.0 ft Time to surface: 46 min", indicating that the diver should not go shallower than 75 feet. If the diver makes decompression stops every 5 feet (stopping at each stop until the ceiling goes up to the next 5' stop), it will take 46 minutes to make it safely to the surface. Depths deeper than the deepest depth in the dive profile display now show a 'v' in the deepest depth rather than not being displayed at all. Bar graph now automatically reverts to a 2:1 scale in both loading and absolute display modes. For instance, if any compartment exceeds 100% loading, the graph will rescale to 0-200% (similarly for absolute pressure display). Autodecompression: When NDLs have been exceeded, the diver can autodecompress by entering 'd' at the depth prompt. This will cause the program to advance to the nearest 5' deeper than the indocated ceiling, and follow the ceiling up in 5' increments. This will produce a profile exactly equal to that used in calculating the 'time to surface' value. If available on your keyboard, the up and down arrow keys can now be used to change depth by one depth increment (as shown in the profile display) with each press during calculation. This is mainly useful while plotting a portion of a profile (i.e. 60' for 50 minutes), and you want to create a more realistic profile by moving up or down while calculating. * * Revision 2.4 90/11/27 15:30:03 15:30:03 dave (Dave Waller) * new features: * * - tissue loading graph now compresses when tissue loading exceeds * 100%, to a scale of 0-200%. Rescales to 0-100% when all compartments * are <= 100%. * * - Compartments can now be displayed as absolute pressure in (units) sea * water, instead of % loading. Default is loading graph, absolute * pressure can be selected at runtime with -P option. While the program * is running, user can toggle between the two modes by typing 't' (this * only works while calculations are taking place, not while waiting for * input). Scale along the top is calibrated in (units) sea water absolute. * * - During calculation, depth can be adjusted up or down using the up and * down arrow keys on the keyboard. For example, if the program is calculating * a dive level of 60 feet for 50 minutes, the depth can be adjusted up or * down by pressing the arrow keys. Adjustments are made in increments * equal to the depth increment in the dive profile display. * * - If compartments are overloaded, the program can "autodecompress" by * entering a depth of 'd' in interactive mode. The program will then * move up to the ceiling value and "ride" it until all the compartments * are <=100% loading. * * - When displaying compartment loading, pressure values are in (units) SWA * instead of FSWA. (Of course, if the units are feet, then the values * *are* FSWA). * * - Stats line during overloading now displays a more meaningful message * regarding ceiling and decompression time. * * Revision 2.1 90/11/21 11:33:57 11:33:57 dave (Dave Waller) * Changed SUN ifdefs to be macro SIMPLE instead... Makefile has been * modified as well. Since Sun users can now compile with full SVID * curses functionality, it seemed unnecessary to remove the reverse * video bells and whistles for for them. However, this functionality * is retained as a "simple" version of the program for those that do not * have reverse video and underline capabilities on their terminals. * * Revision 2.0 90/11/21 11:11:30 11:11:30 dave (Dave Waller) * Bug fixes: * * - incompatible typecasting in several places made the program fail * with certain model files. * * - Logical error in the sample period determination algorithm. * * Enhancements: * * - added capability to display depth in arbitrary units. Default is * feet. Units are specified in either a profile file on the first line * or with the -u option. To use a different unit system, the user must * supply the unit name and a unit conversion factor that represents * units/ft. For example, to display in fathoms, the user would type * * divecomp -mEdge -ufathoms:0.1667 * * There are 6 feet in a fathom, or 1/6=0.1667 fathoms per foot. For meters, * the specification would be -umeters:0.3048, or -um:0.3, etc. * * The unit specification is written into an output profile, so that the * correct units are used when using the profile. Units specified in a * profile file override command line specification. * * - added logging capability. A log file can be specified with the -l * option, and the program will write the allowed nitrogen %age for * each compartment at each sample period into the log file. A header * containing information regarding the model, sample period, and depth * unit used is initially written into the file before the simulation * begins. To make a log of a computer run, type * * divecomp -mBuhlman -umeters:0.3 -llog.buhlman * * * Revision 1.9 90/11/20 11:24:48 11:24:48 dave (Dave Waller) * Bug fixes: * - logical errors in reading sample period from specified sources * - update_dive_profile() routine hada rounding error in the * code that compresses the display. * * Enhancements: * * - new profile file format. Profiles are now stored as depth-duration * pairs, instead of discrete samples. This eliminates the need for * sample period specification in the profile file, and makes the * file more compact and easier to read. I have written a filter * 'cvtprof' to convert from the old format to the new format, so * any existing profiles that people have can be easily converted. * * Profiles created with the -o option in interactive mode are written * in the new format. * * Revision 1.8 90/11/16 16:33:45 16:33:45 dave (Dave Waller) * Cleaned up rounding algorithm for depth profile; added round up to * compartment bar graph display, so that it reads 100% properly; * Fixed scale graphic at top of compartment bar graph (it was off * by one character position to the right, contributing tothe bars not * being at 100% visually when they actually were). * * Revision 1.7 90/11/16 10:34:26 10:34:26 dave (Dave Waller) * Added ability to specify different sample periods. Sample period ('s' in * the source) is specified in the following manner (decreasing precedence): * * 1) via command line option * Example: divecomp -mEdge -omyprof -s2.5 * * Units are in minutes * * 2) From within a profile file. The first line can optionally * specifiy a sample rate, if it has the form "s:". * Example: A profile that contains 2 minute samples would * look like * * s:2.0 * 60 * 60 * 60 * 60 * . * . * . * * (the ellipses [...] are not part of the file). 'divecomp' * now automatically writes the sample period into every profile * it generates via the -o option. * * 3) From a model file. Format is the same as a profile file. * The most basic command, "divecomp -mEdge", for instance, * will cause the computer to use the proper sampling rate * for the Edge. Also, any profiles generates with this model * will have the correct sampling value when used in different * models. * * 4) Default: 1 minute. * * Revision 1.6 90/11/14 17:36:52 17:36:52 dave (Dave Waller) * Added compile time checks to modify curses behavior to accomodate * incomplete curses library on Sun/OS. Controlling tissue is highlighted * with a preceding '*' instead of reverse video, deiling message does not * appear in reverse video when tissue M values are exceeded, and tissue * bar graph is composed of '#' characters instead of reverse video * spaces. Not quite as pretty as the full curses version, but that's what * you get if you're running on a Sun. * * Original graphical functionality is maintained for other platforms. * * Revision 1.5 90/11/14 13:58:43 13:58:43 dave (Dave Waller) * Added the following features: * * - Decompression calculation and indication via ndl() * - ingas/outgas indicator nxt to each compartment number * - full "bottom timer" functions (i.e. dive #, bottom time, surface int) * * Fixed the following bugs: * * - would run forever if duration of 0 entered in interactive mode. * Program now rejects such an entry, and asks for depth and duration * again. * * - Controlling tissue indication lagged one sample behind actual value; * Fixed. * * - Dive profile graph now rounds up to the nearest depth increment. * * Revision 1.4 90/11/13 16:38:49 16:38:49 dave (Dave Waller) * Fixed up the comments. * * Revision 1.3 90/11/13 15:11:48 15:11:48 dave (Dave Waller) * Initial checkin; started using RCS to keep track of revisions. This * revision also fixes a bug with the code that reads in half times from model * files -- they were stored as type 'int', which created problems for * fscanf if the half times were floats. Changed the array 'half[]' to * type 'float'. * */ /* dive computer simulator, by Dave Waller (davew@hpdstma.hp.com) =============================================================Acknowlegments: Much thanks to Eric Williams (sargon@portia.stanford.edu) for his outstanding contribution to the ndl() routine to incorporate ceilings and decompression times. His support and timely reviews/bug reports have been extremely helpful. Thanks, Eric! ============================================================ This program simulates a multi-compartment model dive computer, based upon modified Haldanean tissue absoption models. The number of compartments and their corresponding constants are not built into the program, but must be loaded at runtime, allowing the program to simulate most dive computers on the market today. Subsequent derivation of equations as found in the comments below were done by myself, as I sit here at work, using only my memory; therefore, this initial pass at the simulation may contain some errors that I will have to fix later, after I have had time to review the pertinent material at home. Surprisingly enough, it seems to work pretty accurately, based upon my experience with my ORCA Delpi. Have fun! Tissue halftimes in general express the time it takes for a tissue to either absorb or release nitrogen such that the tissue is 50% equalized to the pressure differential between the ambient nitrogen pressure and the tissue nitrogen pressure. This uptake or outgassing obeys an asymptotic exponential, namely if ambient pressure is PA, and initial tissue pressure is PT0, then the tissue pressure as a function of time is expressed as, PT = PT0 + (PA - PT0)(1 - e^(-kt)) where k = -ln(0.5)/T = 0.6931/T half half This formula holds true for static conditions; i.e. PA does not change. In reality, a diver will probably be continuously changing depth, and therefore PA is changing also. A reasonable approximation of continous PT values can be calculated by sampling PA at discrete intervals, and applying the above formula over the preceding sample interval, then starting over with a new PA and PT0 for the next interval based upon the calculation. In this simulated computer, we assume datapoints are recorded one per minute. Since the halftimes are expressed in minutes, the above formula can be reduce to an adjustment at each sample that consists of the following: PTnew = PTlast + K(PA - PTlast) where K = (1 - e^(-k*1)) = 1-e^(-k) = 1 - (1/e^k) = 1 - (0.5)^(1/T ) half Note that the K value is dependant upon consistency between the units of the compartment half time and the computer sample period. Specifically, the above formula only applies if the sample period is 1 unit of the half time unit (in this case minutes). For an arbitrary sample period s, the formula for the K value is K = 1 - (0.5)^(s/T ) half The dive computer simulator calculates the K values on startup, with the sample period 's' being taken from the following sources, in order of decreasing priority: 1) a sample period specified on the command line with the -s option 2) A sample period specified in a profile file. This must take precedence over a sample period in a model file, otherwise the number of samples in the file will not match the dive profile in real time. In order to compare different models, the same sampling period must be used for a single profile. 3) A sample period specified in the model file 4) The default sample period of 1 second */ ---------------------------------------------------------------------------------------------------- From: davew@hp-ptp.HP.COM (Dave_Waller) Newsgroups: rec.scuba Subject: Dive computer program is here! Date: 10 Nov 90 01:41:02 GMT Organization: HP Pacific Technology Park - Sunnyvale, Ca. Okay, folks, you asked for it. Here is my first pass at a divecomputer program that I hacked together during lunch. As far as I can tell, it seems to be working pretty accurately, based upon my experience with the Delphi (although this version uses half-times and M-values as posted for the Edge by Eric Williams). The first response to this posting is a shell archive that contains 3 files: "divecomp.c", "makefile", and "data". To build your dive computer, unwrap the shar file as specified in its instructions, and type "make divecomp". This should wourk on just about any UNIX system, as the program is really rather simple. The file "data" contains made-up data for a simgle multi-level dive. All it is a set of depth values, one minute apart. The program assumes that depth is sampled every minute. The program uses the 'curses' library, so you must have a terminal cabable of supporting cursor addressing and reverse video. Current features at this early quick-hack release are: * A continuously updated bar graph of all 12 tissue saturations (relative to M values), with the actual N2 tissue partial pressure displayed in FSW at the end of each bar. If a tissue exceeds 100% of the allowable nitrogen, the bar changes to asterisks. * Continuous display of depth. * Continuous display of bottom time, and surface interval (after the dive). * A continuously updated graph of the dive profile. To see all of this, you need a display with about 50 lines; X-window terminal emulators work pretty well. If you have only a 24 line terminal, you'll have to comment out the dive profile display so it doesn't (potentially) mess up the tissue graph. Please post any questions/problems as followups to this note. I'll try to get to them as quickly as I can, and it would be helpful for anyone else having problems. Have fun! Tomorrow: A list of planned enhancements! Dave Waller \ The opinions expressed are solely my own, and in no way Hewlett-Packard Co. \ represent those of my employer (but we all know dave@hpdstma.ptp.hp.com | hplabs!hpdstma!dave \ they should!) From: davew@hp-ptp.HP.COM (Dave_Waller) Newsgroups: rec.scuba Subject: Latest version of divecomputer program Date: 13 Nov 90 18:06:49 GMT Organization: HP Pacific Technology Park - Sunnyvale, Ca. Here is the latest version, which is MUCH improved over the version you were running. As we all bug fixes, it incorporates many new features: -mmodel specifies the file "model" as the file containing half-time Mvalue pairs. Must be specified. -pprofile Specifies a file containing a dive profile, in one minute samples. If not specified, the program is in interactive mode, allowing the user to specify depths and durations. -ooutfile Optional output filename to record interactively entered dive profile. Useful for saving profiles to be used for comparison between different computers using different model files. Computer now computes and displays NDL, and highlights the controlling tissue. Adapts to different screen sizes automagically now. Looks for environment variable "LINES", and if not found, assumes 24. So, I have included the new version with this message, along with the Edge and Navy model files, and a sample profile. Check it out and let me know what you think. Dave Waller \ The opinions expressed are solely my own, and in no way Hewlett-Packard Co. \ represent those of my employer (but we all know dave@hpdstma.ptp.hp.com | hplabs!hpdstma!dave \ they should!) -------------------------------------------------------------------- From: sargon@portia.Stanford.EDU (Eric Williams) Newsgroups: rec.scuba Subject: Discussion of Decompression Models (long) Keywords: decompression, models, history, M values, dive computer Date: 15 Nov 90 02:02:38 GMT Organization: AIR, Stanford University Those of you who asked for this stuff, sorry I left you hanging. It just took me a while. This is a discussion about decompression models. It starts with history, then gets into math, and finally specifics about things like diving at altitude. (It's a *really* long message. You may want to save it and read it in pieces.) I. A Little History of Decompression Models. Our knowledge of DCS (decompression sickness) goes back over three hundred years to 1670 when Robert Boyle described his observations of animals in lowered pressure environments. In the 1800's that knowledge expanded with the frequent use of caissons and other pressurized work environments. The first human cases of DCS were reported in 1841 in coal miners working in mines pressurized to keep out water. In 1857, Hoppe-Seyler suggested that DCS was caused by bubbles in the tissues and suggested treatment by recompression. In 1878, Bert discovered that it is nitrogen that is responsible for DCS. The British Navy commissioned J. S. Haldane to investigate the causes of DCS and to propose a solution. In the early 1900's by working on goats, he made several observations which still influence our thinking on DCS today. His procedure was to bring the goats to a higher than atmospheric pressure and leave them there for "a while"--I think it was about 4 hours [EW]. Then he would lower the pressure and look for DCS. (Animal rights activists, where were you then? :-) He reported that saturated tissues could be decompressed to one half their pressure without the onset of DCS, e.g. from 2 atm to 1 atm. Bringing a tissue back from more than 2 atm could be done in stages, allowing time for the tissue to resaturate to the new pressure at each stage, e.g. from 4 atm to 2 atm then waiting, and then from 2 atm to 1 atm. Haldane developed a model of compression and decompression which is still used today as the basis of many decompression models. The Haldanean model can by summariezed by the following prinicples: + Absorbtion and elimination of nitrogen by the body is at an expontential rate. That is, the rate at which a tissue takes in or releases gases is proportional to the pressure difference between the tissue and the surroundings (see math section) + There is a continuous spectrum of tissue types in the body with various rates of absorbtion and elimination. + The rate of absorbtion is the same as the rate of elimination for any given tissue group. + The continuous spectrum of tissue types in the body can be approximated by a finite number of groups from within the range. In 1908, the Royal Navy adopted the tables that Haldane developed using his model. In 1915 the US Navy published its first set of tables (the C & R tables). In the 1930's Hwkins, Shilling and Hansen (and later Yarborough) determined that the allowable supersaturation is not a constant two as Haldane had said, but depends on the tissue half time and the depths and duration of the dive. In 1937, Yarborough made tables for the US Navy based on a model that had three tissue compartments with half times of 20 minutes, 40 minutes and 75 minutes respectively. In 1957, the US Navy tables were corrected and improved and the repetitive dive tables were added. The tables were based on six compartments with half times of 5, 10, 20, 40, 80, and 120 minutes. The concept of "M-values" originiated with these tables. "M-values" specify the maximum supersaturation a compartment can withstand without getting bent. The M values were modelled as a constant plus an increment proportion to depth (M = M0 + dM*D). In 1976, the Pennsylvania Analysis of Decompression from Undersea and Aerospace (PADUA) model was introduced. It consisted of 10 compartments, with half times all the way up 480 minutes. More conservative M0 and delta-M values were used. Although the model is more conservative than the US Navy model, no tables have been produced for publication. Also in 1976, Spencer made his famous Doppler Ultrasound measurements looking for venous gas emboli (VGE -- fancy name for bubbles in the blood). If bubbles were the cause of DCS then why not look for bubbles directly. He found that at the Navy's no decompression limits there were already significant numbers of VGE present in the blood. He suggested reduced limits which virtually eliminated the presence of VGE upon surfacing. In 1981, Huggins published new repetitive dive tables based on a model similar to the US Navy's, but with M0 values based on the new no decompression times from Spencer. Furthermore, the tables considered all 6 compartments in assigning repetitive groups, not just the 120 minute group as the US Navy did. The tables had no provision for decompression. In 1983, Buhlmann developed another model for decompression (also called the Swiss model). It is still based on Haldane's assumptions and on tissue compartments, but uses a different specification of maximum compartment pressure that takes into account the ambient pressure at the surface. (Other tables assume 1 atm.) They are unique in that from the outset they were developed to be used at altitude in Swiss lakes. This also makes the tables useful for determining the safety of flying after diving, due to reduced pressure in the airplane cabin. In 1984, Thalmann at the Navy Experimental Diving Unit (NEDU) reported on an algorithm that the Navy had been developing for use in a closed- circuit mixed gas system. The algorithm is called E-L (as opposed to E-E in the usual) because the compartment in-gassing occurs at an exponential rate just as in the Haldanean models, but the outgassing occurs at a slower, linear rate. In 1985, two new models were proposed, both based on novel new approaches. At the University of Hawaii, the Varying Permeability Model was proposed. It attempts to model the number and size of gas bubbles in the blood, and bases the ascent criteria on the total volume of bubbles in the body. At the Naval Medical Research Institute (NMRI) a statistical approach to DCS was developed, called the Maximum Likelihood Statistical Method. Using a database of over 1700 individual exposures, model parameters were determined, and then several tables were developed associating sets of no-decompression times with various likelihoods of DCS (e.g. 1% or 5%, etc.) [I'm sure there is more out there, and probably more recent findings but this is what my research a year ago turned up. --EW] PROBLEMS The problem with all of these is that they are only models. Factors such as temperature, individual characteristics, exertion level, ascent rate and more complicated effects of bottom time are all known to influence susceptibility to DCS, but none are included in the models. Attempts to model bubble formation rather than just tissue saturation are IMHO a step in the right direction. But as someone pointed out a while ago on the net, there isn't even a great correlation between observed bubbles and DCS! A classic example where the models break down is bounce diving. A recipe for DCS: Something like 50% (vague recollection giving ballpark magnitude) of divers following this profile get bent: Doing everything by the book (e.g. proper ascent rate) dive to a relatively deep depth ( > 60 ft) for a short time then return to the surface. Repeat a few times with a short surface interval in between dives. For the Haldanean models there is no fundamental difference between this and regular dive profiles. Tissues in-gas then out-gas, and if the times are right you won't go over their limits. But the incidence of DCS says bounce diving defintely does something funny to your body. One theory I've heard is that on a first dive (even relatively benign ones) microscopic bubbles are formed. Since it's easier for bubbles to grow than to form in the first place, on subsequent dives they can get much worse. The bounce diving just multiplies this. I believe the rational behind the safety stop is to try to get rid of most of these bubbles (they go away better under pressure), or maybe to prevent their formation in the first place. I'm not really sure. The point is the Haldanean models don't really take any of this into account. The moral is: Safety stops (especially) and longer surface intervals (somewhat) are good things! :-) Never trust your dive computer completely. It's only a model and the models have limitations. NOTE that because of these problems with the model and the general feeling that the model is _only_ a model, people tend to use the term 'compartment' rather than 'tissue' when talking about Haldanean models in order to highlight that the mathematical model may have no physical connection to actual tissues in the body. I sometimes accidentally use the two interchangably (as does the literature) but the tendency is towards using 'compartment'. So if I should slip and say tissue where I mean compartment, you'll know what i mean. SOME NOTES ABOUT THE EXPONENTIAL MODEL The number that characterizes how quickly a compartment takes in or releases pressure is called the HALF-TIME. It is analogous to a half- life in radiation. It is defined as the time it takes for the pressure to drop (or rise) from its initial value HALFWAY to ambient pressure. In theory it would take an infinite amount of time to actually get to ambient pressure (because as you get closer it slows down). But in practice a few half-times is all that's needed (after 3.5 half times you're at 90% and after six half times you're at 98.4%). Six half- times is generally considered to be saturation. ASIDE: The 12 hour time after diving before you're considered to be "clean" comes from this. The US Navy tables had a 120 minute slowest compartment, so after 6*2 hours all of your compartments would be back to normal surface pressure. Current thinking is that this isn't long enough when you do extensive diving over a long period or before going to altitude (e.g. flying). Thus they incorporate slower compartments to give the model more "memory." II. The Math Go back and look at the basis of the Haldanean model. That's where this picks up. (Dave Waller (dave@hpdstma.ptp.hp.com) gives much of this in the openning comments of the dive computer program.) The change in a compartment's pressure is proportional to the difference between the compartment's current pressure and ambient pressure. Translation: dP = k * (PA - P) * dt where P is compartment pressure and PA is ambient pressure Solving this and using the initial condition P = PT0 at t=0 gives the following (math in between deleted :-) P = PT0 + (PA - PT0)*(1 - e^(-kt)) If you want to do an iterative computation to keep track of the compartment pressures, the computation is what you would expect: P_new = P_old + (PA - P_old)*(1 - e^(-kt)) Where do we get k? Well, we have another condition. We know that at t=HALF-TIME, (1 - e^(-kt)) = 0.5 by definition. Thus: k = ln(2) / HALF-TIME M-VALUES So we know how to model the compartments now. How do we know when they are at their limits, etc? The models specify M-values which are the maximum compartment pressures for which it is still safe to return to the surface (assuming 1 atm at the surface). More concisely M-values are the maximum absolute PARTIAL PRESSURE of nitrogen measured in feet of seawater (FSW). (Absolute, meaning that 0 is a total vacuum.) In numbers, at sea level (1 atm =~= 33 fsw) the partial pressure of nitrogen is 0.79 * 33 = 26 fsw. The US Navy table uses an M-value of 104 fsw for the 5 minute compartment. Thus for returning to the surface a 4:1 supersaturation is permissible without [symptoms of] DCS. [ASIDE: IMHO, It's not exactly clear when to say DCS actually begins. Damage caused by small bubbles could be so minor as to be asymptomatic] Note that since M-values are given the the nitrogen partial pressure you would want to do the calculations of compartment pressures with just the nitrogen. i.e. PA is ambient nitrogen partial pressure. The program calls this apn2. At depth (D >= 0) apn2 = (D + P0) * 0.79 where D is depth P0 is surface ambient pressure (usually 33 fsw) NO DECOMPRESSION TIME REMAINING So you want to compute how much time you have left at a given depth before you're compartments saturate. Just solve the P equation for t given the pressures. Let T = time to reach saturation M = the M-value C = current compartment pressure A = ambient pressure (at depth) Then M = C + (A - C)*(1-e^(-kT)) Solving for T: T = (1/k) * ln((A - C) / (A - M)) or in terms of half-time, H: T = H * log-base-2 ((A - C) / (A - M)) Note that using the properties of logarithms you can manipulate the equation around a bit, but the form is the same. Also note that the solution of this equation is dependent on there being a solution! The three variables A, C and M have six possible relations (e.g. A > C > M, etc) Only two of these have meaningful solutions, but all of them give you some information about the compartment. They are: A > M > C The compartment is still below its limit (what I might call normal, as opposed to being in a decompression mode, M > C) but is eventually going to exceed its limit because A > M and A > C. The equation _does_ have a meaningful solution for T, it's the no decompresion time remaining. M > A > C The compartment is 'normal' (M > C) and furthermore it is what I might call 'safe' i.e. (M > A) so not only is it not over the limit, it will never go over the limit at this ambient pressure. (A > C) so the compartment is in-gassing (increasing in pressure). Since it is 'safe' the T equation has no solution. You can say T = +INFINITY for this compartment. M > C > A The compartment is 'normal' (M > C). It is 'safe' (M > A) it is outgassing (decreasing in pressure) (C > A). Again, T = +INFINITY. A > C > M The compartment is over is limit (C > M), so it's no longer safe to return to the surface. Your dive computer would be in 'decompression mode' now, if it had one. Furthermore it is still in-gassing (A > C). At this ambient pressure the compartment will never get back below its limit (A > M). In a decompression mode, the no decompression limit no longer has meaning, but might like to know how long it take before we're out of decompression. I'll call this TDC. For this condition, TDC = +INFINITY C > A > M The compartment is in a decompression mode (C > M). It is out-gassing (C > A) but it will still never get back below the limit because (A > M). TDC = +INFINITY C > M > A The compartment is in a decompression mode (C > M). It is out-gassing (C > A) and will eventually get back to a safe state. The equation for T also solves for this condition. Look at the LOG(stuff) to convince yourself that it will return a positive, finite solution that _is_ what we are looking for. Thus, TDC = equation gives to time left to decompress. Interesting relations to note are: (C > M) over/under M-value limit (C > A) out/in gassing (M > A) 'safe' vs 'unsafe'** ** This term I coined myself for lack of a better mneumonic. I call it safe because in 'normal' mode a 'safe' compartment will never go over its M-value. In decompression mode, when the compartment is already over its M-value, only a 'safe' one will eventually get back back below the limit. THE REAL COMPUTATION The above discussion only covers a single compartment. The overall state of the model is a composite of the state of the individual compartments. - If any compartment is in decompression, then it will dominate over compartments that are not (i.e. are 'normal'). - Among 'normal' compartments the one with the lowest NDL is the controlling compartment. - Among 'decompressing' compartments the one with the highest TDC is the controlling compartment. Note that it can be very tough to give an absolutely correct answer for TDC, because you can have a mixture of compartments some over- saturated (in decompression) and some under the limit but still in-gassing. At a particular depth, you might be counting down the minutes for one compartment to get back below the limit and mean while another one goes over. Granted it's slightly pathalogical, but definitely _can_ happen. CEILING Given that you have decided you are in a decompression mode and can't go up to the surface, what depth _is_ safe? The smallest depth (shallowest) you can ascend to when in a decompression mode is called your ceiling. To compute this we need to know how M changes with depth. We may be over the M-value for the surface, but at some depth we'll be o.k. The original Haldanean principles just specified a ratio that is safe. e.g. 3:1 (compartment to ambient) is the limit. You could use this to figure out what your ceiling. For some reason (maybe this way works better, less DCS, maybe someone was just lazy, I dunno) this isn't the way most model do it. Dating back to 1957 and the US Navy tables, the following method is used: M_at_depth = M_at_surface + delta-M * depth or M = M0 + dM * depth (the 'd' of dM is actually supposed to be the capital greek letter 'delta', but the net doesn't seem to support greek! :-) Each compartment has an M0 and dM value. Frankly, I'm not sure exactly how the dM's were derived for the Navy Model. The ORCA Edge model just sets them all [somewhat arbitrarily --EW] to 1.0 (which is less than the Navy values and therefore more conservative). For a particular compartment, the ceiling is simply: ceiling = (C - M0) / dM where C = compartment pressure M0 = what I used to call M, max pressure allowed at surface dM = the incremental change in M with depth To compute the composite ceiling for the whole model, just take the worst case (deepest ceiling). STAGED-DECOMPRESSION In order to decompress you must be at an ambient pressure that's lower than the compartment value (so that you out-gas) and yet deeper than your ceiling. This can lead to staged decompression for some situations. Note that the slow compartments also have lower M-values. If you've gone way over on your faster tissues and slightly over on your slow tissues, you would have to do a staged-decompression. The ceiling would be determined by the fact that you were way over on the faster tissues. But at the depth specified by the ceiling, the slower tissues may not be outgassing, since ambient pressure could be greater than the compartment pressure. As you waited below your ceiling, the fast compartment would outgas and the ceiling would slowly move up. You could then move up to a shallower depth. You would repeat this until you were at a depth sufficiently shallow for the slower tissues to outgas. This should give you an idea of why it's hard to compute the actual TDC (time to decompress). In addition, while you were stuck at the deeper ceiling, other slow tissues with low M-values could be in-gassing and could go over the limit. In order to give the right number from the start you would have to consider all these possibilities. III. Other neat stuff, like adjusting for altitude When you dive at altitude the surface ambient pressure is lower than normal (something like 2/3 atm at 10,000 ft is what I remember hearing). In order for the tissues to see the same oversaturation *ratio* which is what we believe to be the controlling factor, you must reduce the M values. For example, the Navy 5 minute compartment M0 of 104 fsw gives a 4:1 supersaturation ratio (104 / (33*0.79)). If we went to 10,000 ft (assuming my 2/3 atm number is right) the same 104 fsw would give a ratio of 6:1. Some compensation must be done. ASIDE: This is also relevant to flying after diving. Since the compartment of commercial jet-liners is typically kept at 8,000 ft what your dive computer says is o.k. to do at sea level could cause problems if you immediately hopped on a plane for home. In fact this make air-evacuation after a diving accident a little tricky (and expensive !!!). The question is how to do the compensation. I don't have a solid answer for this, but we can still think about it. The obvious way to handle it is to scale the M-values to preserve the same supersaturation ratios that you had on the surface. e.g. in the previous case 104 fsw would scale to 69.3 fsw (104 * 2/3). IMHO this is a very reasonable way to do it. The only model that I have info on that was designed to handle altitude is the Buhlmann model. This model specified the maximum pressures a little differently than the M-value model started by the US Navy. In this model: Pmax = a + Pamb/b instead of: M = M0 + dM * depth where 'a' and 'b' are the constants for the compartment. Pamb is the absolute pressure at depth (e.g. 0 is a vacuum). Thus it includes both depth and surface pressure together. Pmax is the same as M -- the maximum pressure that a compartment can have without problem. The two models are equivalent with a little manipulation: Pamb = P0 + P_depth if you use fsw as your unit of pressure, then P_depth is just the depth. Thus: Pmax = (a + P0/b) + (P_depth) * (1/b) If you convert the units of 'a' to fsw (b is unitless) then: M0 = a' + P0/b dM = 1/b where P0 is ambient pressure at the surface. The Buhlmann model was designed for and has been tested at altitude in Swiss lakes. Therefore, we should also consider this approach to altitude compensation. In the first model (straight ratios) if the pressure dropped by 1/3 then 1/3 of the M0 was subtracted. In the Buhlmann model only a fraction of the pressure drop is subtracted, with the actual fraction depending on the a's, b's and surface pressure. In practice, the fraction varies from 35% for the fastest compartments to 80% for the slowest (with most compartments above 60%). Thus we might subtract only 35% of the 1/3 of the normal M0. Unfortunately I don't know how they decided on the a's and b's which determine this. Since I don't have good information on how these numbers came about it's hard to adapt this to other models. Does anyone out there know how dive computer X compensates for altitude? Some I know of use the Buhlmann model. The Delphi is one I'm curious about because I'd bet Orca used their same Edge model but scaled the values somehow. [Is anyone out there still reading at this monster of a posting!! :-)] REFERENCES The pointer to the original Buhlmann paper is in the Proceedings of the AAUS Dive Computer Workshop, 1989. A coulple of people asked me for more info on how to get the publications I cited. (The American Academy of Underwater Sciences and Michigan Sea Grant Publications). I gave out the addresses on an individual basis, but I figured I should wait until I had contacted them to find out their policy/ price/scoop before posting to the net-at-large. If you want the addresses, mail me and I'll send them out as long as the volume isn't overwhelming. If you can wait a bit, I just dashed off a couple of letters to them explaining what I want and will post to the net when I get a response. --Eric Williams. sargon@portia.stanford.edu P.S. If you haven't already done so, try out the dive computer program it's really neat! (and helps you get a feel for how all this works) -------------------------------------------------------------------- From: sargon@portia.Stanford.EDU (Eric Williams) Newsgroups: rec.scuba Subject: Re: Feature Request: Let's design our own dive computer Summary: decompression, m-values, dive computer Date: 8 Nov 90 21:42:43 GMT Organization: AIR, Stanford University (This is a little late, I tried posting yesterday, but had problems) About a year ago I did a comparison report of different dive computer models for my Open Water I course. A dive computer was (and still is) on my project list, so I've been following this discussion with interest. I've got values for four different models, including the Navy. They've been transcribed about three different times (source to notes to report to here) so if you have any of these, please compare, I could have garbled them. First, the numbers, then some references on decompression models. Some discussion about M values and delta M's should probably accompany this, but I'll assume we're all on the same wavelength and save it for another posting. (The M values are most important, the delta M's are only used in decompression algorithms.) ============ US NAVY T 1/2 M0 dM (min) (fsw) (--) ------ ----- ----- 5 104 2.27 10 88 2.00 20 72 1.71 40 58 1.40 80 52 1.29 120 51 1.27 << Sanity check: Do we all still agree? Everybody should have the same numbers here. >> <<< Now that this is late, I've checked this against duis@sgi and they agree. I don't think there are other compartments in the Navy model. (Like 180, 240, etc.) >>> ============= Huggins Model. These numbers were derived and used by Karl Huggins to generate the no-bubbles tables. T 1/2 M0 dM (min) (fsw) (--) ----- ----- ----- 5 102.0 0 10 85.0 0 20 67.5 0 40 54.5 0 80 47.5 0 120 43.0 0 << There are no dM values for this model because it is not intended to be used as for decompression. >> ================= ORCA Edge (and Skinny Dipper, I think) Also by Huggins These were published in 1987. There are no guarantees that these are the numbers actually used, or that they haven't been tweaked slightly. T 1/2 M0 dM (min) (fsw) (--) ----- ----- ----- 5 100.0 1.0 11 81.8 1.0 17 71.5 1.0 24 63.7 1.0 37 55.9 1.0 61 50.7 1.0 87 46.8 1.0 125 43.0 1.0 197 39.1 1.0 271 36.5 1.0 392 33.9 1.0 480 33.0 1.0 << These are from the Sea Grant publication by Huggins, see references >> ========================= Buhlman (Swiss) Model. Some explanation is in order here. The Buhlman model was developed in Switzerland and (I think) been tested at alititude in Swiss lakes. It is based on a different calculation of maximum compartment pressure than the M value one (Pmax = a + Pamb/b, Pamb is absolute ambient pressure (in Pascals!) where a and b are the numbers specified for each compartment.) It was my observation, (I've never seen this in print) that it was equivalent to the M value calculation (M = M0 + dM*D) with a little manipulation and units conversion: M0 = a + P0/b, dM = 1/b, 'a' must be converted to fsw, b is unitless, P0 is air pressure at the surface. The following are my calculations of what M values would be for this model. Unfortunately, I've don't seem to have the original a's and b's around, but they're in the references. T 1/2 M0 dM (min) (fsw) (--) ----- ----- ----- 2.65 114 1.22 7.94 91 1.22 12.2 77 1.21 18.5 70 1.20 26.5 65 1.18 37 58 1.16 53 54 1.15 79 53 1.12 114 53 1.12 146 51 1.07 185 51 1.07 238 48 1.06 304 43 1.04 397 43 1.04 503 43 1.04 635 43 1.04 << Again, note that these are unchecked and unpublished. >> ================================== REFERENCES Edmunds, Carl, "Dive Computers -- The Australian Experience" Proceedings of the AAUS Dive Computer Workshop, AAUS Costa Mesa, CA, USCSG-TR-01-89, 1989, pp. 59-68. Egstrom, Glen H., "Dive Computers, Dive Tables and Decompression" same as above, pp. 163-168. Huggins, Karl E., Micropressor Applications of Multi-Level Air Decompression Problems. Michigan Sea Grant Program, NA86AA-D-SG043, 1987. Lewis, John E., "The Datamaster II -- A Fundamentally Different Dive Computer," Proceedings ... AAUS... 1989, pp. 43-47. Loyst, Ken and Michael Steidley, Diving with Dive Computers, Watersport Publishing, San Diego, 1989. Somers, Lee H. "Dive Computers in Scientific Diving Programs" Proceedings ... AAUS...1989, pp. 203-205. Short, Donald R. and C. Mark Flahan, "Reconstructing the Navy Tables," Proceedings .. AAUS ... 1989, pp. 181 - 187. Unfortunately, I don't have any of these references myself. I borrowed them from my instructor. Let's keep this discussion going. I think it's very interesting. I'd be happy to port another article with background on M values and compartments and how they're used to compute, no decompression time remaining and decompression ceiling, etc. etc. --Eric Williams. sargon@portia.stanford.edu, uucp? thru decwrl? ------------------------------------------------------------------ From: duis@sgi.com (David Duis) Newsgroups: rec.scuba Subject: Re: Feature Request: Let's design our own dive computer Summary: Extended Navy M-values table Keywords: dive computers, algorithms, features, US Navy Tables, M values Date: 9 Nov 90 01:32:23 GMT Reply-To: duis@bent.esd.sgi.com Organization: Silicon Graphics, Inc., Mountain View, CA In article <1990Nov7.225018.23403@odin.corp.sgi.com> duis@sgi.com (David Duis) writes: >As promised, here are the US Navy M-values, as used to compute the >current Navy tables. > >These figures represent the maximum allowable no-decompression >nitrogen-loading. Figures for the 160, 200, and 240 minute >compartments are not listed in the NAUI book -- I'll look them up in >_Physiology & Medicine of Diving_ RSN (Real Soon Now :-). As promised, here is the extended table. Please note that the 160,200, and 240 minute compartments are used only for the Navy Exceptional Exposure tables. However, I consider a multi-day multi-dive-per-day dive trip to be an "exceptional exposure," thus I have included these values. Compartment Surfacing ratios: Half time TOTAL NITROGEN M-VALUE (fsw) 5 4:1 3.15:1 104 10 3.4:1 2.67:1 88 20 2.75:1 2.18:1 72 40 2.22:1 1.76:1 58 80 2:1 1.58:1 52 120 1.96:1 1.55:1 51 160 1.96:1 1.55:1 51 200 1.96:1 1.55:1 51 240 1.92:1 1.52:1 50 I look forward to ANY simulation, now that we have these values. While it would be nice to model every computer, a simple multi-level simulation of the Navy Tables would be nice. Anyone have the M-values for the DSAT table, which uses a 60-minute controlling half-time? I believe these are the same values as those used in the Sherwood Source/Oceanic Sport, so we'd be doubly served. Cheers, Dave Duis NAUI AI Z9588, PADI DM 43922 duis@bent.esd.sgi.com opinions my own, and subject to dispute --------------------------------------------------------------------