private void CalculationForOneStepInOneCompartment(ref int compartmentNo, ref double timeStep, ref Result.PPraeasureForCompartment ppc) { double ceiling = 0; if (result.Count() == 0) { ppc.setN2(compartmentNo, PartialPreasure(ppc.PreasureN2, 0.79 * calcDiving.AtmosphericPressure, 0, compartments.compartment[compartmentNo].HalfTimeForN2(false))); if (bTmx) { ppc.setN2(compartmentNo, PartialPreasure(ppc.PreasureHe, 0.0, 0, compartments.compartment[compartmentNo].HalfTimeForHe(false))); } } else { ppc.setN2(compartmentNo, PartialPreasure(ppc.PreasureN2, result.Last().getN2(compartmentNo), timeStep, compartments.compartment[compartmentNo].HalfTimeForN2(ppc.PreasureN2 < result.Last().getN2(compartmentNo)))); if (bTmx) { ppc.setN2(compartmentNo, PartialPreasure(ppc.PreasureHe, result.Last().getHe(compartmentNo), timeStep, compartments.compartment[compartmentNo].HalfTimeForHe(ppc.PreasureHe < result.Last().getHe(compartmentNo)))); } } if (bTmx) { ceiling = ceiling = Ceiling(ppc.getN2(compartmentNo), compartments.compartment[compartmentNo].M0N2, compartments.compartment[compartmentNo].dMN2, ppc.getHe(compartmentNo), compartments.compartment[compartmentNo].M0He, compartments.compartment[compartmentNo].dMHe); } else { ceiling = Ceiling(ppc.getN2(compartmentNo), compartments.compartment[compartmentNo].M0N2, compartments.compartment[compartmentNo].dMN2); } ppc.setCeiling(compartmentNo, ceiling); }
public Result.PPraeasureForCompartment GetMaxValues(bool tmx) { int compNo = compartments.compartment.Count(); Result.PPraeasureForCompartment res = new Result.PPraeasureForCompartment(compNo, tmx); foreach (Result.PPraeasureForCompartment ppfc in result) { res.AmbientPreasure = Math.Max(res.AmbientPreasure, ppfc.AmbientPreasure); res.Depth = Math.Max(res.Depth, ppfc.Depth); res.PreasureN2 = Math.Max(res.PreasureN2, ppfc.PreasureN2); if (tmx) { res.PreasureHe = Math.Max(res.PreasureHe, ppfc.PreasureHe); } res.Time = Math.Max(res.Time, ppfc.Time); int count = ppfc.Count(); for (int i = 0; i < count; i++) { res.setN2(i, Math.Max(res.getN2(i), ppfc.getN2(i))); if (tmx) { res.setHe(i, Math.Max(res.getHe(i), ppfc.getHe(i))); } } } return(res); }
public Result.PPraeasureForCompartment GetValusAtTime(double time, bool tmx) { int compNo = compartments.compartment.Count(); Result.PPraeasureForCompartment res = new Result.PPraeasureForCompartment(compNo, tmx); if (result[upperResultSerch].Time < time) { lowerResultSerch = upperResultSerch; upperResultSerch = result.Count() - 1; if (result[upperResultSerch].Time < time) { throw new Exception("GetValusAtTime. Invalid time, over maximum value"); } } if (result[lowerResultSerch].Time > time) { upperResultSerch = lowerResultSerch; lowerResultSerch = 0; if (result[lowerResultSerch].Time > time) { throw new Exception("GetValusAtTime. Invalid time, under minimum value"); } } if (lowerResultSerch > upperResultSerch) { throw new Exception("GetValusAtTime. Invalid range"); } bool notFound = true; int curentIndex = 0; while (notFound) { if (Math.Abs(result[lowerResultSerch].Time - time) < Double.Epsilon) { upperResultSerch = lowerResultSerch; } else if (Math.Abs(result[upperResultSerch].Time - time) < Double.Epsilon) { lowerResultSerch = upperResultSerch; } else { curentIndex = (int)(0.5 * (upperResultSerch + lowerResultSerch)); if (result[curentIndex].Time < time) { lowerResultSerch = curentIndex; } else { upperResultSerch = curentIndex; } } notFound = (upperResultSerch - lowerResultSerch) > 1; } if (upperResultSerch == lowerResultSerch) { res = result[upperResultSerch]; } else { double delta = (time - result[lowerResultSerch].Time) / (result[upperResultSerch].Time - result[lowerResultSerch].Time); res.Time = time; res.AmbientPreasure = result[lowerResultSerch].AmbientPreasure + delta * (result[upperResultSerch].AmbientPreasure - result[lowerResultSerch].AmbientPreasure); res.Depth = result[lowerResultSerch].Depth + delta * (result[upperResultSerch].Depth - result[lowerResultSerch].Depth); for (int i = 0; i < compNo; i++) { res.setN2(i, (result[lowerResultSerch].getN2(i) + delta * (result[upperResultSerch].getN2(i) - result[lowerResultSerch].getN2(i)))); if (tmx) { res.setHe(i, (result[lowerResultSerch].getHe(i) + delta * (result[upperResultSerch].getHe(i) - result[lowerResultSerch].getHe(i)))); } } } return(res); }