Skip to content
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

Fix force conversion rates #1308

Merged
merged 8 commits into from
Sep 16, 2023
40 changes: 28 additions & 12 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.80665e3",
"FromBaseToUnitFunc": "{x} / 9.80665e3",
"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} * 0.27801385095378125",
"FromBaseToUnitFunc": "{x} / 0.27801385095378125",
"XmlDocSummary": "An ounce-force is 1⁄16 of a pound-force, or about 0.2780139 newtons.",
MH-ZShearer marked this conversation as resolved.
Show resolved Hide resolved
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce#Ounce-force",
"Localization": [
{
"Culture": "en-US",
Expand Down
28 changes: 14 additions & 14 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.

26 changes: 18 additions & 8 deletions UnitsNet.Tests/CustomCode/ForceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.

using Xunit;
Expand All @@ -7,33 +7,36 @@ namespace UnitsNet.Tests
{
public class ForceTests : ForceTestsBase
{
private const double StandardGravity = 9.80665;
private const double PoundsConversionRate = 4.4482216152605;

protected override bool SupportsSIUnitSystem => true;
protected override double DecanewtonsInOneNewton => 1E-1;
protected override double DyneInOneNewton => 1E5;

protected override double KilogramsForceInOneNewton => 0.101972;
protected override double KilogramsForceInOneNewton => 1.0 / StandardGravity;

protected override double KilopoundsForceInOneNewton => 0.22481e-3;
protected override double KilopoundsForceInOneNewton => 1.0 / (PoundsConversionRate * 1_000.0);
protected override double MeganewtonsInOneNewton => 1E-6;
protected override double KilonewtonsInOneNewton => 1E-3;

protected override double KiloPondsInOneNewton => 0.101972;
protected override double KiloPondsInOneNewton => 1.0 / StandardGravity;

protected override double NewtonsInOneNewton => 1;

protected override double PoundalsInOneNewton => 7.23301;

protected override double PoundsForceInOneNewton => 0.22481;
protected override double PoundsForceInOneNewton => 1.0 / PoundsConversionRate;

protected override double TonnesForceInOneNewton => 1.019716212977928e-4;
protected override double TonnesForceInOneNewton => 1.0 / (StandardGravity * 1_000.0);

protected override double MillinewtonsInOneNewton => 1.0e3;

protected override double MicronewtonsInOneNewton => 1.0e6;

protected override double OunceForceInOneNewton => 3.596943089595368;
protected override double OunceForceInOneNewton => 1.0 / (PoundsConversionRate / 16.0);

protected override double ShortTonsForceInOneNewton => 1.12404471549816e-4;
protected override double ShortTonsForceInOneNewton => 1.0 / (PoundsConversionRate * 2_000.0);
angularsen marked this conversation as resolved.
Show resolved Hide resolved

angularsen marked this conversation as resolved.
Show resolved Hide resolved
[Fact]
public void ForceDividedByAreaEqualsPressure()
Expand Down Expand Up @@ -104,5 +107,12 @@ public void ForceDividedByForceChangeRateEqualsDuration()
Duration duration = Force.FromNewtons(200) / ForceChangeRate.FromNewtonsPerSecond(50);
Assert.Equal(duration, Duration.FromSeconds(4));
}

[Fact]
public void KilogramForceDividedByNewtonEqualsStandardGravity()
{
double duration = Force.FromKilogramsForce(1) / Force.FromNewtons(1);
Assert.Equal(StandardGravity, duration);
}
}
}
28 changes: 14 additions & 14 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