Skip to content

Commit 28f9dc8

Browse files
authored
Add density units (#1012)
1 parent f3d3b8c commit 28f9dc8

File tree

12 files changed

+990
-99
lines changed

12 files changed

+990
-99
lines changed

Common/UnitDefinitions/Density.json

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,182 @@
241241
"Abbreviations": [ "kg/l" ]
242242
}
243243
]
244+
},
245+
{
246+
"SingularName": "TonnePerCubicFoot",
247+
"PluralName": "TonnesPerCubicFoot",
248+
"BaseUnits": {
249+
"L": "Foot",
250+
"M": "Tonne"
251+
},
252+
"FromUnitToBaseFunc": "x*3.53146667214886e4",
253+
"FromBaseToUnitFunc": "x/3.53146667214886e4",
254+
"Localization": [
255+
{
256+
"Culture": "en-US",
257+
"Abbreviations": [ "t/ft³" ]
258+
}
259+
]
260+
},
261+
{
262+
"SingularName": "TonnePerCubicInch",
263+
"PluralName": "TonnesPerCubicInch",
264+
"BaseUnits": {
265+
"L": "Inch",
266+
"M": "Tonne"
267+
},
268+
"FromUnitToBaseFunc": "x*6.10237440947323e7",
269+
"FromBaseToUnitFunc": "x/6.10237440947323e7",
270+
"Localization": [
271+
{
272+
"Culture": "en-US",
273+
"Abbreviations": [ "t/in³" ]
274+
}
275+
]
276+
},
277+
{
278+
"SingularName": "GramPerCubicFoot",
279+
"PluralName": "GramsPerCubicFoot",
280+
"BaseUnits": {
281+
"L": "Foot",
282+
"M": "Gram"
283+
},
284+
"FromUnitToBaseFunc": "x*0.0353146667214886",
285+
"FromBaseToUnitFunc": "x/0.0353146667214886",
286+
"Localization": [
287+
{
288+
"Culture": "en-US",
289+
"Abbreviations": [ "g/ft³" ]
290+
}
291+
]
292+
},
293+
{
294+
"SingularName": "GramPerCubicInch",
295+
"PluralName": "GramsPerCubicInch",
296+
"BaseUnits": {
297+
"L": "Inch",
298+
"M": "Gram"
299+
},
300+
"FromUnitToBaseFunc": "x*61.0237440947323",
301+
"FromBaseToUnitFunc": "x/61.0237440947323",
302+
"Localization": [
303+
{
304+
"Culture": "en-US",
305+
"Abbreviations": [ "g/in³" ]
306+
}
307+
]
308+
},
309+
{
310+
"SingularName": "PoundPerCubicMeter",
311+
"PluralName": "PoundsPerCubicMeter",
312+
"BaseUnits": {
313+
"L": "Meter",
314+
"M": "Pound"
315+
},
316+
"FromUnitToBaseFunc": "x/2.204622621848775",
317+
"FromBaseToUnitFunc": "x*2.204622621848775",
318+
"Localization": [
319+
{
320+
"Culture": "en-US",
321+
"Abbreviations": [ "lb/m³" ]
322+
}
323+
]
324+
},
325+
{
326+
"SingularName": "PoundPerCubicCentimeter",
327+
"PluralName": "PoundsPerCubicCentimeter",
328+
"BaseUnits": {
329+
"L": "Centimeter",
330+
"M": "Pound"
331+
},
332+
"FromUnitToBaseFunc": "x/2.204622621848775e-6",
333+
"FromBaseToUnitFunc": "x*2.204622621848775e-6",
334+
"Localization": [
335+
{
336+
"Culture": "en-US",
337+
"Abbreviations": [ "lb/cm³" ]
338+
}
339+
]
340+
},
341+
{
342+
"SingularName": "PoundPerCubicMillimeter",
343+
"PluralName": "PoundsPerCubicMillimeter",
344+
"BaseUnits": {
345+
"L": "Millimeter",
346+
"M": "Pound"
347+
},
348+
"FromUnitToBaseFunc": "x/2.204622621848775e-9",
349+
"FromBaseToUnitFunc": "x*2.204622621848775e-9",
350+
"Localization": [
351+
{
352+
"Culture": "en-US",
353+
"Abbreviations": [ "lb/mm³" ]
354+
}
355+
]
356+
},
357+
{
358+
"SingularName": "SlugPerCubicMeter",
359+
"PluralName": "SlugsPerCubicMeter",
360+
"BaseUnits": {
361+
"L": "Meter",
362+
"M": "Slug"
363+
},
364+
"FromUnitToBaseFunc": "x*14.5939",
365+
"FromBaseToUnitFunc": "x/14.5939",
366+
"Localization": [
367+
{
368+
"Culture": "en-US",
369+
"Abbreviations": [ "slug/m³" ]
370+
}
371+
]
372+
},
373+
{
374+
"SingularName": "SlugPerCubicCentimeter",
375+
"PluralName": "SlugsPerCubicCentimeter",
376+
"BaseUnits": {
377+
"L": "Centimeter",
378+
"M": "Slug"
379+
},
380+
"FromUnitToBaseFunc": "x*14593903",
381+
"FromBaseToUnitFunc": "x/14593903",
382+
"Localization": [
383+
{
384+
"Culture": "en-US",
385+
"Abbreviations": [ "slug/cm³" ]
386+
}
387+
]
388+
},
389+
{
390+
"SingularName": "SlugPerCubicMillimeter",
391+
"PluralName": "SlugsPerCubicMillimeter",
392+
"BaseUnits": {
393+
"L": "Millimeter",
394+
"M": "Slug"
395+
},
396+
"FromUnitToBaseFunc": "x*14593903000",
397+
"FromBaseToUnitFunc": "x/14593903000",
398+
"Localization": [
399+
{
400+
"Culture": "en-US",
401+
"Abbreviations": [ "slug/mm³" ]
402+
}
403+
]
404+
},
405+
{
406+
"SingularName": "SlugPerCubicInch",
407+
"PluralName": "SlugsPerCubicInch",
408+
"BaseUnits": {
409+
"L": "Inch",
410+
"M": "Slug"
411+
},
412+
"FromUnitToBaseFunc": "x*890574.60201535",
413+
"FromBaseToUnitFunc": "x/890574.60201535",
414+
"Localization": [
415+
{
416+
"Culture": "en-US",
417+
"Abbreviations": [ "slug/in³" ]
418+
}
419+
]
244420
}
245421
]
246422
}

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

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

UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs

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

UnitsNet.Tests/CustomCode/DensityTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,28 @@ public class DensityTests : DensityTestsBase
8989

9090
protected override double KilogramsPerLiterInOneKilogramPerCubicMeter => 1e-3;
9191

92+
protected override double TonnesPerCubicFootInOneKilogramPerCubicMeter => 2.8316846591999996e-05;
93+
94+
protected override double TonnesPerCubicInchInOneKilogramPerCubicMeter => 1.6387063999999997e-08;
95+
96+
protected override double GramsPerCubicFootInOneKilogramPerCubicMeter => 28.316846591999994;
97+
98+
protected override double GramsPerCubicInchInOneKilogramPerCubicMeter => 0.016387063999999996;
99+
100+
protected override double PoundsPerCubicMeterInOneKilogramPerCubicMeter => 2.204622621848775;
101+
102+
protected override double PoundsPerCubicCentimeterInOneKilogramPerCubicMeter => 2.204622621848775e-6;
103+
104+
protected override double PoundsPerCubicMillimeterInOneKilogramPerCubicMeter => 2.204622621848775e-9;
105+
106+
protected override double SlugsPerCubicMeterInOneKilogramPerCubicMeter => 0.068521765561961;
107+
108+
protected override double SlugsPerCubicCentimeterInOneKilogramPerCubicMeter => 6.8521765561961e-8;
109+
110+
protected override double SlugsPerCubicMillimeterInOneKilogramPerCubicMeter => 6.8521765561961e-11;
111+
112+
protected override double SlugsPerCubicInchInOneKilogramPerCubicMeter => 1.1228705576569e-6;
113+
92114
[Fact]
93115
public static void DensityTimesVolumeEqualsMass()
94116
{

0 commit comments

Comments
 (0)