Unit-safe fluid properties using CoolProp and EngineeringUnits
Looking up properties for Ammonia
usingEngineeringUnits;usingEngineeringUnits.Units;usingSharpFluids;...FluidR717=newFluid(FluidList.Ammonia);R717.UpdatePT(Pressure.FromBars(10),Temperature.FromDegreesCelsius(100));Console.WriteLine(R717.Density);// 5.751 kg/m³Console.WriteLine(R717.DynamicViscosity);// 1.286e-05 Pa·sAvailable properties
CompressibilityConductivity(W/m/K)CriticalPressure(Pa)CriticalTemperature(K)Density- (kg/m3)DynamicViscosity(Pa*s)Enthalpy(J/kg)Entropy(J/kg/K)InternalEnergy(J/kg)MolarMass(kg/mol)PhasePrandtlPressure(Pa)QualitySoundSpeed(m/s)SpecificHeat(J/kg/K)SurfaceTension(N/m)Temperature(K)TriplePressure(Pa)TripleTemperature(K)
"As long as you do all your calculation in SI-units.." is the normal saying but if you have tried spending days debugging code to figure out you 'just' had a wrong unit - then unit-safety is your new friend
This is an example of a common unit mistake - With unit-safety you get an error where you did the mistake.
Massmass=newMass(10,MassUnit.Kilogram);Volumevolume=newVolume(4,VolumeUnit.CubicMeter);DensityD1=mass/volume;// 2.5 kg/m³DensityD2=volume/mass;// WrongUnitException: 'This is NOT a [kg/m³] as expected! Your Unit is a [m³/kg]'You just input the units you have and ask for the units you want:
Lengthlength=newLength(5.485,LengthUnit.Inch);Lengthheight=newLength(12.4,LengthUnit.Centimeter);Areaarea=length*height;// 0.01728 m²Console.WriteLine(area.ToUnit(AreaUnit.SquareFoot));// 0.186 ft²Console.WriteLine(area.ToUnit(AreaUnit.SquareCentimeter));// 172.8 cm²