예제 #1
0
        public static double CalculateEND(DepthFactor depthF, BreathGas gas)
        {
            var air   = new BreathGas();
            var ppN   = DivingMath.SeaLevelPreasureBars * BreathGas.GetGasPartialPreasureForDepth(depthF, gas.PpN);
            var depth = DivingMath.PreasureBarsToDepth(ppN / air.PpN, depthF.WaterDensity);

            return(Math.Round(depth.Depth, 1));
        }
예제 #2
0
        private double GetCurrentCeilingDepth(double currentDepth, double?customGF = null, CompartmentCalculations[] tissues = null)
        {
            int    index      = 0;
            double maxDepth   = 0;
            double gradFactor = customGF ?? 0;

            if (gradFactor <= double.Epsilon)
            {
                if (_firstDecoStopDepth < double.Epsilon)
                {
                    gradFactor = _diveParameters.DiveConfig.GradFactorLow;
                }
                else
                {
                    currentDepth -= DecoStopsStep;
                    if (currentDepth < 0)
                    {
                        currentDepth = 0;
                    }

                    gradFactor = _diveParameters.DiveConfig.GradFactorHigh -
                                 (_diveParameters.DiveConfig.GradFactorHigh - _diveParameters.DiveConfig.GradFactorLow) / _firstDecoStopDepth * currentDepth;
                }
            }

            foreach (var cpt in _compartments)
            {
                var data   = (tissues ?? _compartmentData)[index];
                var pTotal = data.HePresure + data.N2Presure;

                var bulmanA = ((cpt.N2ValueA * data.N2Presure) + (cpt.HeValueA * data.HePresure)) / pTotal;
                var bulmanB = ((cpt.N2ValueB * data.N2Presure) + (cpt.HeValueB * data.HePresure)) / pTotal;

                var tolerantPreasure = (pTotal - (bulmanA * gradFactor)) / ((gradFactor / bulmanB) + 1.0 - gradFactor);
                var tolerantDepth    = DivingMath.PreasureBarsToDepth(tolerantPreasure, _waterDensity);

                if (tolerantDepth.Depth > maxDepth)
                {
                    maxDepth = tolerantDepth.Depth;
                }

                ++index;
            }

            return(maxDepth);
        }