diff --git a/Common/UnitRelations.json b/Common/UnitRelations.json index afd0ab65b6..b2d50f226f 100644 --- a/Common/UnitRelations.json +++ b/Common/UnitRelations.json @@ -1,24 +1,24 @@ [ "1 = Area.SquareMeter * ReciprocalArea.InverseSquareMeter", + "1 = Density.KilogramPerCubicMeter * SpecificVolume.CubicMeterPerKilogram", "1 = ElectricResistivity.OhmMeter * ElectricConductivity.SiemensPerMeter", "1 = Length.Meter * ReciprocalLength.InverseMeter", "Acceleration.MeterPerSecondSquared = Jerk.MeterPerSecondCubed * Duration.Second", - "AmountOfSubstance.Kilomole = MolarFlow.KilomolePerSecond * Duration.Second", + "AmountOfSubstance.Mole = MolarFlow.MolePerSecond * Duration.Second", "AmountOfSubstance.Mole = Molarity.MolePerCubicMeter * Volume.CubicMeter", "Angle.Radian = RotationalSpeed.RadianPerSecond * Duration.Second", - "Area.SquareMeter = KinematicViscosity.SquareMeterPerSecond * Duration.Second", + "Area.SquareMeter = KinematicViscosity.SquareMeterPerSecond * Duration.Second -- NoInferredDivision", "Area.SquareMeter = Length.Meter * Length.Meter", "Area.SquareMeter = Volume.CubicMeter * ReciprocalLength.InverseMeter", "AreaMomentOfInertia.MeterToTheFourth = Volume.CubicMeter * Length.Meter", - "double = Density.KilogramPerCubicMeter * SpecificVolume.CubicMeterPerKilogram", "double = SpecificEnergy.JoulePerKilogram * BrakeSpecificFuelConsumption.KilogramPerJoule", - "double = TemperatureDelta.Kelvin * CoefficientOfThermalExpansion.PerKelvin", "DynamicViscosity.NewtonSecondPerMeterSquared = Density.KilogramPerCubicMeter * KinematicViscosity.SquareMeterPerSecond", "ElectricCharge.AmpereHour = ElectricCurrent.Ampere * Duration.Hour", "ElectricCurrent.Ampere = ElectricCurrentGradient.AmperePerSecond * Duration.Second", "ElectricPotential.Volt = ElectricCurrent.Ampere * ElectricResistance.Ohm", "Energy.Joule = ElectricPotential.Volt * ElectricCharge.Coulomb", "Energy.Joule = EnergyDensity.JoulePerCubicMeter * Volume.CubicMeter", + "Energy.Joule = MolarEnergy.JoulePerMole * AmountOfSubstance.Mole", "Energy.Joule = Power.Watt * Duration.Second", "Energy.Joule = SpecificEnergy.JoulePerKilogram * Mass.Kilogram", "Energy.Joule = TemperatureDelta.Kelvin * Entropy.JoulePerKelvin", @@ -35,8 +35,9 @@ "Length.Meter = Speed.MeterPerSecond * Duration.Second", "Length.Meter = Volume.CubicMeter * ReciprocalArea.InverseSquareMeter", "LinearDensity.KilogramPerMeter = Area.SquareMeter * Density.KilogramPerCubicMeter", + "LuminousFlux.Lumen = Illuminance.Lux * Area.SquareMeter", "LuminousIntensity.Candela = Luminance.CandelaPerSquareMeter * Area.SquareMeter", - "Mass.Gram = AmountOfSubstance.Mole * MolarMass.GramPerMole", + "Mass.Kilogram = AmountOfSubstance.Mole * MolarMass.KilogramPerMole", "Mass.Kilogram = AreaDensity.KilogramPerSquareMeter * Area.SquareMeter", "Mass.Kilogram = Density.KilogramPerCubicMeter * Volume.CubicMeter", "Mass.Kilogram = LinearDensity.KilogramPerMeter * Length.Meter", @@ -62,7 +63,8 @@ "Pressure.NewtonPerSquareMeter = ForcePerLength.NewtonPerMeter * ReciprocalLength.InverseMeter", "Pressure.Pascal = PressureChangeRate.PascalPerSecond * Duration.Second", "Pressure.Pascal = SpecificWeight.NewtonPerCubicMeter * Length.Meter", - "Ratio.DecimalFraction = Area.SquareMeter * ReciprocalArea.InverseSquareMeter", + "Ratio.DecimalFraction = Area.SquareMeter * ReciprocalArea.InverseSquareMeter -- NoInferredDivision", + "Ratio.DecimalFraction = TemperatureDelta.Kelvin * CoefficientOfThermalExpansion.PerKelvin -- NoInferredDivision", "ReciprocalArea.InverseSquareMeter = ReciprocalLength.InverseMeter * ReciprocalLength.InverseMeter", "ReciprocalLength.InverseMeter = Length.Meter * ReciprocalArea.InverseSquareMeter", "RotationalStiffness.NewtonMeterPerRadian = RotationalStiffnessPerLength.NewtonMeterPerRadianPerMeter * Length.Meter", diff --git a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs index a0ee0496fb..5f9cf696f2 100644 --- a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs +++ b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs @@ -66,8 +66,8 @@ public void NumberOfParticlesInTwoMolesIsDoubleAvogadroConstant() [Theory] [InlineData(10, AmountOfSubstanceUnit.Mole, - KnownQuantities.MolarMassOfOxygen, MolarMassUnit.GramPerMole, - 10 * KnownQuantities.MolarMassOfOxygen, MassUnit.Gram)] // 10 Moles of Oxygen weight 10 times as much as 1 Mole of Oxygen (MolarMass) + KnownQuantities.MolarMassOfOxygen, MolarMassUnit.GramPerMole, + 10 * KnownQuantities.MolarMassOfOxygen, MassUnit.Gram)] // 10 Moles of Oxygen weight 10 times as much as 1 Mole of Oxygen (MolarMass) public void MassFromAmountOfSubstanceAndMolarMass( double amountOfSubstanceValue, AmountOfSubstanceUnit amountOfSubstanceUnit, double molarMassValue, MolarMassUnit molarMassUnit, @@ -83,9 +83,9 @@ public void MassFromAmountOfSubstanceAndMolarMass( [Theory] [InlineData(5, MassUnit.Gram, - KnownQuantities.MolarMassHClInGramsPerMole, MolarMassUnit.GramPerMole, - 1.2, VolumeUnit.Liter, - 0.1142805, MolarityUnit.MolePerLiter)] // molarity(HCl) = 5g / (1.2L * 36.46) = 0.114 mol/l = 0.114 M + KnownQuantities.MolarMassHClInGramsPerMole, MolarMassUnit.GramPerMole, + 1.2, VolumeUnit.Liter, + 0.1142805, MolarityUnit.MolePerLiter)] // molarity(HCl) = 5g / (1.2L * 36.46) = 0.114 mol/l = 0.114 M public void MolarityFromComponentMassAndSolutionVolume( double componentMassValue, MassUnit componentMassUnit, double componentMolarMassValue, MolarMassUnit componentMolarMassUnit, @@ -104,9 +104,9 @@ public void MolarityFromComponentMassAndSolutionVolume( [Theory] [InlineData(5, MassUnit.Gram, - KnownQuantities.MolarMassHClInGramsPerMole, MolarMassUnit.GramPerMole, - 0.1142805, MolarityUnit.MolePerLiter, - 1.2, VolumeUnit.Liter)] // 1.2 L of solution required for obtaining 0.1142805 Moles/L from 5g HCl + KnownQuantities.MolarMassHClInGramsPerMole, MolarMassUnit.GramPerMole, + 0.1142805, MolarityUnit.MolePerLiter, + 1.2, VolumeUnit.Liter)] // 1.2 L of solution required for obtaining 0.1142805 Moles/L from 5g HCl public void VolumeSolutionFromComponentMassAndDesiredConcentration( double componentMassValue, MassUnit componentMassUnit, double componentMolarMassValue, MolarMassUnit componentMolarMassUnit, @@ -122,5 +122,38 @@ public void VolumeSolutionFromComponentMassAndDesiredConcentration( AssertEx.EqualTolerance(expectedSolutionVolumeValue, volumeSolution.As(expectedSolutionVolumeUnit), tolerence); } + + [Fact] + public void From_Mass_And_MolarMass_ReturnsTheMassDividedByTheMolarMass() + { + var mass = Mass.From(10, MassUnit.Gram); + var molarMass = MolarMass.From(2, MolarMassUnit.GramPerMole); + var expectedAmountOfSubstance = AmountOfSubstance.From(5, AmountOfSubstanceUnit.Mole); + + var amountOfSubstance = AmountOfSubstance.FromMass(mass, molarMass); + + Assert.Equal(expectedAmountOfSubstance, amountOfSubstance); + } + + [Fact] + public void Multiplying_AmountOfSubstance_By_MolarEnergy_ReturnsEnergy() + { + Energy energy = AmountOfSubstance.FromMoles(5) * MolarEnergy.FromJoulesPerMole(10); + Assert.Equal(Energy.FromJoules(50), energy); + } + + [Fact] + public void Dividing_AmountOfSubstance_By_MolarFlow_Returns_Duration() + { + var duration = AmountOfSubstance.FromMoles(10) / MolarFlow.FromMolesPerSecond(2); + Assert.Equal(Duration.FromSeconds(5), duration); + } + + [Fact] + public void Dividing_AmountOfSubstance_By_Duration_Returns_MolarFlow() + { + MolarFlow molarFlow = AmountOfSubstance.FromMoles(10) / Duration.FromSeconds(5); + Assert.Equal(MolarFlow.FromMolesPerSecond(2), molarFlow); + } } } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 6c0f6a20a2..c4415f8fbc 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -145,5 +145,61 @@ public void AreaTimesReciprocalAreaEqualsRatio() Ratio ratio = Area.FromSquareMeters(0.5) * ReciprocalArea.FromInverseSquareMeters(10); Assert.Equal(5.0, ratio.Value); } + + [Fact] + public void AreaTimesIlluminanceEqualsLuminousFlux() + { + LuminousFlux luminousFlux = Area.FromSquareMeters(5) * Illuminance.FromLux(10); + Assert.Equal(LuminousFlux.FromLumens(50), luminousFlux); + } + + [Fact] + public void AreaTimesLuminanceEqualsLuminousIntensity() + { + LuminousIntensity luminousIntensity = Area.FromSquareMeters(5) * Luminance.FromCandelasPerSquareMeter(10); + Assert.Equal(LuminousIntensity.FromCandela(50), luminousIntensity); + } + + [Fact] + public void AreaTimesSpecificWeightEqualsForcePerLength() + { + ForcePerLength forcePerLength = Area.FromSquareMeters(20) * SpecificWeight.FromNewtonsPerCubicMeter(2000); + Assert.Equal(ForcePerLength.FromNewtonsPerMeter(40000), forcePerLength); + } + + [Fact] + public void AreaTimesReciprocalLengthEqualsLength() + { + Length length = Area.FromSquareMeters(20) * ReciprocalLength.FromInverseMeters(5); + Assert.Equal(Length.FromMeters(100), length); + } + + [Fact] + public void AreaTimesAreaDensityEqualsMass() + { + Mass mass = Area.FromSquareMeters(2) * AreaDensity.FromKilogramsPerSquareMeter(10); + Assert.Equal(Mass.FromKilograms(20), mass); + } + + [Fact] + public void AreaTimesHeatFluxEqualsPower() + { + Power power = Area.FromSquareMeters(2) * HeatFlux.FromWattsPerSquareMeter(10); + Assert.Equal(Power.FromWatts(20), power); + } + + [Fact] + public void AreaTimesForcePerLengthEqualsEqualsTorque() + { + Torque torque = Area.FromSquareMeters(2) * ForcePerLength.FromNewtonsPerMeter(10); + Assert.Equal(Torque.FromNewtonMeters(20), torque); + } + + [Fact] + public void AreaDividedByReciprocalLengthEqualsVolume() + { + Volume volume = Area.FromSquareMeters(20) / ReciprocalLength.FromInverseMeters(5); + Assert.Equal(Volume.FromCubicMeters(4), volume); + } } } diff --git a/UnitsNet.Tests/CustomCode/CoefficientOfThermalExpansionTests.cs b/UnitsNet.Tests/CustomCode/CoefficientOfThermalExpansionTests.cs index 6199c7f658..29008018fa 100644 --- a/UnitsNet.Tests/CustomCode/CoefficientOfThermalExpansionTests.cs +++ b/UnitsNet.Tests/CustomCode/CoefficientOfThermalExpansionTests.cs @@ -44,21 +44,8 @@ public class CoefficientOfThermalExpansionTests : CoefficientOfThermalExpansionT [Fact] public void CoefficientOfThermalExpansionTimesTemperatureDelta() { - double temperatureDeltaDegC = 2.0; - double ctePerDegC = 0.001; - CoefficientOfThermalExpansion cte = CoefficientOfThermalExpansion.FromPerDegreeCelsius(ctePerDegC); - TemperatureDelta dT = TemperatureDelta.FromDegreesCelsius(temperatureDeltaDegC); - AssertEx.EqualTolerance(cte * dT, ctePerDegC * temperatureDeltaDegC, 1e-10); - } - - [Fact] - public void TemperatureDeltaTimesCoefficientOfThermalExpansion() - { - double temperatureDeltaDegC = 2.0; - double ctePerDegC = 0.001; - CoefficientOfThermalExpansion cte = CoefficientOfThermalExpansion.FromPerDegreeCelsius(ctePerDegC); - TemperatureDelta dT = TemperatureDelta.FromDegreesCelsius(temperatureDeltaDegC); - AssertEx.EqualTolerance(dT * cte, temperatureDeltaDegC * ctePerDegC, 1e-10); + Ratio expansionRatio = CoefficientOfThermalExpansion.FromPerDegreeCelsius(2) * TemperatureDelta.FromDegreesCelsius(0.001); + Assert.Equal(Ratio.FromDecimalFractions(0.002), expansionRatio); } } } diff --git a/UnitsNet.Tests/CustomCode/DensityTests.cs b/UnitsNet.Tests/CustomCode/DensityTests.cs index 0d5b42a287..70e562d9c1 100644 --- a/UnitsNet.Tests/CustomCode/DensityTests.cs +++ b/UnitsNet.Tests/CustomCode/DensityTests.cs @@ -162,5 +162,19 @@ public void DensityTimesAreaEqualsLinearDensity() LinearDensity linearDensity = Density.FromGramsPerCubicCentimeter(10) * Area.FromSquareCentimeters(2); Assert.Equal(20, linearDensity.GramsPerCentimeter); } + + [Fact] + public static void DensityTimesVolumeConcentrationEqualsMassConcentration() + { + MassConcentration massConcentration = Density.FromKilogramsPerCubicMeter(20) * VolumeConcentration.FromPercent(50); + Assert.Equal(massConcentration, MassConcentration.FromKilogramsPerCubicMeter(10)); + } + + [Fact] + public static void InverseDensityEqualsSpecificVolume() + { + SpecificVolume specificVolume = Density.FromKilogramsPerCubicMeter(4).Inverse(); + Assert.Equal(specificVolume, SpecificVolume.FromCubicMetersPerKilogram(0.25)); + } } } diff --git a/UnitsNet.Tests/CustomCode/EnergyTests.cs b/UnitsNet.Tests/CustomCode/EnergyTests.cs index 9290cfe003..d917278988 100644 --- a/UnitsNet.Tests/CustomCode/EnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/EnergyTests.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; @@ -191,5 +191,33 @@ public void EnergyDividedBySpecificEnergyEqualsMass() Mass m = Energy.FromJoules(24) / SpecificEnergy.FromJoulesPerKilogram(8); Assert.Equal(Mass.FromKilograms(3), m); } + + [Fact] + public void EnergyDividedByMolarEnergyEqualsAmountOfSubstance() + { + AmountOfSubstance m = Energy.FromJoules(24) / MolarEnergy.FromJoulesPerMole(8); + Assert.Equal(AmountOfSubstance.FromMoles(3), m); + } + + [Fact] + public void EnergyDividedByAmountOfSubstanceEqualsMolarEnergy() + { + MolarEnergy m = Energy.FromJoules(24) / AmountOfSubstance.FromMoles(8); + Assert.Equal(MolarEnergy.FromJoulesPerMole(3), m); + } + + [Fact] + public void EnergyDividedByVolumeEqualsEnergyDensity() + { + EnergyDensity m = Energy.FromJoules(24) / Volume.FromCubicMeters(8); + Assert.Equal(EnergyDensity.FromJoulesPerCubicMeter(3), m); + } + + [Fact] + public void EnergyDividedByEnergyDensityEqualsVolume() + { + Volume m = Energy.FromJoules(24) / EnergyDensity.FromJoulesPerCubicMeter(8); + Assert.Equal(Volume.FromCubicMeters(3), m); + } } } diff --git a/UnitsNet.Tests/CustomCode/IlluminanceTests.cs b/UnitsNet.Tests/CustomCode/IlluminanceTests.cs index b561f238c7..c7b766d740 100644 --- a/UnitsNet.Tests/CustomCode/IlluminanceTests.cs +++ b/UnitsNet.Tests/CustomCode/IlluminanceTests.cs @@ -22,6 +22,7 @@ using System; +using Xunit; namespace UnitsNet.Tests.CustomCode { @@ -35,5 +36,12 @@ public class IlluminanceTests : IlluminanceTestsBase protected override double KiloluxInOneLux => 1E-3; protected override double MegaluxInOneLux => 1E-6; + + [Fact] + public void IlluminanceTimesAreaEqualsLuminousFlux() + { + LuminousFlux luminousFlux = Illuminance.FromLux(10) * Area.FromSquareMeters(5); + Assert.Equal(LuminousFlux.FromLumens(50), luminousFlux); + } } } diff --git a/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs b/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs index b24539f1ed..ee85f8de1a 100644 --- a/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs +++ b/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs @@ -22,6 +22,7 @@ using System; +using Xunit; namespace UnitsNet.Tests.CustomCode { @@ -29,5 +30,27 @@ public class LuminousFluxTests : LuminousFluxTestsBase { protected override bool SupportsSIUnitSystem => false; protected override double LumensInOneLumen => 1; + + [Fact] + public void LuminousFluxDividedByAreaEqualsIlluminance() + { + var luminousFlux = LuminousFlux.FromLumens(100); + var area = Area.FromSquareMeters(10); + + var illuminance = luminousFlux / area; + + Assert.Equal(Illuminance.FromLux(10), illuminance); + } + + [Fact] + public void LuniousFluxDividedByIlluminanceEqualsArea() + { + var luminousFlux = LuminousFlux.FromLumens(100); + var illuminance = Illuminance.FromLux(10); + + var area = luminousFlux / illuminance; + + Assert.Equal(Area.FromSquareMeters(10), area); + } } } diff --git a/UnitsNet.Tests/CustomCode/MassTests.cs b/UnitsNet.Tests/CustomCode/MassTests.cs index 285cb7a6ec..2e5cfd1c5b 100644 --- a/UnitsNet.Tests/CustomCode/MassTests.cs +++ b/UnitsNet.Tests/CustomCode/MassTests.cs @@ -164,5 +164,69 @@ public void AmountOfSubstanceFromMassAndMolarMass( AssertEx.EqualTolerance(expectedAmountOfSubstanceValue, amountOfSubstance.As(expectedAmountOfSubstanceUnit), tolerence); } + + [Theory] + [InlineData(10, MassUnit.Kilogram, + 5, SpecificVolumeUnit.CubicMeterPerKilogram, + 50, VolumeUnit.CubicMeter)] + public void Multiplying_Mass_By_SpecificVolume_ReturnsVolume(double massValue, MassUnit massUnit, double specificVolumeValue, + SpecificVolumeUnit specificVolumeUnit, double expectedVolumeValue, VolumeUnit expectedVolumeUnit) + { + var mass = new Mass(massValue, massUnit); + var specificVolume = new SpecificVolume(specificVolumeValue, specificVolumeUnit); + var expectedVolume = new Volume(expectedVolumeValue, expectedVolumeUnit); + + Volume volume = mass * specificVolume; + + Assert.Equal(expectedVolume, volume); + } + + [Theory] + [InlineData(10, MassUnit.Kilogram, + 5, MassFlowUnit.KilogramPerSecond, + 2, DurationUnit.Second)] + public void Dividing_Mass_By_MassFlow_ReturnsDuration(double massValue, MassUnit massUnit, double massFlowValue, + MassFlowUnit massFlowUnit, double expectedDurationValue, DurationUnit expectedDurationUnit) + { + var mass = new Mass(massValue, massUnit); + var massFlow = new MassFlow(massFlowValue, massFlowUnit); + var expectedDuration = new Duration(expectedDurationValue, expectedDurationUnit); + + Duration duration = mass / massFlow; + + Assert.Equal(expectedDuration, duration); + } + + [Theory] + [InlineData(10, MassUnit.Kilogram, + 5, AmountOfSubstanceUnit.Mole, + 2, MolarMassUnit.KilogramPerMole)] + public void Dividing_Mass_By_AmountOfSubstance_ReturnsMolarMass(double massValue, MassUnit massUnit, double amountOfSubstanceValue, + AmountOfSubstanceUnit amountOfSubstanceUnit, double expectedMolarMassValue, MolarMassUnit expectedMolarMassUnit) + { + var mass = new Mass(massValue, massUnit); + var amountOfSubstance = new AmountOfSubstance(amountOfSubstanceValue, amountOfSubstanceUnit); + var expectedMolarMass = new MolarMass(expectedMolarMassValue, expectedMolarMassUnit); + + MolarMass molarMass = mass / amountOfSubstance; + + Assert.Equal(expectedMolarMass, molarMass); + } + + [Theory] + [InlineData(10, MassUnit.Kilogram, + 5, DensityUnit.KilogramPerCubicMeter, + 2, VolumeUnit.CubicMeter)] + public void Dividing_Mass_By_Density_ReturnsVolume(double massValue, MassUnit massUnit, double densityValue, + DensityUnit densityUnit, double expectedVolumeValue, VolumeUnit expectedVolumeUnit) + { + var mass = new Mass(massValue, massUnit); + var density = new Density(densityValue, densityUnit); + var expectedVolume = new Volume(expectedVolumeValue, expectedVolumeUnit); + + Volume volume = mass / density; + + Assert.Equal(expectedVolume, volume); + } } } diff --git a/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs b/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs index 5b05835c78..332b4f6a3d 100644 --- a/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs @@ -22,6 +22,8 @@ using System; +using UnitsNet.Units; +using Xunit; namespace UnitsNet.Tests.CustomCode { @@ -31,5 +33,21 @@ public class MolarEnergyTests : MolarEnergyTestsBase protected override double JoulesPerMoleInOneJoulePerMole => 1e0; protected override double KilojoulesPerMoleInOneJoulePerMole => 1e-3; protected override double MegajoulesPerMoleInOneJoulePerMole => 1e-6; + + [Theory] + [InlineData(10, MolarEnergyUnit.JoulePerMole, + 5, AmountOfSubstanceUnit.Mole, + 50, EnergyUnit.Joule)] + public void Multiplying_AmountOfSubstance_With_MolarEnergy_ReturnsEnergy(double molarEnergyValue, MolarEnergyUnit molarEnergyUnit, + double amountOfSubstanceValue, AmountOfSubstanceUnit amountOfSubstanceUnit, double expectedEnergyValue, EnergyUnit expectedEnergyUnit) + { + var molarEnergy = new MolarEnergy(molarEnergyValue, molarEnergyUnit); + var amountOfSubstance = new AmountOfSubstance(amountOfSubstanceValue, amountOfSubstanceUnit); + var expectedEnergy = new Energy(expectedEnergyValue, expectedEnergyUnit); + + var energy = molarEnergy * amountOfSubstance; + + Assert.Equal(expectedEnergy, energy); + } } } diff --git a/UnitsNet.Tests/CustomCode/MolarFlowTests.cs b/UnitsNet.Tests/CustomCode/MolarFlowTests.cs index f11828b446..28ceb57aee 100644 --- a/UnitsNet.Tests/CustomCode/MolarFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MolarFlowTests.cs @@ -49,28 +49,28 @@ public class MolarFlowTests : MolarFlowTestsBase [Fact] public void MolarFlowTimesTimeSpanEqualsAmountOfSubstance() { - AmountOfSubstance amount = MolarFlow.FromKilomolesPerSecond(20) * TimeSpan.FromSeconds(2); - Assert.Equal(AmountOfSubstance.FromKilomoles(40), amount); + AmountOfSubstance amount = MolarFlow.FromMolesPerSecond(20) * TimeSpan.FromSeconds(2); + Assert.Equal(AmountOfSubstance.FromMoles(40), amount); } [Fact] public void MolarFlowTimesDurationEqualsAmountOfSubstance() { - AmountOfSubstance amount = MolarFlow.FromKilomolesPerSecond(20) * Duration.FromSeconds(2); - Assert.Equal(AmountOfSubstance.FromKilomoles(40), amount); + AmountOfSubstance amount = MolarFlow.FromMolesPerSecond(20) * Duration.FromSeconds(2); + Assert.Equal(AmountOfSubstance.FromMoles(40), amount); } [Fact] public void MolarFlowTimesMolarMassEqualsMassFlow() { - MassFlow massFlow = MolarFlow.FromKilomolesPerSecond(2) * MolarMass.FromKilogramsPerKilomole(3); + MassFlow massFlow = MolarFlow.FromMolesPerSecond(2) * MolarMass.FromKilogramsPerMole(3); Assert.Equal(MassFlow.FromKilogramsPerSecond(6), massFlow); } [Fact] public void MolarFlowOverMolarityEqualsVolumeFlow() { - VolumeFlow volumeFlow = MolarFlow.FromKilomolesPerSecond(6) / Molarity.FromKilomolesPerCubicMeter(3); + VolumeFlow volumeFlow = MolarFlow.FromMolesPerSecond(6) / Molarity.FromMolesPerCubicMeter(3); Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(2), volumeFlow); } diff --git a/UnitsNet.Tests/CustomCode/MolarMassTests.cs b/UnitsNet.Tests/CustomCode/MolarMassTests.cs index 264350bee0..e48321fd36 100644 --- a/UnitsNet.Tests/CustomCode/MolarMassTests.cs +++ b/UnitsNet.Tests/CustomCode/MolarMassTests.cs @@ -43,5 +43,26 @@ public class MolarMassTests : MolarMassTestsBase protected override double NanogramsPerMoleInOneKilogramPerMole => 1e12; protected override double PoundsPerMoleInOneKilogramPerMole => 2.2046226218487757; protected override double KilogramsPerKilomoleInOneKilogramPerMole => 1e3; + + [Fact] + public void MolarMassTimesAmountOfSubstanceEqualsMass() + { + Mass mass = MolarMass.FromKilogramsPerMole(2) * AmountOfSubstance.FromMoles(5); + Assert.Equal(Mass.FromKilograms(10), mass); + } + + [Fact] + public void MolarMassTimesMolarityEqualsMassConcentration() + { + MassConcentration massConcentration = MolarMass.FromKilogramsPerMole(2) * Molarity.FromMolesPerCubicMeter(5); + Assert.Equal(MassConcentration.FromKilogramsPerCubicMeter(10), massConcentration); + } + + [Fact] + public void MolarMassTimesMolarFlowEqualsMassFlow() + { + MassFlow massFlow = MolarMass.FromKilogramsPerMole(2) * MolarFlow.FromMolesPerSecond(5); + Assert.Equal(MassFlow.FromKilogramsPerSecond(10), massFlow); + } } } diff --git a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs index 11fd0a396d..13f2b57dfc 100644 --- a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs @@ -41,9 +41,9 @@ public static void SpecificVolumeTimesMassEqualsVolume() } [Fact] - public static void ConstantOverSpecificVolumeEqualsDensity() + public static void InverseSpecificVolumeEqualsDensity() { - Density density = 5 / SpecificVolume.FromCubicMetersPerKilogram(20); + Density density = SpecificVolume.FromCubicMetersPerKilogram(4).Inverse(); Assert.Equal(density, Density.FromKilogramsPerCubicMeter(0.25)); } } diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs index abf2d33e35..8171557dbe 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs @@ -65,6 +65,13 @@ public void TemperatureDeltaTimesEntropyEqualsEnergy() Assert.Equal(Energy.FromJoules(80), energy); } + [Fact] + public void TemperatureDeltaTimesCoefficientOfThermalExpansionEqualsRatio() + { + Ratio expansionRatio = TemperatureDelta.FromDegreesCelsius(0.001) * CoefficientOfThermalExpansion.FromPerDegreeCelsius(2); + Assert.Equal(Ratio.FromDecimalFractions(0.002), expansionRatio); + } + [Fact] public void TemperatureDeltaDividedByTimeSpanEqualsTemperatureChangeRate() { @@ -78,5 +85,12 @@ public void TemperatureDeltaDividedByDurationEqualsTemperatureChangeRate() TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / Duration.FromSeconds(2); Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); } + + [Fact] + public void TemperatureDeltaDividedByTemperatureChangeRateEqualsDuration() + { + Duration duration = TemperatureDelta.FromKelvins(20) / TemperatureChangeRate.FromDegreesCelsiusPerSecond(10); + Assert.Equal(Duration.FromSeconds(2), duration); + } } } diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs index cb1d4ceea6..35eccba87b 100644 --- a/UnitsNet.Tests/CustomCode/VolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; using Xunit; namespace UnitsNet.Tests @@ -154,5 +155,21 @@ public void VolumeDividedByVolumeFlowEqualsTimeSpan() Duration duration = Volume.FromCubicMeters(20) / VolumeFlow.FromCubicMetersPerSecond(2); Assert.Equal(Duration.FromSeconds(10), duration); } + + [Theory] + [InlineData(50, VolumeUnit.CubicMeter, + 5, SpecificVolumeUnit.CubicMeterPerKilogram, + 10, MassUnit.Kilogram)] + public void Dividing_Volume_By_SpecificVolume_ReturnsMass(double volumeValue, VolumeUnit volumeUnit, double specificVolumeValue, + SpecificVolumeUnit specificVolumeUnit, double expectedMassValue, MassUnit expectedMassUnit) + { + var mass = new Mass(expectedMassValue, expectedMassUnit); + var specificVolume = new SpecificVolume(specificVolumeValue, specificVolumeUnit); + var expectedVolume = new Volume(volumeValue, volumeUnit); + + Mass massFromVolume = expectedVolume / specificVolume; + + Assert.Equal(mass, massFromVolume); + } } } diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 18acb1bddd..1b101837a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -45,6 +45,7 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IDivisionOperators, + IMultiplyOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, @@ -700,19 +701,25 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from / . public static Duration operator /(AmountOfSubstance amountOfSubstance, MolarFlow molarFlow) { - return Duration.FromSeconds(amountOfSubstance.Kilomoles / molarFlow.KilomolesPerSecond); + return Duration.FromSeconds(amountOfSubstance.Moles / molarFlow.MolesPerSecond); + } + + /// Get from * . + public static Energy operator *(AmountOfSubstance amountOfSubstance, MolarEnergy molarEnergy) + { + return Energy.FromJoules(amountOfSubstance.Moles * molarEnergy.JoulesPerMole); } /// Get from * . public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass) { - return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); + return Mass.FromKilograms(amountOfSubstance.Moles * molarMass.KilogramsPerMole); } /// Get from / . public static MolarFlow operator /(AmountOfSubstance amountOfSubstance, Duration duration) { - return MolarFlow.FromKilomolesPerSecond(amountOfSubstance.Kilomoles / duration.Seconds); + return MolarFlow.FromMolesPerSecond(amountOfSubstance.Moles / duration.Seconds); } /// Get from / . diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 478beca76e..e7b0ee9df6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -44,13 +44,12 @@ namespace UnitsNet public readonly partial struct Area : IArithmeticQuantity, #if NET7_0_OR_GREATER - IDivisionOperators, IMultiplyOperators, IMultiplyOperators, - IDivisionOperators, IMultiplyOperators, IDivisionOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, @@ -668,12 +667,6 @@ public ReciprocalArea Inverse() return SquareMeters == 0.0 ? ReciprocalArea.Zero : ReciprocalArea.FromInverseSquareMeters(1 / SquareMeters); } - /// Get from / . - public static Duration operator /(Area area, KinematicViscosity kinematicViscosity) - { - return Duration.FromSeconds(area.SquareMeters / kinematicViscosity.SquareMetersPerSecond); - } - /// Get from * . public static Force operator *(Area area, Pressure pressure) { @@ -686,12 +679,6 @@ public ReciprocalArea Inverse() return ForcePerLength.FromNewtonsPerMeter(area.SquareMeters * specificWeight.NewtonsPerCubicMeter); } - /// Get from / . - public static KinematicViscosity operator /(Area area, Duration duration) - { - return KinematicViscosity.FromSquareMetersPerSecond(area.SquareMeters / duration.Seconds); - } - /// Get from * . public static Length operator *(Area area, ReciprocalLength reciprocalLength) { @@ -710,6 +697,12 @@ public ReciprocalArea Inverse() return LinearDensity.FromKilogramsPerMeter(area.SquareMeters * density.KilogramsPerCubicMeter); } + /// Get from * . + public static LuminousFlux operator *(Area area, Illuminance illuminance) + { + return LuminousFlux.FromLumens(area.SquareMeters * illuminance.Lux); + } + /// Get from * . public static LuminousIntensity operator *(Area area, Luminance luminance) { diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 8d37760e9b..b2c2c230e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -44,7 +44,7 @@ namespace UnitsNet public readonly partial struct CoefficientOfThermalExpansion : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -517,16 +517,10 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #region Relational Operators - /// Get from / . - public static TemperatureDelta operator /(double value, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + /// Get from * . + public static Ratio operator *(CoefficientOfThermalExpansion coefficientOfThermalExpansion, TemperatureDelta temperatureDelta) { - return TemperatureDelta.FromKelvins(value / coefficientOfThermalExpansion.PerKelvin); - } - - /// Get from * . - public static double operator *(CoefficientOfThermalExpansion coefficientOfThermalExpansion, TemperatureDelta temperatureDelta) - { - return coefficientOfThermalExpansion.PerKelvin * temperatureDelta.Kelvins; + return Ratio.FromDecimalFractions(coefficientOfThermalExpansion.PerKelvin * temperatureDelta.Kelvins); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index c79a3fa833..a20873495a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -54,7 +54,6 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -1327,6 +1326,13 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #region Relational Operators + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public SpecificVolume Inverse() + { + return KilogramsPerCubicMeter == 0.0 ? SpecificVolume.Zero : SpecificVolume.FromCubicMetersPerKilogram(1 / KilogramsPerCubicMeter); + } + /// Get from * . public static DynamicViscosity operator *(Density density, KinematicViscosity kinematicViscosity) { @@ -1363,24 +1369,12 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); } - /// Get from / . - public static SpecificVolume operator /(double value, Density density) - { - return SpecificVolume.FromCubicMetersPerKilogram(value / density.KilogramsPerCubicMeter); - } - /// Get from * . public static SpecificWeight operator *(Density density, Acceleration acceleration) { return SpecificWeight.FromNewtonsPerCubicMeter(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared); } - /// Get from * . - public static double operator *(Density density, SpecificVolume specificVolume) - { - return density.KilogramsPerCubicMeter * specificVolume.CubicMetersPerKilogram; - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index e565614d52..5ff36bbeeb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -635,7 +635,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from * . public static AmountOfSubstance operator *(Duration duration, MolarFlow molarFlow) { - return AmountOfSubstance.FromKilomoles(duration.Seconds * molarFlow.KilomolesPerSecond); + return AmountOfSubstance.FromMoles(duration.Seconds * molarFlow.MolesPerSecond); } /// Get from * . diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index d7daf39f9e..a2cb8f7372 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -44,12 +44,14 @@ namespace UnitsNet public readonly partial struct Energy : IArithmeticQuantity, #if NET7_0_OR_GREATER + IDivisionOperators, IDivisionOperators, IDivisionOperators, IDivisionOperators, IDivisionOperators, IDivisionOperators, IDivisionOperators, + IDivisionOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, @@ -1071,6 +1073,12 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #region Relational Operators + /// Get from / . + public static AmountOfSubstance operator /(Energy energy, MolarEnergy molarEnergy) + { + return AmountOfSubstance.FromMoles(energy.Joules / molarEnergy.JoulesPerMole); + } + /// Get from / . public static Duration operator /(Energy energy, Power power) { @@ -1107,6 +1115,12 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? return Mass.FromKilograms(energy.Joules / specificEnergy.JoulesPerKilogram); } + /// Get from / . + public static MolarEnergy operator /(Energy energy, AmountOfSubstance amountOfSubstance) + { + return MolarEnergy.FromJoulesPerMole(energy.Joules / amountOfSubstance.Moles); + } + /// Get from * . public static Power operator *(Energy energy, Frequency frequency) { diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 4316c922a2..09edee1cb6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -22,6 +22,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -43,6 +46,9 @@ namespace UnitsNet [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct Illuminance : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -480,6 +486,16 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #endregion + #region Relational Operators + + /// Get from * . + public static LuminousFlux operator *(Illuminance illuminance, Area area) + { + return LuminousFlux.FromLumens(illuminance.Lux * area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index fbee22f23e..6aa738b0f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -22,6 +22,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -43,6 +46,10 @@ namespace UnitsNet [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct LuminousFlux : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -432,6 +439,22 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(LuminousFlux luminousFlux, Illuminance illuminance) + { + return Area.FromSquareMeters(luminousFlux.Lumens / illuminance.Lux); + } + + /// Get from / . + public static Illuminance operator /(LuminousFlux luminousFlux, Area area) + { + return Illuminance.FromLux(luminousFlux.Lumens / area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 2ab58cdc87..18b1116dc8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -871,7 +871,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from / . public static AmountOfSubstance operator /(Mass mass, MolarMass molarMass) { - return AmountOfSubstance.FromMoles(mass.Grams / molarMass.GramsPerMole); + return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); } /// Get from / . @@ -949,7 +949,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from / . public static MolarMass operator /(Mass mass, AmountOfSubstance amountOfSubstance) { - return MolarMass.FromGramsPerMole(mass.Grams / amountOfSubstance.Moles); + return MolarMass.FromKilogramsPerMole(mass.Kilograms / amountOfSubstance.Moles); } /// Get from * . diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index a65136b21e..c552d0cccc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -22,6 +22,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -40,6 +43,9 @@ namespace UnitsNet [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct MolarEnergy : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -461,6 +467,16 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #endregion + #region Relational Operators + + /// Get from * . + public static Energy operator *(MolarEnergy molarEnergy, AmountOfSubstance amountOfSubstance) + { + return Energy.FromJoules(molarEnergy.JoulesPerMole * amountOfSubstance.Moles); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 5e681b772d..0d7c9a833d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -571,7 +571,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from * . public static AmountOfSubstance operator *(MolarFlow molarFlow, Duration duration) { - return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * duration.Seconds); + return AmountOfSubstance.FromMoles(molarFlow.MolesPerSecond * duration.Seconds); } /// Get from * . diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 107abbcb86..f002be06ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -634,7 +634,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? /// Get from * . public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) { - return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); + return Mass.FromKilograms(molarMass.KilogramsPerMole * amountOfSubstance.Moles); } /// Get from * . diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index dad3083376..abccc95c05 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -22,9 +22,6 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -43,10 +40,6 @@ namespace UnitsNet [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct Ratio : IArithmeticQuantity, -#if NET7_0_OR_GREATER - IDivisionOperators, - IDivisionOperators, -#endif IComparable, IComparable, IConvertible, @@ -516,22 +509,6 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #endregion - #region Relational Operators - - /// Get from / . - public static Area operator /(Ratio ratio, ReciprocalArea reciprocalArea) - { - return Area.FromSquareMeters(ratio.DecimalFractions / reciprocalArea.InverseSquareMeters); - } - - /// Get from / . - public static ReciprocalArea operator /(Ratio ratio, Area area) - { - return ReciprocalArea.FromInverseSquareMeters(ratio.DecimalFractions / area.SquareMeters); - } - - #endregion - #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 9c8b2e6dd0..f7d867ab49 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -45,7 +45,6 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -470,10 +469,11 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #region Relational Operators - /// Get from / . - public static Density operator /(double value, SpecificVolume specificVolume) + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public Density Inverse() { - return Density.FromKilogramsPerCubicMeter(value / specificVolume.CubicMetersPerKilogram); + return CubicMetersPerKilogram == 0.0 ? Density.Zero : Density.FromKilogramsPerCubicMeter(1 / CubicMetersPerKilogram); } /// Get from * . @@ -482,12 +482,6 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? return Volume.FromCubicMeters(specificVolume.CubicMetersPerKilogram * mass.Kilograms); } - /// Get from * . - public static double operator *(SpecificVolume specificVolume, Density density) - { - return specificVolume.CubicMetersPerKilogram * density.KilogramsPerCubicMeter; - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 189706f7c6..a3c9b391ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -47,10 +47,10 @@ namespace UnitsNet IDivisionOperators, IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -571,12 +571,6 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? #region Relational Operators - /// Get from / . - public static CoefficientOfThermalExpansion operator /(double value, TemperatureDelta temperatureDelta) - { - return CoefficientOfThermalExpansion.FromPerKelvin(value / temperatureDelta.Kelvins); - } - /// Get from / . public static Duration operator /(TemperatureDelta temperatureDelta, TemperatureChangeRate temperatureChangeRate) { @@ -595,6 +589,12 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? return Length.FromKilometers(temperatureDelta.DegreesCelsius / temperatureGradient.DegreesCelsiusPerKilometer); } + /// Get from * . + public static Ratio operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + { + return Ratio.FromDecimalFractions(temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin); + } + /// Get from * . public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy) { @@ -613,12 +613,6 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? return TemperatureGradient.FromDegreesCelsiusPerKilometer(temperatureDelta.DegreesCelsius / length.Kilometers); } - /// Get from * . - public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) - { - return temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin; - } - #endregion #region Equality / IComparable