diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json
index 1049797d99..c82cac206c 100644
--- a/Common/UnitDefinitions/Mass.json
+++ b/Common/UnitDefinitions/Mass.json
@@ -165,6 +165,20 @@
"Abbreviations": [ "cwt" ]
}
]
+ },
+ {
+ "SingularName": "Grain",
+ "PluralName": "Grains",
+ "FromUnitToBaseFunc": "x/15432.358352941431",
+ "FromBaseToUnitFunc": "x*15432.358352941431",
+ "XmlDocSummary": "A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams.",
+ "XmlDocRemarks": "https://en.wikipedia.org/wiki/Grain_(unit)",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "gr" ]
+ }
+ ]
}
]
}
diff --git a/Common/UnitDefinitions/SpecificEnergy.json b/Common/UnitDefinitions/SpecificEnergy.json
index 9f945ea618..8c706f0b83 100644
--- a/Common/UnitDefinitions/SpecificEnergy.json
+++ b/Common/UnitDefinitions/SpecificEnergy.json
@@ -46,6 +46,18 @@
"Abbreviations": [ "Wh/kg" ]
}
]
+ },
+ {
+ "SingularName": "BtuPerPound",
+ "PluralName": "BtuPerPound",
+ "FromUnitToBaseFunc": "x*2326.000075362",
+ "FromBaseToUnitFunc": "x/2326.000075362",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "btu/lb" ]
+ }
+ ]
}
]
diff --git a/UnitsNet.Tests/CustomCode/MassTests.cs b/UnitsNet.Tests/CustomCode/MassTests.cs
index 6b0a9b70ed..167042a35c 100644
--- a/UnitsNet.Tests/CustomCode/MassTests.cs
+++ b/UnitsNet.Tests/CustomCode/MassTests.cs
@@ -33,6 +33,8 @@ public class MassTests : MassTestsBase
protected override double DecigramsInOneKilogram => 1E4;
+ protected override double GrainsInOneKilogram => 15432.358352941431d;
+
protected override double GramsInOneKilogram => 1E3;
protected override double HectogramsInOneKilogram => 10;
diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
index d8d719a48d..dd8bce3d7e 100644
--- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
@@ -28,6 +28,7 @@ public class SpecificEnergyTests : SpecificEnergyTestsBase
protected override double JoulesPerKilogramInOneJoulePerKilogram => 1e0;
protected override double KilojoulesPerKilogramInOneJoulePerKilogram => 1e-3;
protected override double MegajoulesPerKilogramInOneJoulePerKilogram => 1e-6;
+ protected override double BtuPerPoundInOneJoulePerKilogram => 4.299226e-4;
protected override double CaloriesPerGramInOneJoulePerKilogram => 2.3900573613766730401529636711281e-4;
protected override double KilocaloriesPerGramInOneJoulePerKilogram => 2.3900573613766730401529636711281e-7;
protected override double WattHoursPerKilogramInOneJoulePerKilogram => 2.77777778e-4;
@@ -69,4 +70,4 @@ public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy()
Assert.Equal(200d, value);
}
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs
index f6b75df0f3..6151a5f747 100644
--- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs
+++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs
@@ -176,6 +176,11 @@ private Mass(double numericValue, MassUnit unit)
///
public double Decigrams => As(MassUnit.Decigram);
+ ///
+ /// Get Mass in Grains.
+ ///
+ public double Grains => As(MassUnit.Grain);
+
///
/// Get Mass in Grams.
///
@@ -332,6 +337,16 @@ public static Mass FromDecigrams(double decigrams)
return new Mass(value, MassUnit.Decigram);
}
///
+ /// Get Mass from Grains.
+ ///
+ /// If value is NaN or Infinity.
+ [Windows.Foundation.Metadata.DefaultOverload]
+ public static Mass FromGrains(double grains)
+ {
+ double value = (double) grains;
+ return new Mass(value, MassUnit.Grain);
+ }
+ ///
/// Get Mass from Grams.
///
/// If value is NaN or Infinity.
@@ -813,6 +828,7 @@ private double AsBaseUnit()
case MassUnit.Centigram: return (_value/1e3) * 1e-2d;
case MassUnit.Decagram: return (_value/1e3) * 1e1d;
case MassUnit.Decigram: return (_value/1e3) * 1e-1d;
+ case MassUnit.Grain: return _value/15432.358352941431;
case MassUnit.Gram: return _value/1e3;
case MassUnit.Hectogram: return (_value/1e3) * 1e2d;
case MassUnit.Kilogram: return (_value/1e3) * 1e3d;
@@ -849,6 +865,7 @@ private double AsBaseNumericType(MassUnit unit)
case MassUnit.Centigram: return (baseUnitValue*1e3) / 1e-2d;
case MassUnit.Decagram: return (baseUnitValue*1e3) / 1e1d;
case MassUnit.Decigram: return (baseUnitValue*1e3) / 1e-1d;
+ case MassUnit.Grain: return baseUnitValue*15432.358352941431;
case MassUnit.Gram: return baseUnitValue*1e3;
case MassUnit.Hectogram: return (baseUnitValue*1e3) / 1e2d;
case MassUnit.Kilogram: return (baseUnitValue*1e3) / 1e3d;
diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs
index 54b8293db5..734fa9e4ca 100644
--- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs
+++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs
@@ -164,6 +164,11 @@ private SpecificEnergy(double numericValue, SpecificEnergyUnit unit)
#region Conversion Properties
+ ///
+ /// Get SpecificEnergy in BtuPerPound.
+ ///
+ public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound);
+
///
/// Get SpecificEnergy in CaloriesPerGram.
///
@@ -234,6 +239,16 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, [CanBeNull] string
#region Static Factory Methods
+ ///
+ /// Get SpecificEnergy from BtuPerPound.
+ ///
+ /// If value is NaN or Infinity.
+ [Windows.Foundation.Metadata.DefaultOverload]
+ public static SpecificEnergy FromBtuPerPound(double btuperpound)
+ {
+ double value = (double) btuperpound;
+ return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound);
+ }
///
/// Get SpecificEnergy from CaloriesPerGram.
///
@@ -603,6 +618,7 @@ private double AsBaseUnit()
{
switch(Unit)
{
+ case SpecificEnergyUnit.BtuPerPound: return _value*2326.000075362;
case SpecificEnergyUnit.CaloriePerGram: return _value*4.184e3;
case SpecificEnergyUnit.JoulePerKilogram: return _value;
case SpecificEnergyUnit.KilocaloriePerGram: return (_value*4.184e3) * 1e3d;
@@ -625,6 +641,7 @@ private double AsBaseNumericType(SpecificEnergyUnit unit)
switch(unit)
{
+ case SpecificEnergyUnit.BtuPerPound: return baseUnitValue/2326.000075362;
case SpecificEnergyUnit.CaloriePerGram: return baseUnitValue/4.184e3;
case SpecificEnergyUnit.JoulePerKilogram: return baseUnitValue;
case SpecificEnergyUnit.KilocaloriePerGram: return (baseUnitValue/4.184e3) / 1e3d;
diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs
index f68c7a731b..eae1d5a933 100644
--- a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs
@@ -162,6 +162,11 @@ public Mass(double numericValue, MassUnit unit)
///
public double Decigrams => As(MassUnit.Decigram);
+ ///
+ /// Get Mass in Grains.
+ ///
+ public double Grains => As(MassUnit.Grain);
+
///
/// Get Mass in Grams.
///
@@ -314,6 +319,15 @@ public static Mass FromDecigrams(QuantityValue decigrams)
return new Mass(value, MassUnit.Decigram);
}
///
+ /// Get Mass from Grains.
+ ///
+ /// If value is NaN or Infinity.
+ public static Mass FromGrains(QuantityValue grains)
+ {
+ double value = (double) grains;
+ return new Mass(value, MassUnit.Grain);
+ }
+ ///
/// Get Mass from Grams.
///
/// If value is NaN or Infinity.
@@ -838,6 +852,7 @@ private double AsBaseUnit()
case MassUnit.Centigram: return (_value/1e3) * 1e-2d;
case MassUnit.Decagram: return (_value/1e3) * 1e1d;
case MassUnit.Decigram: return (_value/1e3) * 1e-1d;
+ case MassUnit.Grain: return _value/15432.358352941431;
case MassUnit.Gram: return _value/1e3;
case MassUnit.Hectogram: return (_value/1e3) * 1e2d;
case MassUnit.Kilogram: return (_value/1e3) * 1e3d;
@@ -874,6 +889,7 @@ private double AsBaseNumericType(MassUnit unit)
case MassUnit.Centigram: return (baseUnitValue*1e3) / 1e-2d;
case MassUnit.Decagram: return (baseUnitValue*1e3) / 1e1d;
case MassUnit.Decigram: return (baseUnitValue*1e3) / 1e-1d;
+ case MassUnit.Grain: return baseUnitValue*15432.358352941431;
case MassUnit.Gram: return baseUnitValue*1e3;
case MassUnit.Hectogram: return (baseUnitValue*1e3) / 1e2d;
case MassUnit.Kilogram: return (baseUnitValue*1e3) / 1e3d;
diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs
index d72c3d329b..11422766f9 100644
--- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs
@@ -150,6 +150,11 @@ public SpecificEnergy(double numericValue, SpecificEnergyUnit unit)
#region Conversion Properties
+ ///
+ /// Get SpecificEnergy in BtuPerPound.
+ ///
+ public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound);
+
///
/// Get SpecificEnergy in CaloriesPerGram.
///
@@ -219,6 +224,15 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, [CanBeNull] IForma
#region Static Factory Methods
+ ///
+ /// Get SpecificEnergy from BtuPerPound.
+ ///
+ /// If value is NaN or Infinity.
+ public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound)
+ {
+ double value = (double) btuperpound;
+ return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound);
+ }
///
/// Get SpecificEnergy from CaloriesPerGram.
///
@@ -642,6 +656,7 @@ private double AsBaseUnit()
{
switch(Unit)
{
+ case SpecificEnergyUnit.BtuPerPound: return _value*2326.000075362;
case SpecificEnergyUnit.CaloriePerGram: return _value*4.184e3;
case SpecificEnergyUnit.JoulePerKilogram: return _value;
case SpecificEnergyUnit.KilocaloriePerGram: return (_value*4.184e3) * 1e3d;
@@ -664,6 +679,7 @@ private double AsBaseNumericType(SpecificEnergyUnit unit)
switch(unit)
{
+ case SpecificEnergyUnit.BtuPerPound: return baseUnitValue/2326.000075362;
case SpecificEnergyUnit.CaloriePerGram: return baseUnitValue/4.184e3;
case SpecificEnergyUnit.JoulePerKilogram: return baseUnitValue;
case SpecificEnergyUnit.KilocaloriePerGram: return (baseUnitValue/4.184e3) / 1e3d;
diff --git a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
index bdaca92df2..5669c11540 100644
--- a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
+++ b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
@@ -521,6 +521,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
("ru-RU", typeof(MassUnit), (int)MassUnit.Decagram, new string[]{"даг"}),
("en-US", typeof(MassUnit), (int)MassUnit.Decigram, new string[]{"dg"}),
("ru-RU", typeof(MassUnit), (int)MassUnit.Decigram, new string[]{"дг"}),
+ ("en-US", typeof(MassUnit), (int)MassUnit.Grain, new string[]{"gr"}),
("en-US", typeof(MassUnit), (int)MassUnit.Gram, new string[]{"g"}),
("ru-RU", typeof(MassUnit), (int)MassUnit.Gram, new string[]{"г"}),
("en-US", typeof(MassUnit), (int)MassUnit.Hectogram, new string[]{"hg"}),
@@ -835,6 +836,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, new string[]{"MN·m/rad/m"}),
("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, new string[]{"N·m/rad/m", "Nm/rad/m"}),
("en-US", typeof(SolidAngleUnit), (int)SolidAngleUnit.Steradian, new string[]{"sr"}),
+ ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.BtuPerPound, new string[]{"btu/lb"}),
("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.CaloriePerGram, new string[]{"cal/g"}),
("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.JoulePerKilogram, new string[]{"J/kg"}),
("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilocaloriePerGram, new string[]{"kcal/g"}),
diff --git a/UnitsNet/GeneratedCode/Units/MassUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassUnit.g.cs
index 8fb2ebc11f..2aac301b31 100644
--- a/UnitsNet/GeneratedCode/Units/MassUnit.g.cs
+++ b/UnitsNet/GeneratedCode/Units/MassUnit.g.cs
@@ -47,6 +47,12 @@ public enum MassUnit
Centigram,
Decagram,
Decigram,
+
+ ///
+ /// A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams.
+ ///
+ /// https://en.wikipedia.org/wiki/Grain_(unit)
+ Grain,
Gram,
Hectogram,
Kilogram,
diff --git a/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs
index 9879456b83..92492d143c 100644
--- a/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs
+++ b/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs
@@ -44,6 +44,7 @@ namespace UnitsNet.Units
public enum SpecificEnergyUnit
{
Undefined = 0,
+ BtuPerPound,
CaloriePerGram,
JoulePerKilogram,
KilocaloriePerGram,