public void ConversionRoundTrip() { Pressure pascal = Pressure.FromPascals(1); Assert.AreEqual(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance); Assert.AreEqual(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance); Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance); Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance); Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance); Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance); Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance); Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance); Assert.AreEqual(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance); Assert.AreEqual(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance); Assert.AreEqual(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance); Assert.AreEqual(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance); Assert.AreEqual(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance); Assert.AreEqual(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance); Assert.AreEqual(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance); Assert.AreEqual(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance); Assert.AreEqual(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance); Assert.AreEqual(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance); Assert.AreEqual(1, Pressure.FromPsi(pascal.Psi).Pascals, PsiTolerance); Assert.AreEqual(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance); Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance); Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance); Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance); Assert.AreEqual(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance); }
public void TestMethod1() { //Creating Compressor object Compressor Comp = new Compressor(FluidList.Ammonia); //Settings for the compressor Comp.DischargePressure = Pressure.FromBars(60); Comp.EtaI = 0.80; Comp.EtaV = 0.80; Comp.Inlet.UpdatePX(Pressure.FromBars(20), 1); Comp.Inlet.MassFlow = MassFlow.FromKilogramsPerSecond(0.65); //Calling the compressor calculations Comp.DoCalculation(); //Test Input case Assert.AreEqual(0.80, Comp.EtaI); Assert.AreEqual(0.80, Comp.EtaV); Assert.AreEqual(20, Comp.Inlet.Pressure.Bars, 0.00001); Assert.AreEqual(60, Comp.DischargePressure.Bars, 0.00001); Assert.AreEqual(1637090.7774993675, Comp.Inlet.Enthalpy.JoulesPerKilogram, 0.1); Assert.AreEqual(0.65, Comp.Inlet.MassFlow.KilogramsPerSecond, 0.00001); //Test Output condition Assert.AreEqual(1834964.38585952, Comp.Outlet.Enthalpy.JoulesPerKilogram, 10); Assert.AreEqual(60, Comp.Outlet.Pressure.Bars, 0.001); Assert.AreEqual(0.018348331149592015, Comp.Outlet.VolumeFlow.CubicMetersPerSecond, 0.001); Assert.AreEqual(Comp.Inlet.MassFlow, Comp.Outlet.MassFlow); }
public ControlPressure() { InitializeComponent(); Unit = PressureUnit.Bar; Minimum2 = Pressure.Zero; Maximum2 = Pressure.FromBars(10000); Minimum = (decimal)Minimum2.As(unit); Maximum = (decimal)Maximum2.As(unit); }
public Form1() { //Starting up frontpage InitializeComponent(); //Starting LOGPH diagram Plot_LogPH LOGPH = new Plot_LogPH(MyChart, FluidList.Ammonia); //Setting up class's Compressor Comp = new Compressor(FluidList.Ammonia); Condenser Cond = new Condenser(FluidList.Ammonia); ExpValve Valve = new ExpValve(FluidList.Ammonia); Evaporator Evap = new Evaporator(FluidList.Ammonia); //Connecting the units Cond.Inlet = Comp.Outlet; Valve.Inlet = Cond.Outlet; Evap.Inlet = Valve.Outlet; Comp.Inlet = Evap.Outlet; //Settings for the compressor Comp.DischargePressure = Pressure.FromBars(60); Comp.EtaI = 0.80; Comp.EtaV = 0.80; //Settings for the Valve Valve.EvapPressure = Pressure.FromBars(10); //Settings for the Valve Evap.SuperHeat = Temperature.FromKelvins(10); for (int i = 0; i < 10; i++) { Comp.DoCalculation(); Cond.DoCalculation(); Valve.DoCalculation(); Evap.DoCalculation(); } //Drawing the dome LOGPH.PlotLogPH(); LOGPH.Plot(Comp.Inlet, Comp.Outlet); LOGPH.Plot(Cond.Inlet, Cond.Outlet); LOGPH.Plot(Valve.Inlet, Valve.Outlet); LOGPH.Plot(Evap.Inlet, Evap.Outlet); }
public void ConversionRoundTrip() { Pressure pascal = Pressure.FromPascals(1); AssertEx.EqualTolerance(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance); AssertEx.EqualTolerance(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromCentibars(pascal.Centibars).Pascals, CentibarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromDecapascals(pascal.Decapascals).Pascals, DecapascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromDecibars(pascal.Decibars).Pascals, DecibarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromDynesPerSquareCentimeter(pascal.DynesPerSquareCentimeter).Pascals, DynesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromFeetOfHead(pascal.FeetOfHead).Pascals, FeetOfHeadTolerance); AssertEx.EqualTolerance(1, Pressure.FromGigapascals(pascal.Gigapascals).Pascals, GigapascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromHectopascals(pascal.Hectopascals).Pascals, HectopascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromInchesOfMercury(pascal.InchesOfMercury).Pascals, InchesOfMercuryTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilobars(pascal.Kilobars).Pascals, KilobarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance); AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance); AssertEx.EqualTolerance(1, Pressure.FromMegabars(pascal.Megabars).Pascals, MegabarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromMeganewtonsPerSquareMeter(pascal.MeganewtonsPerSquareMeter).Pascals, MeganewtonsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromMetersOfHead(pascal.MetersOfHead).Pascals, MetersOfHeadTolerance); AssertEx.EqualTolerance(1, Pressure.FromMicrobars(pascal.Microbars).Pascals, MicrobarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromMicropascals(pascal.Micropascals).Pascals, MicropascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromMillibars(pascal.Millibars).Pascals, MillibarsTolerance); AssertEx.EqualTolerance(1, Pressure.FromMillimetersOfMercury(pascal.MillimetersOfMercury).Pascals, MillimetersOfMercuryTolerance); AssertEx.EqualTolerance(1, Pressure.FromMillipascals(pascal.Millipascals).Pascals, MillipascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance); AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance); AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance); AssertEx.EqualTolerance(1, Pressure.FromPoundsPerInchSecondSquared(pascal.PoundsPerInchSecondSquared).Pascals, PoundsPerInchSecondSquaredTolerance); AssertEx.EqualTolerance(1, Pressure.FromPsi(pascal.Psi).Pascals, PsiTolerance); AssertEx.EqualTolerance(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance); AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance); AssertEx.EqualTolerance(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance); }
public void UpdatePX() { //Arrange Fluid Co2 = new Fluid(FluidList.CO2); Pressure setPressure = Pressure.FromBars(25); double X = 1; Mass SetMass = Mass.FromKilograms(43); //Act Co2.UpdatePX(setPressure, X); Co2.Mass = SetMass; //Assert Assert.IsFalse(Co2.FailState); Assert.AreEqual(0.016083133611710109, Co2.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(1456.9187615135381, Co2.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(800.30959584601669, Co2.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(435661.92547518451, Co2.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(1.2412134074282795, Co2.Prandtl, 0.0001); Assert.AreEqual(24.999999999999989, Co2.Pressure.Bars, 0.0001); Assert.AreEqual(73.773, Co2.CriticalPressure.Bars, 0.0001); Assert.AreEqual(8000, Co2.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(5.1796434344772573, Co2.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(66.78620802621117, Co2.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(0.45619347847526537, Co2.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0, Co2.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(-12.01316976352382, Co2.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(-12.013169763523649, Co2.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Co2.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(-56.557999999999964, Co2.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(1.3701931500680655E-05, Co2.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(X, Co2.Quality, 0.0001); Assert.AreEqual(0, Co2.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(44.0098, Co2.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.758748472112, Co2.Compressibility, 0.0001); Assert.AreEqual(398229.047133, Co2.InternalEnergy.JoulesPerKilogram, 0.0001); Assert.AreEqual(43, Co2.Mass.Kilograms, 0.0001); Assert.AreEqual(0.64384550749046954, Co2.Volume.CubicMeters, 0.0001); }
public void TranscriticalState() { //Arrange Fluid Co2 = new Fluid(FluidList.CO2); Pressure setPressure = Pressure.FromBars(90); Temperature setTemperature = Temperature.FromDegreesCelsius(30); Mass SetMass = Mass.FromKilograms(43); //Act Co2.UpdatePT(setPressure, setTemperature); Co2.Mass = SetMass; //Assert Assert.IsFalse(Co2.FailState); Assert.AreEqual(5.1796434344772573, Co2.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(8000, Co2.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(73.773, Co2.CriticalPressure.Bars, 0.0001); Assert.AreEqual(-56.557999999999964, Co2.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Co2.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(0.0832514502504721, Co2.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(3796.4672563772951, Co2.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(982.57493262354069, Co2.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(276318.70433843043, Co2.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(2.8243769924416289, Co2.Prandtl, 0.0001); Assert.AreEqual(90, Co2.Pressure.Bars, 0.0001); Assert.AreEqual(744.30948867565462, Co2.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(0.29681456863586464, Co2.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0, Co2.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(30, Co2.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(6.1934810653208115E-05, Co2.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(-1, Co2.Quality, 0.0001); Assert.AreEqual(345.78742425860986, Co2.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(44.0098, Co2.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.211127165113, Co2.Compressibility, 0.0001); Assert.AreEqual(264226.960051, Co2.InternalEnergy.JoulesPerKilogram, 0.0001); Assert.AreEqual(43, Co2.Mass.Kilograms, 0.0001); Assert.AreEqual(0.0577716671011539, Co2.Volume.CubicMeters, 0.0001); }
private IEnumerable <Layer> GetMockUnbreathableAtmo() { var layers = new List <Layer>() { new BasicSolidLayer(Length.FromKilometers(10000.0)), new BasicGaseousLayer(Length.FromKilometers(100.0), new List <(Chemical, Ratio)>() { (TestGases["N"], Ratio.FromDecimalFractions(1.0)) }, Pressure.FromBars(1.0)) }; return(layers); /*return new Gas[] * { * new Gas(TestGases["N"], Pressure.FromMillibars(GlobalConstants.EARTH_SURF_PRES_IN_MILLIBARS) ) * };*/ }
public void GasState() { //Arrange Fluid Co2 = new Fluid(FluidList.CO2); Pressure setPressure = Pressure.FromBars(50); Temperature setTemperature = Temperature.FromDegreesCelsius(40); Mass SetMass = Mass.FromKilograms(43); //Act Co2.UpdatePT(setPressure, setTemperature); Co2.Mass = SetMass; //Assert Assert.IsFalse(Co2.FailState); Assert.AreEqual(0.023128791374493297, Co2.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(1469.6947917707614, Co2.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(807.62943446640077, Co2.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(467125.89386438479, Co2.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(1.0820593348809831, Co2.Prandtl, 0.0001); Assert.AreEqual(50, Co2.Pressure.Bars, 0.0001); Assert.AreEqual(73.773, Co2.CriticalPressure.Bars, 0.0001); Assert.AreEqual(8000, Co2.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(5.1796434344772573, Co2.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(113.05213925800003, Co2.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(0.4588969385489618, Co2.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0, Co2.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(40, Co2.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(14.283923802417348, Co2.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Co2.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(-56.557999999999964, Co2.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(1.7028518268838521E-05, Co2.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(-1, Co2.Quality, 0.0001); Assert.AreEqual(237.78957338780987, Co2.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(44.0098, Co2.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.747569438228, Co2.Compressibility, 0.0001); Assert.AreEqual(422898.513161, Co2.InternalEnergy.JoulesPerKilogram, 0.0001); Assert.AreEqual(43, Co2.Mass.Kilograms, 0.0001); Assert.AreEqual(0.38035547387447732, Co2.Volume.CubicMeters, 0.0001); }
public void LiqGasState() { //Arrange Fluid Co2 = new Fluid(FluidList.CO2); Pressure setPressure = Pressure.FromBars(25); double X = 0.5; Mass SetMass = Mass.FromKilograms(43); //Act Co2.UpdatePX(setPressure, X); Co2.Mass = SetMass; //Assert Assert.IsFalse(Co2.FailState); Assert.AreEqual(5.1796434344772573, Co2.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(8000, Co2.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(73.773, Co2.CriticalPressure.Bars, 0.0001); Assert.AreEqual(-56.557999999999964, Co2.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Co2.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(0.019438568632493974, Co2.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(9538.9198786323577, Co2.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(1328.5132337829052, Co2.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(303821.86127955979, Co2.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(7.2362227645827124, Co2.Prandtl, 0.0001); Assert.AreEqual(25, Co2.Pressure.Bars, 0.0001); Assert.AreEqual(125.15644631203638, Co2.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(0.33552673235991382, Co2.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0.006762279814496573, Co2.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(-12.01316976352382, Co2.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(-12.01316976352706, Co2.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(1.4746094383751521E-05, Co2.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(0.5, Co2.Quality, 0.0001); Assert.AreEqual(0, Co2.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(44.0098, Co2.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.557960456, Co2.Compressibility, 0.0001); Assert.AreEqual(43, Co2.Mass.Kilograms, 0.0001); Assert.AreEqual(0.34356999792718357, Co2.Volume.CubicMeters, 0.0001); }
public void LiquidState() { //Arrange Fluid Co2 = new Fluid(FluidList.CO2); Pressure setPressure = Pressure.FromBars(50); Temperature setTemperature = Temperature.FromDegreesCelsius(0); Mass SetMass = Mass.FromKilograms(43); //Act Co2.UpdatePT(setPressure, setTemperature); Co2.Mass = SetMass; //Assert Assert.IsFalse(Co2.FailState); Assert.AreEqual(0.11302927178715505, Co2.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(2417.260925841651, Co2.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(935.30983351562668, Co2.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(198533.51952994024, Co2.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(2.2073170762964236, Co2.Prandtl, 0.0001); Assert.AreEqual(50, Co2.Pressure.Bars, 0.0001); Assert.AreEqual(73.773, Co2.CriticalPressure.Bars, 0.0001); Assert.AreEqual(8000, Co2.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(5.1796434344772573, Co2.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(940.51699029972065, Co2.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(0.23630359663511932, Co2.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0, Co2.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(0, Co2.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(14.283923802417348, Co2.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(30.978200000000015, Co2.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Co2.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(-56.557999999999964, Co2.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(0.00010321245798083137, Co2.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(-1, Co2.Quality, 0.0001); Assert.AreEqual(567.71652802229244, Co2.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(44.0098, Co2.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.103018421004, Co2.Compressibility, 0.0001); Assert.AreEqual(193217.294462, Co2.InternalEnergy.JoulesPerKilogram, 0.0001); Assert.AreEqual(43, Co2.Mass.Kilograms, 0.0001); Assert.AreEqual(0.045719535578296049, Co2.Volume.CubicMeters, 0.0001); }
public void UpdatePT() { //Arrange Fluid Water = new Fluid(FluidList.Water); Pressure setPressure = Pressure.FromBars(3); Temperature setTemperature = Temperature.FromDegreesCelsius(237); //Act Water.UpdatePT(setPressure, setTemperature); //Assert Assert.IsFalse(Water.FailState); Assert.AreEqual(0.03752160884674547, Water.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(2034.1444264493639, Water.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(1539.4771263572343, Water.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(2941434.7212755163, Water.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(0.95772763107228476, Water.Prandtl, 0.0001); Assert.AreEqual(3, Water.Pressure.Bars, 0.0001); Assert.AreEqual(220.64, Water.CriticalPressure.Bars, 0.0001); Assert.AreEqual(10000, Water.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(0.0061165480089686846, Water.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(1.2890299515474706, Water.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(1.7846226274892405, Water.Entropy.CaloriesPerGramKelvin, 0.0001); //Assert.AreEqual(0.052144997752313106, Water.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(237, Water.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(133.522420460943, Water.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(373.946, Water.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Water.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(0.010000000000047749, Water.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(1.7666140657249425E-05, Water.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(-1, Water.Quality, 0.0001); Assert.AreEqual(551.279827045, Water.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(18.015268, Water.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.988488597881, Water.Compressibility, 0.0001); Assert.AreEqual(2708701.57212, Water.InternalEnergy.JoulesPerKilogram, 0.001); }
public void UpdatePX() { //Arrange Fluid Water = new Fluid(FluidList.Water); Pressure setPressure = Pressure.FromBars(3); double X = 1; //Act Water.UpdatePX(setPressure, X); //Assert Assert.IsFalse(Water.FailState); Assert.AreEqual(0.028215527552977144, Water.Conductivity.WattsPerMeterKelvin, 0.0001); Assert.AreEqual(2263.0469328306258, Water.Cp.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(1671.0843504212746, Water.Cv.JoulesPerKilogramKelvin, 0.0001); Assert.AreEqual(2724882.6302959691, Water.Enthalpy.JoulesPerKilogram, 0.0001); Assert.AreEqual(1.0742998825687049, Water.Prandtl, 0.0001); Assert.AreEqual(3.0000000000000004, Water.Pressure.Bars, 0.0001); Assert.AreEqual(220.64, Water.CriticalPressure.Bars, 0.0001); Assert.AreEqual(10000, Water.LimitPressureMax.Bars, 0.0001); Assert.AreEqual(0.0061165480089686846, Water.LimitPressureMin.Bars, 0.0001); Assert.AreEqual(1.650819966799242, Water.Density.KilogramsPerCubicMeter, 0.0001); Assert.AreEqual(1.6710365869337238, Water.Entropy.CaloriesPerGramKelvin, 0.0001); Assert.AreEqual(0, Water.SurfaceTension.NewtonsPerMeter, 0.0001); Assert.AreEqual(133.522420460943, Water.Temperature.DegreesCelsius, 0.0001); Assert.AreEqual(133.52242046094256, Water.Tsat.DegreesCelsius, 0.0001); Assert.AreEqual(373.946, Water.CriticalTemperature.DegreesCelsius, 0.0001); Assert.AreEqual(1726.85, Water.LimitTemperatureMax.DegreesCelsius, 0.0001); Assert.AreEqual(0.010000000000047749, Water.LimitTemperatureMin.DegreesCelsius, 0.0001); Assert.AreEqual(1.3394303713738338E-05, Water.DynamicViscosity.NewtonSecondsPerMeterSquared, 0.0001); Assert.AreEqual(X, Water.Quality, 0.0001); Assert.AreEqual(0, Water.SoundSpeed.MetersPerSecond, 0.0001); Assert.AreEqual(18.015268, Water.MolarMass.GramsPerMole, 0.0001); Assert.AreEqual(0.968251392124, Water.Compressibility, 0.0001); Assert.AreEqual(2543154.75807, Water.InternalEnergy.JoulesPerKilogram, 0.001); }
public void UpdatePTFailedTestIceWater() { //It cant do lookups on Ice //Arrange Fluid Water = new Fluid(FluidList.Water); Pressure setPressure = Pressure.FromBars(3); Temperature setTemperature = Temperature.FromDegreesCelsius(-5); //Act Water.UpdatePT(setPressure, setTemperature); //Assert Assert.IsTrue(Water.FailState); Assert.AreEqual(0, Water.Conductivity.WattsPerMeterKelvin); Assert.AreEqual(0, Water.Cp.JoulesPerKilogramKelvin); Assert.AreEqual(0, Water.Cv.JoulesPerKilogramKelvin); Assert.AreEqual(0, Water.Enthalpy.JoulesPerKilogram); Assert.AreEqual(0, Water.Prandtl); Assert.AreEqual(0, Water.Pressure.Bars); Assert.AreEqual(0, Water.Density.KilogramsPerCubicMeter); Assert.AreEqual(0, Water.Entropy.KilocaloriesPerGramKelvin); Assert.AreEqual(0, Water.SurfaceTension.NewtonsPerMeter); Assert.AreEqual(0, Water.Temperature.Kelvins); Assert.AreEqual(0, Water.Tsat.Kelvins); Assert.AreEqual(0, Water.DynamicViscosity.NewtonSecondsPerMeterSquared); Assert.AreEqual(0, Water.Quality); Assert.AreEqual(0, Water.SoundSpeed.MetersPerSecond); Assert.AreEqual(0, Water.MolarMass.GramsPerMole); Assert.AreEqual(0, Water.Compressibility); Assert.AreEqual(0, Water.InternalEnergy.JoulesPerKilogram); }
//Dome private ChartValues <ObservablePoint> Dome() { var Results = new ChartValues <ObservablePoint>(); var SelectedFluid = new Fluid(RefType); Pressure top, bottom, step; //This defines the top of the 'dome' top = SelectedFluid.CriticalPressure; bottom = SelectedFluid.LimitPressureMin; step = Pressure.FromBars(1); //Creating the left side of the dome with X = 0 for (Pressure i = bottom; i <= top; i = i + step) { SelectedFluid.UpdatePX(i, 0); Results.Add(new ObservablePoint { X = SelectedFluid.Enthalpy.ToUnit(UnitsNet.Units.SpecificEnergyUnit.KilojoulePerKilogram).Value, Y = i.ToUnit(UnitsNet.Units.PressureUnit.Bar).Value }); } //Creating the right side of the dome with X = 1 for (Pressure i = top; i >= bottom; i = i - step) { SelectedFluid.UpdatePX(i, 1); Results.Add(new ObservablePoint { X = SelectedFluid.Enthalpy.ToUnit(UnitsNet.Units.SpecificEnergyUnit.KilojoulePerKilogram).Value, Y = i.ToUnit(UnitsNet.Units.PressureUnit.Bar).Value }); } return(Results); }
public Form1() { //Starting up frontpage InitializeComponent(); //Starting LOGPH diagram Plot_LogPH LOGPH = new Plot_LogPH(MyChart, FluidList.Ammonia); PlotXY XYChart = new PlotXY(MyChartXY); //Playing around with a normal XY Graph XYChart.Plot(Power.FromKilowatts(10), MassFlow.FromKilogramsPerSecond(1)); XYChart.Plot(Power.FromKilowatts(11), MassFlow.FromKilogramsPerSecond(1.2)); XYChart.Plot(Power.FromKilowatts(12), MassFlow.FromKilogramsPerSecond(1.6)); XYChart.Plot(Power.FromKilowatts(13), MassFlow.FromKilogramsPerSecond(1.7)); XYChart.Plot(Power.FromKilowatts(14), MassFlow.FromKilogramsPerSecond(1.8)); XYChart.Plot(Power.FromKilowatts(15), MassFlow.FromKilogramsPerSecond(1.9)); XYChart.Plot(Power.FromKilowatts(17), MassFlow.FromKilogramsPerSecond(2)); XYChart.Plot(Power.FromKilowatts(21), MassFlow.FromKilogramsPerSecond(2.8)); XYChart.Plot(Power.FromKilowatts(25), MassFlow.FromKilogramsPerSecond(3)); LOGPH.PlotLogPH(); Fluid Vand = new Fluid(FluidList.Water); //Compressor calculations Fluid CompressorInlet = new Fluid(FluidList.Ammonia); Fluid CompressorOutlet = new Fluid(FluidList.Ammonia); Fluid CompressorOutletH2s = new Fluid(FluidList.Ammonia); //Giving the inlet guess on its condition CompressorInlet.UpdatePX(Pressure.FromBars(5), 1); LOGPH.Plot(CompressorInlet); //Calculating the outlet af compressor //This is h1 SpecificEnergy h1 = CompressorInlet.Enthalpy; //Updating output refrigerant with the high pressure and the entropy(from input) CompressorOutletH2s.UpdatePS(Pressure.FromBars(30), CompressorInlet.Entropy); LOGPH.Plot(CompressorOutletH2s); //Setting h2s from output-refrigerant SpecificEnergy H2s = CompressorOutletH2s.Enthalpy; //Compressor calculation SpecificEnergy h2 = ((H2s - h1) / 0.80) + h1; //Compressor outlet condition CompressorOutlet.UpdatePH(CompressorOutletH2s.Pressure, h2); LOGPH.Plot(CompressorOutlet); //Plot Compressor as lines LOGPH.Plot(CompressorInlet, CompressorOutlet); //Creating a condensator Fluid CondenserInlet = new Fluid(FluidList.Ammonia); Fluid CondenserOutlet = new Fluid(FluidList.Ammonia); //The inlet of the condenser is the same as compressor outlet CondenserInlet.Copy(CompressorOutlet); //Condensator outlet CondenserOutlet.UpdatePX(CondenserInlet.Pressure, 0); //Plot Condensator as lines LOGPH.Plot(CondenserInlet, CondenserOutlet); //Creating a Expansion valve Fluid ValveInlet = new Fluid(FluidList.Ammonia); Fluid ValveOutlet = new Fluid(FluidList.Ammonia); //The inlet of the valve is the same as condens outlet ValveInlet.Copy(CondenserOutlet); //Expansion valve drops the pressure down but keeps the Enthalpy ValveOutlet.UpdatePH(CompressorInlet.Pressure, ValveInlet.Enthalpy); //Plot Valve as lines LOGPH.Plot(ValveInlet, ValveOutlet); //Creating an Evaporator Fluid EvaporatorInlet = new Fluid(FluidList.Ammonia); Fluid EvaporatorOutlet = new Fluid(FluidList.Ammonia); //The inlet of the valve is the same as condens outlet EvaporatorInlet.Copy(ValveOutlet); //Creating a superheat of 10°C EvaporatorOutlet.UpdatePT(EvaporatorInlet.Pressure, EvaporatorInlet.Tsat + TemperatureDelta.FromKelvins(10)); //Plot Valve as lines LOGPH.Plot(EvaporatorInlet, EvaporatorOutlet); //Telling the compressor that it is connected to the evaporator CompressorInlet.Copy(EvaporatorOutlet); //Calculations //Can we find the power input to the compressor? //Setting a massflow MassFlow MassflowCompressor = MassFlow.FromKilogramsPerSecond(0.45); //Power = Massflow * (H2 - H1) Power PowerToCompressor = MassflowCompressor * (CompressorOutlet.Enthalpy - CompressorInlet.Enthalpy); //Print it to Debug screen without telling it in what unit we want to see it Debug.Print(PowerToCompressor.ToString()); //Giving it a unit to display it in Debug.Print(PowerToCompressor.ToUnit(PowerUnit.Kilowatt).ToString()); ///What if we want to calculation an equation that the unit-system cant handle? //!Beware!: Normally you should let the UnitSystem handle the units because it checks the units for you // and it puts out an error if you have messed up the units. // Sometimes the unitsystem give you an error even though the equation is correct and then you have to // do this to bypass the unitsystem and then you have to handle the units yourself! //The Stefan - Boltzmann Constant double σ = 5.6703 * 10E-8; //(W / m2K4) Temperature TempOfBlackBody = Temperature.FromDegreesCelsius(20); Area AreaOfBody = Area.FromSquareMeters(0.634); //q = σ * T^4 * A Power RadiationPower = Power.FromWatts(σ * Math.Pow(TempOfBlackBody.Kelvins, 4) * AreaOfBody.SquareMeters); //Display result Debug.Print(RadiationPower.ToUnit(PowerUnit.Kilowatt).ToString()); //Example: Putting code in Class to make it easyier to reuse //New instance of a compressor Compressor Comp1 = new Compressor(FluidList.Ammonia); //Settings for the compressor Comp1.DischargePressure = Pressure.FromBars(60); Comp1.EtaI = 0.80; Comp1.EtaV = 0.80; //Giving the compressor en inlet condition Comp1.Inlet.UpdatePX(Pressure.FromBars(20), 1); //Calling the compressor calculations Comp1.DoCalculation(); //Plotting the result LOGPH.Plot(Comp1.Inlet, Comp1.Outlet); }
public void NumberToBarsTest() => Assert.Equal(Pressure.FromBars(2), 2.Bars());
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .WriteTo.Debug() .CreateLogger(); Log.Information("Hello, world!"); MoistAir Air = new MoistAir(); Air.UpdateAir(Pressure.FromBars(1), DryBulbTemperature: Temperature.FromDegreesCelsius(20), RelativeHumidity: 0.7 ); Air.UpdateAir(Pressure.FromBars(1), HumidityRatio: 0.010397090640274141, RelativeHumidity: 0.7); //Air.UpdateAir(Pressure.FromSI(101325), HumidityRatio: 0.011, RelativeHumidity: 0.8); Fluid R407C = new Fluid(FluidList.R407C); R407C.UpdatePX(Pressure.FromMegapascals(4.022736), 0); Fluid Ammonia = new Fluid(FluidList.Ammonia); var test11 = Ammonia.GetEnvelopePhase(); Ammonia.UpdatePX(Pressure.FromBars(25), 0.5); Ammonia.UpdateDH(Ammonia.Density, Ammonia.Enthalpy); Ammonia.UpdatePT(Pressure.FromSI(2293443.57087332), Temperature.FromSI(405.55873230045091)); Ammonia.UpdatePT(Pressure.FromSI(2493443), Temperature.FromSI(410)); Fluid r134a = new Fluid(FluidList.R134a); r134a.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(75)); var phase = r134a.Phase; Length length = new Length(5.485, LengthUnit.Inch); Length height = new Length(12.4, LengthUnit.Centimeter); Area area = length * height; // 0.01728 m² Console.WriteLine(area.ToUnit(AreaUnit.SquareFoot)); // 0.186 ft² Console.WriteLine(area.ToUnit(AreaUnit.SquareCentimeter)); // 172.8 cm² Console.WriteLine(area.GetHashCode()); Fluid R717 = new Fluid(FluidList.Ammonia); R717.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(100)); Fluid R717Clone = R717.Clone(); Console.WriteLine(R717.Density); // 5.751 kg/m³ Console.WriteLine(R717.DynamicViscosity); // 1.286e-05 Pa·s //Fluid test12 = new Fluid(FluidList.Custom_SHC226E); //test12.updateAir("H","T",298.15,"P",101325,"R",0.5); Air.UpdateAir(Pressure.FromBars(1), DryBulbTemperature: Temperature.FromKelvins(298.15), RelativeHumidity: 0.5 ); Debug.Print($"WetBulbTemperature: {Air.WetBulbTemperature}"); Debug.Print($"DewPointTemperature: {Air.DewPointTemperature}"); Debug.Print($"DryBulbTemperature: {Air.Temperature}"); Debug.Print($"RelativeHumidity: {Air.RelativeHumidity * 100} % "); Debug.Print($"HumidityRatio: {Air.HumidityRatio} kg/kg"); Enthalpy H = Air.Enthalpy; int totalcount = 10000; var watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < totalcount; i++) { Air.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(10)); Air.UpdatePT(Pressure.FromBars(2), Temperature.FromDegreesCelsius(300)); } watch.Stop(); Log.Information($"Time: {watch.ElapsedTicks / totalcount}"); string jsonString1 = JsonConvert.SerializeObject(Air); Fluid testJSON = JsonConvert.DeserializeObject <Fluid>(jsonString1); string jsonString2 = JsonConvert.SerializeObject(testJSON); Debug.Print($"{jsonString1 == jsonString2}"); testJSON.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(10)); var howManyBytes = jsonString1.Length * sizeof(Char); Debug.Print($"Size is: {howManyBytes}"); //................................................ Fluid test = new Fluid(FluidList.Water); test.UpdatePT(Pressure.FromBars(3), Temperature.FromDegreesCelsius(20)); test.MassFlow = MassFlow.FromKilogramsPerSecond(1); //for (int i = 0; i < 100000; i++) //{ // test.AddPower(Power.FromWatts(1)); //} Debug.Print(""); ////Arrange //foreach (FluidList suit in (FluidList[])Enum.GetValues(typeof(FluidList))) //{ // //Arrange // Fluid TestFluid = new Fluid(suit); // using (var loggerFactory = LoggerFactory.Create(builder => // { builder.AddConsole(); })) // { // ILogger logger = loggerFactory.CreateLogger<Program>(); // //logger.LogInformation("Logging has stared"); // TestFluid.Log = logger; // } // Debug.Print(TestFluid.Media.InternalName); // TestFluid.Log.LogInformation(TestFluid.Media.InternalName); // TestFluid.GetEnvelopePhase(); //} ////This is want we are aiming for //Entropy Aim = Entropy.FromJoulesPerKelvin(1699.7); //Temperature Max = my_fluid.LimitTemperatureMax; //Temperature Min = my_fluid.LimitTemperatureMin; //Temperature Mid = Temperature.Zero; //for (int i = 0; i < 20; i++) //{ // Mid = Temperature.FromKelvins((Max.Kelvins + Min.Kelvins) / 2); // my_fluid.UpdatePT(Pressure.FromBars(10), Mid); // if (my_fluid.Entropy > Aim) // Max = Mid; // else // Min = Mid; //} //my_fluid.UpdatePX(Pressure.FromBars(9), 0.0); // Fluid test = new Fluid(FluidList.Water); test.UpdatePT(Pressure.FromBars(-10), Temperature.FromDegreesCelsius(300)); test.UpdatePT(Pressure.FromBars(100000), Temperature.FromDegreesCelsius(300)); test.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(30000)); test.UpdatePH(Pressure.FromBars(2), SpecificEnergy.FromKilojoulesPerKilogram(10740.5)); test.MassFlow = MassFlow.FromKilogramsPerSecond(-0.0054); test.AddPower(Power.FromWatts(-86982.42)); //Fluid r134a = new Fluid(FluidList.R134a); r134a.UpdatePT(Pressure.FromBars(2), Temperature.FromDegreesCelsius(13)); string densité = r134a.Density.MilligramsPerCubicMeter.ToString(); Density Result = r134a.Density; //Arrange //Fluid R717 = new Fluid(FluidList.Ammonia); Density setDensity = Density.FromKilogramsPerCubicMeter(15.36622602626586); SpecificEnergy setEnthalpy = SpecificEnergy.FromJoulesPerKilogram(1043420.2106074861); Mass setMass = Mass.FromKilograms(43); setMass = setMass.ToUnit(MassUnit.Decagram); //Act R717.UpdateDH(setDensity, setEnthalpy); R717.Mass = setMass; //Save as JSON string json = R717.SaveAsJSON(); //Start new fluid and load as json Fluid R717JSON = R717.LoadFromJSON(json); Temperature test1 = R717JSON.Tsat; //Find the Density of water at 13°C Fluid Water = new Fluid(FluidList.Water); Water.UpdatePT(Pressure.FromBars(1.013), Temperature.FromDegreesCelsius(13)); Console.WriteLine("Density of water at 13°C: " + Water.Density); Water.UpdateHS(SpecificEnergy.FromJoulesPerKilogram(54697.59), SpecificEntropy.FromJoulesPerKilogramKelvin(195.27)); Debug.Print("Density of water is: " + Water.Density); //Giving water a Massflow Water.MassFlow = MassFlow.FromKilogramsPerHour(100); //What is the volumeFlow for this water? Console.WriteLine("VolumeFlow of the water: " + Water.VolumeFlow); //What is the boiling point of the water? Water.UpdatePX(Pressure.FromBars(1.013), 0); //X=0 it is 100% liquid and 0% gas but at it boiling point Console.WriteLine("Boiling point of this water is: " + Water.Temperature); //..and if you want to display it in another unit Console.WriteLine("Boiling point of this water is: " + Water.Temperature.ToUnit(TemperatureUnit.DegreeCelsius)); //Display Dynamic Viscosity of the water Console.WriteLine("Dynamic Viscosity of this water is: " + Water.DynamicViscosity); //Create a CO2 fluid Fluid ref1 = new Fluid(FluidList.CO2); //Update it with 25bar and X=1 ref1.UpdatePX(Pressure.FromBars(25), 1); Console.WriteLine(ref1.Cp); Console.WriteLine(ref1.Temperature); Console.WriteLine("Prandtl is : " + ref1.Prandtl); Console.WriteLine("Cp is : " + ref1.Cp); Console.WriteLine("Cv is : " + ref1.Cv); Console.WriteLine("Surface Tension is : " + ref1.SurfaceTension); Console.WriteLine("Density is : " + ref1.Density); //A Fluid that is a mix of Ammonia and water Fluid ref2 = new Fluid(FluidList.MixAmmoniaAQ); //Set the fraction between ammonia(80%) and water(20%) ref2.SetFraction(0.3); //Update it with 10bars and 10°C ref2.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(10)); //Copy fluid type Fluid ref3 = new Fluid(); ref3.CopyType(ref1); ref3.UpdatePX(Pressure.FromBars(25), 1); Console.WriteLine(ref3.Cp); Console.WriteLine(ref3.Temperature); Console.WriteLine("Prandtl is : " + ref3.Prandtl); Console.WriteLine("Cp is : " + ref3.Cp); Console.WriteLine("Cv is : " + ref3.Cv); Console.WriteLine("Surface Tension is : " + ref3.SurfaceTension); //Saving and loading to JSON Fluid ref4 = new Fluid(); string JSON = ref3.SaveAsJSON(); ref4 = ref4.LoadFromJSON(JSON); Console.WriteLine(ref4.Cp); Console.WriteLine(ref4.Temperature); Console.WriteLine("Prandtl is : " + ref4.Prandtl); Console.WriteLine("Cp is : " + ref4.Cp); Console.WriteLine("Cv is : " + ref4.Cv); Console.WriteLine("Surface Tension is : " + ref4.SurfaceTension); ref4.UpdatePX(Pressure.FromBars(45), 1); Console.WriteLine(ref4.Cp); Console.WriteLine(ref4.Temperature); Console.WriteLine("Prandtl is : " + ref4.Prandtl); Console.WriteLine("Cp is : " + ref4.Cp); Console.WriteLine("Cv is : " + ref4.Cv); Console.WriteLine("Surface Tension is : " + ref4.SurfaceTension); ref4.UpdatePX(Pressure.FromBars(25), 1); Console.WriteLine(ref4.Cp); Console.WriteLine(ref4.Temperature); Console.WriteLine("Prandtl is : " + ref4.Prandtl); Console.WriteLine("Cp is : " + ref4.Cp); Console.WriteLine("Cv is : " + ref4.Cv); Console.WriteLine("Surface Tension is : " + ref4.SurfaceTension); Console.WriteLine(ref2.Density); Fluid ref5 = new Fluid(); ref5.Copy(ref4); Console.ReadKey(); }
public static Pressure Bars <T>(this T value) => Pressure.FromBars(Convert.ToDecimal(value));
public List <(Pressure, SpecificEnergy)> GetEnvelopePhase() { List <(Pressure, SpecificEnergy)> localListLiq = new List <(Pressure, SpecificEnergy)>(); List <(Pressure, SpecificEnergy)> localListGas = new List <(Pressure, SpecificEnergy)>(); List <(Pressure, SpecificEnergy)> CompleteList = new List <(Pressure, SpecificEnergy)>(); Pressure Increment = (CriticalPressure - LimitPressureMin) / (10000); //List<Pressure> PressureList = new List<Pressure>(); //for (Pressure i = CriticalPressure; i > LimitPressureMin; i -= Increment) //{ // PressureList.Add(i); // Increment *= 1.10; //} for (Pressure i = CriticalPressure - Pressure.FromBars(1); i > LimitPressureMin; i -= Increment) { UpdatePX(i, 0); if (!FailState) { localListLiq.Add((i, Enthalpy)); } UpdatePX(i, 1); if (!FailState) { localListGas.Add((i, Enthalpy)); } Increment *= 1.10; } //localListLiq.Sort((x, y) => y.Item1.CompareTo(x.Item1)); //We dont want the Critical point to be there twice //localListLiq.RemoveAt(0); //Merging into one list foreach (var item in localListLiq.AsEnumerable().Reverse()) { CompleteList.Add(item); } foreach (var item in localListGas) { CompleteList.Add(item); } return(CompleteList); }
public static Pressure?Bars <T>(this T?value) where T : struct => Pressure.FromBars(value == null ? (double?)null : Convert.ToDouble(value.Value));