Skip to content

Commit 628c531

Browse files
authored
Fix force conversion rates (#1308)
Fixes #1306 Corrects the conversion rates of the force quantity to be the precisely defined values, relative to standard gravity. Adds a unit test that verifies that the conversion rate from kilograms divided by the conversion rate from newtons equals standard gravity (`9.80665` m/s<sup>2</sup>).
1 parent a239f03 commit 628c531

File tree

6 files changed

+156
-52
lines changed

6 files changed

+156
-52
lines changed

Common/UnitDefinitions/Force.json

+30-14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
},
1919
"FromUnitToBaseFunc": "{x} / 1e5",
2020
"FromBaseToUnitFunc": "{x} * 1e5",
21+
"XmlDocSummary": "One dyne is equal to 10 micronewtons, 10e−5 N or to 10 nsn (nanosthenes) in the old metre–tonne–second system of units.",
22+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Dyne#Definition",
2123
"Localization": [
2224
{
2325
"Culture": "en-US",
@@ -32,8 +34,10 @@
3234
{
3335
"SingularName": "KilogramForce",
3436
"PluralName": "KilogramsForce",
35-
"FromUnitToBaseFunc": "{x} * 9.80665002864",
36-
"FromBaseToUnitFunc": "{x} / 9.80665002864",
37+
"FromUnitToBaseFunc": "{x} * 9.80665",
38+
"FromBaseToUnitFunc": "{x} / 9.80665",
39+
"XmlDocSummary": "The kilogram-force, or kilopond, is equal to the magnitude of the force exerted on one kilogram of mass in a 9.80665 m/s2 gravitational field (standard gravity). Therefore, one kilogram-force is by definition equal to 9.80665 N.",
40+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force",
3741
"Localization": [
3842
{
3943
"Culture": "en-US",
@@ -48,8 +52,10 @@
4852
{
4953
"SingularName": "TonneForce",
5054
"PluralName": "TonnesForce",
51-
"FromUnitToBaseFunc": "{x} * 9.80665002864e3",
52-
"FromBaseToUnitFunc": "{x} / 9.80665002864e3",
55+
"FromUnitToBaseFunc": "{x} * (9.80665 * 1000)",
56+
"FromBaseToUnitFunc": "{x} / (9.80665 * 1000)",
57+
"XmlDocSummary": "The tonne-force, metric ton-force, megagram-force, and megapond (Mp) are each 1000 kilograms-force.",
58+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force#Related_units",
5359
"Localization": [
5460
{
5561
"Culture": "en-US",
@@ -71,6 +77,8 @@
7177
},
7278
"FromUnitToBaseFunc": "{x}",
7379
"FromBaseToUnitFunc": "{x}",
80+
"XmlDocSummary": "The newton (symbol: N) is the unit of force in the International System of Units (SI). It is defined as 1 kg⋅m/s2, the force which gives a mass of 1 kilogram an acceleration of 1 metre per second per second.",
81+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Newton_(unit)",
7482
"Prefixes": [ "Micro", "Milli", "Deca", "Kilo", "Mega" ],
7583
"Localization": [
7684
{
@@ -86,8 +94,10 @@
8694
{
8795
"SingularName": "KiloPond",
8896
"PluralName": "KiloPonds",
89-
"FromUnitToBaseFunc": "{x} * 9.80665002864",
90-
"FromBaseToUnitFunc": "{x} / 9.80665002864",
97+
"FromUnitToBaseFunc": "{x} * 9.80665",
98+
"FromBaseToUnitFunc": "{x} / 9.80665",
99+
"XmlDocSummary": "The kilogram-force, or kilopond, is equal to the magnitude of the force exerted on one kilogram of mass in a 9.80665 m/s2 gravitational field (standard gravity). Therefore, one kilogram-force is by definition equal to 9.80665 N.",
100+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force",
91101
"Localization": [
92102
{
93103
"Culture": "en-US",
@@ -107,8 +117,10 @@
107117
"M": "Pound",
108118
"T": "Second"
109119
},
110-
"FromUnitToBaseFunc": "{x} * 0.13825502798973041652092282466083",
111-
"FromBaseToUnitFunc": "{x} / 0.13825502798973041652092282466083",
120+
"FromUnitToBaseFunc": "{x} * 0.138254954376",
121+
"FromBaseToUnitFunc": "{x} / 0.138254954376",
122+
"XmlDocSummary": "The poundal is defined as the force necessary to accelerate 1 pound-mass at 1 foot per second per second. 1 pdl = 0.138254954376 N exactly.",
123+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Poundal",
112124
"Localization": [
113125
{
114126
"Culture": "en-US",
@@ -123,8 +135,10 @@
123135
{
124136
"SingularName": "PoundForce",
125137
"PluralName": "PoundsForce",
126-
"FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421",
127-
"FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421",
138+
"FromUnitToBaseFunc": "{x} * 4.4482216152605",
139+
"FromBaseToUnitFunc": "{x} / 4.4482216152605",
140+
"XmlDocSummary": "The standard values of acceleration of the standard gravitational field (gn) and the international avoirdupois pound (lb) result in a pound-force equal to 4.4482216152605 N.",
141+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Pound_(force)#Definitions",
128142
"Prefixes": [ "Kilo" ],
129143
"Localization": [
130144
{
@@ -142,8 +156,10 @@
142156
{
143157
"SingularName": "OunceForce",
144158
"PluralName": "OunceForce",
145-
"FromUnitToBaseFunc": "{x} * 2.780138509537812e-1",
146-
"FromBaseToUnitFunc": "{x} / 2.780138509537812e-1",
159+
"FromUnitToBaseFunc": "{x} * (4.4482216152605 / 16)",
160+
"FromBaseToUnitFunc": "{x} / (4.4482216152605 / 16)",
161+
"XmlDocSummary": "An ounce-force is 1⁄16 of a pound-force, or about 0.2780139 newtons.",
162+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce#Ounce-force",
147163
"Localization": [
148164
{
149165
"Culture": "en-US",
@@ -154,8 +170,8 @@
154170
{
155171
"SingularName": "ShortTonForce",
156172
"PluralName": "ShortTonsForce",
157-
"FromUnitToBaseFunc": "{x} * 8.896443230521e3",
158-
"FromBaseToUnitFunc": "{x} / 8.896443230521e3",
173+
"FromUnitToBaseFunc": "{x} * (4.4482216152605 * 2000)",
174+
"FromBaseToUnitFunc": "{x} / (4.4482216152605 * 2000)",
159175
"XmlDocSummary": "The short ton-force is a unit of force equal to 2,000 pounds-force (907.18474 kgf), that is most commonly used in the United States – known there simply as the ton or US ton.",
160176
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ton-force#Short_ton-force",
161177
"Localization": [

UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/CustomCode/ForceTests.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ public class ForceTests : ForceTestsBase
1111
protected override double DecanewtonsInOneNewton => 1E-1;
1212
protected override double DyneInOneNewton => 1E5;
1313

14-
protected override double KilogramsForceInOneNewton => 0.101972;
14+
protected override double KilogramsForceInOneNewton => 0.1019716;
1515

16-
protected override double KilopoundsForceInOneNewton => 0.22481e-3;
16+
protected override double KilopoundsForceInOneNewton => 0.2248089e-3;
1717
protected override double MeganewtonsInOneNewton => 1E-6;
1818
protected override double KilonewtonsInOneNewton => 1E-3;
1919

20-
protected override double KiloPondsInOneNewton => 0.101972;
20+
protected override double KiloPondsInOneNewton => 0.1019716;
2121

2222
protected override double NewtonsInOneNewton => 1;
2323

24-
protected override double PoundalsInOneNewton => 7.23301;
24+
protected override double PoundalsInOneNewton => 7.2330138;
2525

26-
protected override double PoundsForceInOneNewton => 0.22481;
26+
protected override double PoundsForceInOneNewton => 0.2248089;
2727

2828
protected override double TonnesForceInOneNewton => 1.019716212977928e-4;
2929

@@ -33,7 +33,7 @@ public class ForceTests : ForceTestsBase
3333

3434
protected override double OunceForceInOneNewton => 3.596943089595368;
3535

36-
protected override double ShortTonsForceInOneNewton => 1.12404471549816e-4;
36+
protected override double ShortTonsForceInOneNewton => 1.12404471549855e-4;
3737

3838
[Fact]
3939
public void ForceDividedByAreaEqualsPressure()
@@ -104,5 +104,13 @@ public void ForceDividedByForceChangeRateEqualsDuration()
104104
Duration duration = Force.FromNewtons(200) / ForceChangeRate.FromNewtonsPerSecond(50);
105105
Assert.Equal(duration, Duration.FromSeconds(4));
106106
}
107+
108+
[Fact]
109+
public void KilogramForceDividedByNewtonEqualsStandardGravity()
110+
{
111+
const double standardGravity = 9.80665;
112+
double duration = Force.FromKilogramsForce(1) / Force.FromNewtons(1);
113+
Assert.Equal(standardGravity, duration);
114+
}
107115
}
108116
}

UnitsNet/GeneratedCode/Quantities/Force.g.cs

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)