public void T01_Should_create() { // kiloWatt var power = Power.FromKiloWatt(123); var theSamePower = new Power(123, PowerUnits.KiloWatt); // Temperature var tempC = CelsiusTemperature.FromDegree(23); var tempK = KelvinTemperature.FromDegree(300); // length var meters = Length.FromMeter(10); var miliMeter = Length.FromMilimeters(45); // density kg/m³ var density = new Density(23, MassUnits.Kg, VolumeUnits.CubicMeter); // stream [m³/s] [m³/h] var stream1 = new VolumeStream(34, VolumeUnits.CubicMeter, TimeUnits.Second); var stream2 = new VolumeStream(34, VolumeUnits.CubicMeter, TimeUnits.Hour); // [J/kg*K] is supported // [kJ/kg*C] is not supported var specificHeatCapacityUnit = new SpecificHeatCapacityUnit( EnergyUnits.Joule, MassUnits.Kg, KelvinTemperatureUnits.Degree); var waterSpecificHeatCapacity = new SpecificHeatCapacity(4211, specificHeatCapacityUnit); var velocity1 = Velocity.FromMeterPerSecond(12); var velocity2 = new Velocity(2, LengthUnits.Feet, TimeUnits.Minute); var pressure = new Pressure(123, PressureUnits.KiloPascal); }
public void T01_Should_decompose_SpecificHeatCapacity_unit() { var specificHeatCapacity = new SpecificHeatCapacity(50, EnergyUnits.Joule, MassUnits.Kg, KelvinTemperatureUnits.Degree); var dec = specificHeatCapacity.Unit.Decompose(); Assert.Equal(3, dec.Count); Assert.Equal("J", dec[0].ToString()); Assert.Equal("kg^-1", dec[1].ToString()); Assert.Equal("K^-1", dec[2].ToString()); }
public void T02b_Should_div_EnergyMassDensity_by_SpecificHeatCapacity() { // public static DeltaKelvinTemperature operator /(EnergyMassDensity energyMassDensity, SpecificHeatCapacity specificHeatCapacity) var energyMassDensity = new EnergyMassDensity(200, EnergyUnits.KiloJoule, MassUnits.Kg); var specificHeatCapacity = new SpecificHeatCapacity(50, EnergyUnits.Joule, MassUnits.Kg, KelvinTemperatureUnits.Degree); var d = energyMassDensity / specificHeatCapacity; Assert.Equal(4000, d.Value); Assert.Equal("K", d.Unit.UnitName); }
public void T01_Should_calculate_pipe_diameter() { var tempSupply = CelsiusTemperature.FromDegree(130); var tempReturn = CelsiusTemperature.FromDegree(95); Assert.Equal("95°C", tempReturn.ToString()); // J/kg*K var waterSpecificHeatCapacity = new SpecificHeatCapacityUnit( EnergyUnits.Joule, MassUnits.Kg, KelvinTemperatureUnits.Degree); var cp = new SpecificHeatCapacity(4211, waterSpecificHeatCapacity); var requestedPower = Power.FromKiloWatt(300); Assert.Equal("300kW", requestedPower.ToString()); var tempDifference = tempSupply - tempReturn; var energyDensity = cp * tempDifference; Assert.Equal("147385J/kg", energyDensity.ToString()); var newUnit = EnergyMassDensityUnits.KiloWattHourPerTone; energyDensity = energyDensity.ConvertTo(newUnit.Unit); Assert.Equal("40.9403kWh/t", energyDensity.Round(4).ToString()); { // other mul order - result should be the same var a1 = tempDifference * cp; Assert.Equal("147385J/kg", a1.ToString()); } // ============ mass stream var massStream = requestedPower / energyDensity; Assert.Equal(7.3277470570275129762187468138m, massStream.Value, 10); Assert.Equal("t/h", massStream.Unit.UnitName); var waterDensity = new Density(961.9m, MassUnits.Kg, VolumeUnits.CubicMeter); var volumeStream = massStream / waterDensity; Assert.Equal(7.6179925741007516126611360992m, volumeStream.Value, 10); Assert.Equal("m³/h", volumeStream.Unit.UnitName); //var liquidSpeed = new Velocity(1, LengthUnits.Meter, TimeUnits.Second); var liquidSpeed = Velocity.FromMeterPerSecond(1); Assert.Equal(1, liquidSpeed.Value, 10); Assert.Equal("m/s", liquidSpeed.Unit.UnitName); var pipeArea = volumeStream / liquidSpeed; Assert.Equal(0.0021161090483613198924058713m, pipeArea.Value, 10); Assert.Equal("m²", pipeArea.Unit.UnitName); var diameter = pipeArea.GetCircleDiameter(); Assert.Equal(0.0519067791463266m, diameter.Value, 10); Assert.Equal("m", diameter.Unit.UnitName); diameter = diameter.ConvertTo(LengthUnits.Mm); Assert.Equal(51.9067791463266m, diameter.Value, 10); }