Skip to content

Add density units #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 176 additions & 0 deletions Common/UnitDefinitions/Density.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,182 @@
"Abbreviations": [ "kg/l" ]
}
]
},
{
"SingularName": "TonnePerCubicFoot",
"PluralName": "TonnesPerCubicFoot",
"BaseUnits": {
"L": "Foot",
"M": "Tonne"
},
"FromUnitToBaseFunc": "x*3.53146667214886e4",
"FromBaseToUnitFunc": "x/3.53146667214886e4",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "t/ft³" ]
}
]
},
{
"SingularName": "TonnePerCubicInch",
"PluralName": "TonnesPerCubicInch",
"BaseUnits": {
"L": "Inch",
"M": "Tonne"
},
"FromUnitToBaseFunc": "x*6.10237440947323e7",
"FromBaseToUnitFunc": "x/6.10237440947323e7",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "t/in³" ]
}
]
},
{
"SingularName": "GramPerCubicFoot",
"PluralName": "GramsPerCubicFoot",
"BaseUnits": {
"L": "Foot",
"M": "Gram"
},
"FromUnitToBaseFunc": "x*0.0353146667214886",
"FromBaseToUnitFunc": "x/0.0353146667214886",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "g/ft³" ]
}
]
},
{
"SingularName": "GramPerCubicInch",
"PluralName": "GramsPerCubicInch",
"BaseUnits": {
"L": "Inch",
"M": "Gram"
},
"FromUnitToBaseFunc": "x*61.0237440947323",
"FromBaseToUnitFunc": "x/61.0237440947323",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "g/in³" ]
}
]
},
{
"SingularName": "PoundPerCubicMeter",
"PluralName": "PoundsPerCubicMeter",
"BaseUnits": {
"L": "Meter",
"M": "Pound"
},
"FromUnitToBaseFunc": "x/2.204622621848775",
"FromBaseToUnitFunc": "x*2.204622621848775",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lb/m³" ]
}
]
},
{
"SingularName": "PoundPerCubicCentimeter",
"PluralName": "PoundsPerCubicCentimeter",
"BaseUnits": {
"L": "Centimeter",
"M": "Pound"
},
"FromUnitToBaseFunc": "x/2.204622621848775e-6",
"FromBaseToUnitFunc": "x*2.204622621848775e-6",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lb/cm³" ]
}
]
},
{
"SingularName": "PoundPerCubicMillimeter",
"PluralName": "PoundsPerCubicMillimeter",
"BaseUnits": {
"L": "Millimeter",
"M": "Pound"
},
"FromUnitToBaseFunc": "x/2.204622621848775e-9",
"FromBaseToUnitFunc": "x*2.204622621848775e-9",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lb/mm³" ]
}
]
},
{
"SingularName": "SlugPerCubicMeter",
"PluralName": "SlugsPerCubicMeter",
"BaseUnits": {
"L": "Meter",
"M": "Slug"
},
"FromUnitToBaseFunc": "x*14.5939",
"FromBaseToUnitFunc": "x/14.5939",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "slug/m³" ]
}
]
},
{
"SingularName": "SlugPerCubicCentimeter",
"PluralName": "SlugsPerCubicCentimeter",
"BaseUnits": {
"L": "Centimeter",
"M": "Slug"
},
"FromUnitToBaseFunc": "x*14593903",
"FromBaseToUnitFunc": "x/14593903",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "slug/cm³" ]
}
]
},
{
"SingularName": "SlugPerCubicMillimeter",
"PluralName": "SlugsPerCubicMillimeter",
"BaseUnits": {
"L": "Millimeter",
"M": "Slug"
},
"FromUnitToBaseFunc": "x*14593903000",
"FromBaseToUnitFunc": "x/14593903000",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "slug/mm³" ]
}
]
},
{
"SingularName": "SlugPerCubicInch",
"PluralName": "SlugsPerCubicInch",
"BaseUnits": {
"L": "Inch",
"M": "Slug"
},
"FromUnitToBaseFunc": "x*890574.60201535",
"FromBaseToUnitFunc": "x/890574.60201535",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "slug/in³" ]
}
]
}
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions UnitsNet.Tests/CustomCode/DensityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ public class DensityTests : DensityTestsBase

protected override double KilogramsPerLiterInOneKilogramPerCubicMeter => 1e-3;

protected override double TonnesPerCubicFootInOneKilogramPerCubicMeter => 2.8316846591999996e-05;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double TonnesPerCubicInchInOneKilogramPerCubicMeter => 1.6387063999999997e-08;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double GramsPerCubicFootInOneKilogramPerCubicMeter => 28.316846591999994;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double GramsPerCubicInchInOneKilogramPerCubicMeter => 0.016387063999999996;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double PoundsPerCubicMeterInOneKilogramPerCubicMeter => 2.204622621848775;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double PoundsPerCubicCentimeterInOneKilogramPerCubicMeter => 2.204622621848775e-6;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double PoundsPerCubicMillimeterInOneKilogramPerCubicMeter => 2.204622621848775e-9;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified


protected override double SlugsPerCubicMeterInOneKilogramPerCubicMeter => 0.068521765561961;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double SlugsPerCubicCentimeterInOneKilogramPerCubicMeter => 6.8521765561961e-8;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


protected override double SlugsPerCubicMillimeterInOneKilogramPerCubicMeter => 6.8521765561961e-11;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified


protected override double SlugsPerCubicInchInOneKilogramPerCubicMeter => 1.1228705576569e-6;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


[Fact]
public static void DensityTimesVolumeEqualsMass()
{
Expand Down
Loading