Skip to content

Commit 42205dc

Browse files
authored
Add pound per pound-mole molar mass (#1703)
## Motivation Fixes #1668. `PoundPerMole` currently means pound mass per SI mole, `lb/mol`. That is a valid unit and I don't think we should silently redefine it. The issue is that engineering and manufacturing users often need molecular weight in English Engineering units, where the common unit is pound mass per pound-mole, `lb/lbmol`. That should be numerically equal to `kg/kmol`, but it is not the same as `lb/mol`. ## Changes - Add `MolarMassUnit.PoundPerPoundMole` with `lb/lbmol` and `lbm/lbmol` abbreviations. - Use `Pound` and the existing `PoundMole` amount-of-substance unit as base units. - Keep `PoundPerMole` unchanged, but document that it means pound mass per SI mole. - Regenerate UnitsNet and number-extension APIs. - Add tests showing `lb/lbmol` matches `kg/kmol` and remains distinct from `lb/mol`. ## Validation - `generate-code.bat` - `dotnet test UnitsNet.Tests --filter "FullyQualifiedName~UnitsNet.Tests.CustomCode.MolarMassTests"`
1 parent 29feec4 commit 42205dc

12 files changed

Lines changed: 130 additions & 2 deletions

File tree

Common/UnitDefinitions/MolarMass.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
{
4848
"SingularName": "PoundPerMole",
4949
"PluralName": "PoundsPerMole",
50+
"XmlDocSummary": "Pound mass per SI mole. This is distinct from PoundPerPoundMole, where the denominator is the pound-mole amount of substance unit.",
5051
"BaseUnits": {
5152
"M": "Pound",
5253
"N": "Mole"
@@ -64,6 +65,24 @@
6465
"Abbreviations": [ "фунт/моль" ]
6566
}
6667
]
68+
},
69+
{
70+
"SingularName": "PoundPerPoundMole",
71+
"PluralName": "PoundsPerPoundMole",
72+
"XmlDocSummary": "Pound mass per pound-mole. This is numerically equal to kilograms per kilomole and distinct from PoundPerMole, where the denominator is the SI mole.",
73+
"XmlDocRemarks": "Sources: https://www.engineeringtoolbox.com/molecular-weight-gas-vapor-d_1156.html, https://www.engineeringtoolbox.com/unit-converter-d_185.html",
74+
"BaseUnits": {
75+
"M": "Pound",
76+
"N": "PoundMole"
77+
},
78+
"FromUnitToBaseFunc": "{x} / 1e3",
79+
"FromBaseToUnitFunc": "{x} * 1e3",
80+
"Localization": [
81+
{
82+
"Culture": "en-US",
83+
"Abbreviations": [ "lb/lbmol", "lbm/lbmol" ]
84+
}
85+
]
6786
}
6887
]
6988
}

Common/UnitEnumValues.g.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@
10551055
"NanogramPerMole": 11,
10561056
"PoundPerMole": 12,
10571057
"KiloGramPerKiloMole": 20,
1058-
"KilogramPerKilomole": 15
1058+
"KilogramPerKilomole": 15,
1059+
"PoundPerPoundMole": 24
10591060
},
10601061
"Permeability": {
10611062
"HenryPerMeter": 1

UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToMolarMassExtensions.g.cs

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/CustomCode/MolarMassTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,32 @@ public class MolarMassTests : MolarMassTestsBase
4141
protected override double NanogramsPerMoleTolerance => 1e-3;
4242
protected override double NanogramsPerMoleInOneKilogramPerMole => 1e12;
4343
protected override double PoundsPerMoleInOneKilogramPerMole => 2.2046226218487757;
44+
protected override double PoundsPerPoundMoleInOneKilogramPerMole => 1e3;
4445
protected override double KilogramsPerKilomoleInOneKilogramPerMole => 1e3;
4546

47+
[Fact]
48+
public void PoundPerPoundMoleMatchesKilogramPerKilomole()
49+
{
50+
// Engineering Toolbox lists air molecular weight as 28.966 in kg/kmol, g/mol, and lb/lbmol.
51+
const double airMolecularWeight = 28.966;
52+
53+
MolarMass molarMass = MolarMass.FromPoundsPerPoundMole(airMolecularWeight);
54+
55+
Assert.Equal(airMolecularWeight, molarMass.KilogramsPerKilomole, precision: 12);
56+
}
57+
58+
[Fact]
59+
public void PoundPerPoundMoleIsDistinctFromPoundPerMole()
60+
{
61+
const double value = 1;
62+
63+
MolarMass poundPerPoundMole = MolarMass.FromPoundsPerPoundMole(value);
64+
MolarMass poundPerMole = MolarMass.FromPoundsPerMole(value);
65+
66+
Assert.Equal(value, poundPerPoundMole.KilogramsPerKilomole, precision: 12);
67+
Assert.True(poundPerMole.KilogramsPerKilomole > poundPerPoundMole.KilogramsPerKilomole);
68+
}
69+
4670
[Fact]
4771
public void MolarMassTimesAmountOfSubstanceEqualsMass()
4872
{

UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)