/// Converts from PSF (pounds per square foot) to one of several unit systems. protected double ConvertFromPSF(double p, ePressure unit = ePressure.ePSF) { double targetPressure = 0; // Pressure switch (unit) { case ePressure.ePSF: targetPressure = p; break; case ePressure.eMillibars: targetPressure = p / 2.08854342; break; case ePressure.ePascals: targetPressure = p / 0.0208854342; break; case ePressure.eInchesHg: targetPressure = p / 70.7180803; break; default: throw new Exception("Undefined pressure unit given"); } return(targetPressure); }
/** Sets the partial pressure of water vapor. * @param Pv The vapor pressure in the units specified * @param unit The unit of measure that the specified vapor pressure is * supplied in. */ public void SetVaporPressure(ePressure unit, double Pa) { double altitude = CalculatePressureAltitude(Pressure, 0.0); double VaporPressure = ConvertToPSF(Pa, unit); VaporMassFraction = Rdry * VaporPressure / (Rwater * (Pressure - VaporPressure)); ValidateVaporMassFraction(altitude); }
/** Returns the saturated pressure of water vapor. * @param to The unit of measure that the water vapor should be supplied in. */ public double GetSaturatedVaporPressure(ePressure to) { return(ConvertFromPSF(saturatedVaporPressure, to)); }
/** Returns the partial pressure of water vapor. * @param to The unit of measure that the water vapor should be supplied in. */ public double GetVaporPressure(ePressure to) { double VaporPressure = Pressure * VaporMassFraction / (VaporMassFraction + Rdry / Rwater); return(ConvertFromPSF(VaporPressure, to)); }
/** Sets the sea level pressure for modeling an off-standard pressure * profile. This could be useful in the case where the pressure at an * airfield is known or set for a particular simulation run. * @param pressure The pressure in the units specified. * @param unit the unit of measure that the specified pressure is * supplied in.*/ public override void SetPressureSL(ePressure unit, double pressure) { SLpressure = ConvertToPSF(pressure, unit); CalculateSLDensity(); CalculatePressureBreakpoints(SLpressure); }
/// <summary> /// Sets the sea level pressure for modeling. /// </summary> /// <param name="unit">the unit of measure that the specified pressure is supplied in.</param> /// <param name="pressure">The pressure in the units specified.</param> public virtual void SetPressureSL(ePressure unit, double pressure) { double press = ConvertToPSF(pressure, unit); SLpressure = press; }
/// <summary> /// Returns the sea level pressure in target units, default in psf. /// </summary> /// <param name="to"></param> /// <returns></returns> public virtual double GetPressureSL(ePressure to = ePressure.ePSF) { return(ConvertFromPSF(SLpressure, to)); }