Skip to content

Fix force conversion rates #1308

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 8 commits into from
Sep 16, 2023
44 changes: 30 additions & 14 deletions Common/UnitDefinitions/Force.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
},
"FromUnitToBaseFunc": "{x} / 1e5",
"FromBaseToUnitFunc": "{x} * 1e5",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Dyne#Definition",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -32,8 +34,10 @@
{
"SingularName": "KilogramForce",
"PluralName": "KilogramsForce",
"FromUnitToBaseFunc": "{x} * 9.80665002864",
"FromBaseToUnitFunc": "{x} / 9.80665002864",
"FromUnitToBaseFunc": "{x} * 9.80665",
"FromBaseToUnitFunc": "{x} / 9.80665",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -48,8 +52,10 @@
{
"SingularName": "TonneForce",
"PluralName": "TonnesForce",
"FromUnitToBaseFunc": "{x} * 9.80665002864e3",
"FromBaseToUnitFunc": "{x} / 9.80665002864e3",
"FromUnitToBaseFunc": "{x} * (9.80665 * 1000)",
"FromBaseToUnitFunc": "{x} / (9.80665 * 1000)",
"XmlDocSummary": "The tonne-force, metric ton-force, megagram-force, and megapond (Mp) are each 1000 kilograms-force.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force#Related_units",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -71,6 +77,8 @@
},
"FromUnitToBaseFunc": "{x}",
"FromBaseToUnitFunc": "{x}",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Newton_(unit)",
"Prefixes": [ "Micro", "Milli", "Deca", "Kilo", "Mega" ],
"Localization": [
{
Expand All @@ -86,8 +94,10 @@
{
"SingularName": "KiloPond",
"PluralName": "KiloPonds",
"FromUnitToBaseFunc": "{x} * 9.80665002864",
"FromBaseToUnitFunc": "{x} / 9.80665002864",
"FromUnitToBaseFunc": "{x} * 9.80665",
"FromBaseToUnitFunc": "{x} / 9.80665",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -107,8 +117,10 @@
"M": "Pound",
"T": "Second"
},
"FromUnitToBaseFunc": "{x} * 0.13825502798973041652092282466083",
"FromBaseToUnitFunc": "{x} / 0.13825502798973041652092282466083",
"FromUnitToBaseFunc": "{x} * 0.138254954376",
"FromBaseToUnitFunc": "{x} / 0.138254954376",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Poundal",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -123,8 +135,10 @@
{
"SingularName": "PoundForce",
"PluralName": "PoundsForce",
"FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421",
"FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421",
"FromUnitToBaseFunc": "{x} * 4.4482216152605",
"FromBaseToUnitFunc": "{x} / 4.4482216152605",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Pound_(force)#Definitions",
"Prefixes": [ "Kilo" ],
"Localization": [
{
Expand All @@ -142,8 +156,10 @@
{
"SingularName": "OunceForce",
"PluralName": "OunceForce",
"FromUnitToBaseFunc": "{x} * 2.780138509537812e-1",
"FromBaseToUnitFunc": "{x} / 2.780138509537812e-1",
"FromUnitToBaseFunc": "{x} * (4.4482216152605 / 16)",
"FromBaseToUnitFunc": "{x} / (4.4482216152605 / 16)",
"XmlDocSummary": "An ounce-force is 1⁄16 of a pound-force, or about 0.2780139 newtons.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce#Ounce-force",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -154,8 +170,8 @@
{
"SingularName": "ShortTonForce",
"PluralName": "ShortTonsForce",
"FromUnitToBaseFunc": "{x} * 8.896443230521e3",
"FromBaseToUnitFunc": "{x} / 8.896443230521e3",
"FromUnitToBaseFunc": "{x} * (4.4482216152605 * 2000)",
"FromBaseToUnitFunc": "{x} / (4.4482216152605 * 2000)",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ton-force#Short_ton-force",
"Localization": [
Expand Down
32 changes: 16 additions & 16 deletions UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs

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

40 changes: 40 additions & 0 deletions UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs

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

20 changes: 14 additions & 6 deletions UnitsNet.Tests/CustomCode/ForceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ public class ForceTests : ForceTestsBase
protected override double DecanewtonsInOneNewton => 1E-1;
protected override double DyneInOneNewton => 1E5;

protected override double KilogramsForceInOneNewton => 0.101972;
protected override double KilogramsForceInOneNewton => 0.1019716;

protected override double KilopoundsForceInOneNewton => 0.22481e-3;
protected override double KilopoundsForceInOneNewton => 0.2248089e-3;
protected override double MeganewtonsInOneNewton => 1E-6;
protected override double KilonewtonsInOneNewton => 1E-3;

protected override double KiloPondsInOneNewton => 0.101972;
protected override double KiloPondsInOneNewton => 0.1019716;

protected override double NewtonsInOneNewton => 1;

protected override double PoundalsInOneNewton => 7.23301;
protected override double PoundalsInOneNewton => 7.2330138;

protected override double PoundsForceInOneNewton => 0.22481;
protected override double PoundsForceInOneNewton => 0.2248089;

protected override double TonnesForceInOneNewton => 1.019716212977928e-4;

Expand All @@ -33,7 +33,7 @@ public class ForceTests : ForceTestsBase

protected override double OunceForceInOneNewton => 3.596943089595368;

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

[Fact]
public void ForceDividedByAreaEqualsPressure()
Expand Down Expand Up @@ -104,5 +104,13 @@ public void ForceDividedByForceChangeRateEqualsDuration()
Duration duration = Force.FromNewtons(200) / ForceChangeRate.FromNewtonsPerSecond(50);
Assert.Equal(duration, Duration.FromSeconds(4));
}

[Fact]
public void KilogramForceDividedByNewtonEqualsStandardGravity()
{
const double standardGravity = 9.80665;
double duration = Force.FromKilogramsForce(1) / Force.FromNewtons(1);
Assert.Equal(standardGravity, duration);
}
}
}
32 changes: 16 additions & 16 deletions UnitsNet/GeneratedCode/Quantities/Force.g.cs

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

Loading