Skip to content

Adding dyn/cm² and lbm/(in·s²) units for pressure #534

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 2 commits into from
Oct 29, 2018
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
63 changes: 63 additions & 0 deletions Common/GeneratedCode/Quantities/Pressure.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public static BaseDimensions BaseDimensions
/// </summary>
public double Decibars => As(PressureUnit.Decibar);

/// <summary>
/// Get Pressure in DynesPerSquareCentimeter.
/// </summary>
public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter);

/// <summary>
/// Get Pressure in FeetOfHead.
/// </summary>
Expand Down Expand Up @@ -276,6 +281,11 @@ public static BaseDimensions BaseDimensions
/// </summary>
public double MetersOfHead => As(PressureUnit.MeterOfHead);

/// <summary>
/// Get Pressure in Microbars.
/// </summary>
public double Microbars => As(PressureUnit.Microbar);

/// <summary>
/// Get Pressure in Micropascals.
/// </summary>
Expand Down Expand Up @@ -321,6 +331,11 @@ public static BaseDimensions BaseDimensions
/// </summary>
public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch);

/// <summary>
/// Get Pressure in PoundsPerInchSecondSquared.
/// </summary>
public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared);

/// <summary>
/// Get Pressure in Psi.
/// </summary>
Expand Down Expand Up @@ -431,6 +446,20 @@ public static Pressure FromDecibars(QuantityValue decibars)
return new Pressure(value, PressureUnit.Decibar);
}

/// <summary>
/// Get Pressure from DynesPerSquareCentimeter.
/// </summary>
#if WINDOWS_UWP
[Windows.Foundation.Metadata.DefaultOverload]
public static Pressure FromDynesPerSquareCentimeter(double dynespersquarecentimeter)
#else
public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquarecentimeter)
#endif
{
double value = (double) dynespersquarecentimeter;
return new Pressure(value, PressureUnit.DynePerSquareCentimeter);
}

/// <summary>
/// Get Pressure from FeetOfHead.
/// </summary>
Expand Down Expand Up @@ -683,6 +712,20 @@ public static Pressure FromMetersOfHead(QuantityValue metersofhead)
return new Pressure(value, PressureUnit.MeterOfHead);
}

/// <summary>
/// Get Pressure from Microbars.
/// </summary>
#if WINDOWS_UWP
[Windows.Foundation.Metadata.DefaultOverload]
public static Pressure FromMicrobars(double microbars)
#else
public static Pressure FromMicrobars(QuantityValue microbars)
#endif
{
double value = (double) microbars;
return new Pressure(value, PressureUnit.Microbar);
}

/// <summary>
/// Get Pressure from Micropascals.
/// </summary>
Expand Down Expand Up @@ -809,6 +852,20 @@ public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforceper
return new Pressure(value, PressureUnit.PoundForcePerSquareInch);
}

/// <summary>
/// Get Pressure from PoundsPerInchSecondSquared.
/// </summary>
#if WINDOWS_UWP
[Windows.Foundation.Metadata.DefaultOverload]
public static Pressure FromPoundsPerInchSecondSquared(double poundsperinchsecondsquared)
#else
public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinchsecondsquared)
#endif
{
double value = (double) poundsperinchsecondsquared;
return new Pressure(value, PressureUnit.PoundPerInchSecondSquared);
}

/// <summary>
/// Get Pressure from Psi.
/// </summary>
Expand Down Expand Up @@ -1071,6 +1128,7 @@ private double AsBaseUnit()
case PressureUnit.Centibar: return (_value*1e5) * 1e-2d;
case PressureUnit.Decapascal: return (_value) * 1e1d;
case PressureUnit.Decibar: return (_value*1e5) * 1e-1d;
case PressureUnit.DynePerSquareCentimeter: return _value*1.0e-1;
case PressureUnit.FootOfHead: return _value*2989.0669;
case PressureUnit.Gigapascal: return (_value) * 1e9d;
case PressureUnit.Hectopascal: return (_value) * 1e2d;
Expand All @@ -1089,6 +1147,7 @@ private double AsBaseUnit()
case PressureUnit.MeganewtonPerSquareMeter: return (_value) * 1e6d;
case PressureUnit.Megapascal: return (_value) * 1e6d;
case PressureUnit.MeterOfHead: return _value*9804.139432;
case PressureUnit.Microbar: return (_value*1e5) * 1e-6d;
case PressureUnit.Micropascal: return (_value) * 1e-6d;
case PressureUnit.Millibar: return (_value*1e5) * 1e-3d;
case PressureUnit.MillimeterOfMercury: return _value/7.50061561302643e-3;
Expand All @@ -1098,6 +1157,7 @@ private double AsBaseUnit()
case PressureUnit.Pascal: return _value;
case PressureUnit.PoundForcePerSquareFoot: return _value*4.788025898033584e1;
case PressureUnit.PoundForcePerSquareInch: return _value*6.894757293168361e3;
case PressureUnit.PoundPerInchSecondSquared: return _value*1.785796732283465e1;
case PressureUnit.Psi: return _value*6.894757293168361e3;
case PressureUnit.TechnicalAtmosphere: return _value*9.80680592331*1e4;
case PressureUnit.TonneForcePerSquareCentimeter: return _value*9.80665e7;
Expand All @@ -1123,6 +1183,7 @@ private double AsBaseNumericType(PressureUnit unit)
case PressureUnit.Centibar: return (baseUnitValue/1e5) / 1e-2d;
case PressureUnit.Decapascal: return (baseUnitValue) / 1e1d;
case PressureUnit.Decibar: return (baseUnitValue/1e5) / 1e-1d;
case PressureUnit.DynePerSquareCentimeter: return baseUnitValue/1.0e-1;
case PressureUnit.FootOfHead: return baseUnitValue*0.000334552565551;
case PressureUnit.Gigapascal: return (baseUnitValue) / 1e9d;
case PressureUnit.Hectopascal: return (baseUnitValue) / 1e2d;
Expand All @@ -1141,6 +1202,7 @@ private double AsBaseNumericType(PressureUnit unit)
case PressureUnit.MeganewtonPerSquareMeter: return (baseUnitValue) / 1e6d;
case PressureUnit.Megapascal: return (baseUnitValue) / 1e6d;
case PressureUnit.MeterOfHead: return baseUnitValue*0.0001019977334;
case PressureUnit.Microbar: return (baseUnitValue/1e5) / 1e-6d;
case PressureUnit.Micropascal: return (baseUnitValue) / 1e-6d;
case PressureUnit.Millibar: return (baseUnitValue/1e5) / 1e-3d;
case PressureUnit.MillimeterOfMercury: return baseUnitValue*7.50061561302643e-3;
Expand All @@ -1150,6 +1212,7 @@ private double AsBaseNumericType(PressureUnit unit)
case PressureUnit.Pascal: return baseUnitValue;
case PressureUnit.PoundForcePerSquareFoot: return baseUnitValue/4.788025898033584e1;
case PressureUnit.PoundForcePerSquareInch: return baseUnitValue/6.894757293168361e3;
case PressureUnit.PoundPerInchSecondSquared: return baseUnitValue/1.785796732283465e1;
case PressureUnit.Psi: return baseUnitValue/6.894757293168361e3;
case PressureUnit.TechnicalAtmosphere: return baseUnitValue/(9.80680592331*1e4);
case PressureUnit.TonneForcePerSquareCentimeter: return baseUnitValue/9.80665e7;
Expand Down
26 changes: 25 additions & 1 deletion Common/UnitDefinitions/Pressure.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"PluralName": "Bars",
"FromUnitToBaseFunc": "x*1e5",
"FromBaseToUnitFunc": "x/1e5",
"Prefixes": [ "Milli", "Centi", "Deci", "Kilo", "Mega" ],
"Prefixes": [ "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ],
"Localization": [
{
"Culture": "en-US",
Expand Down Expand Up @@ -321,6 +321,30 @@
"Abbreviations": [ "inHg" ]
}
]
},
{
"SingularName": "DynePerSquareCentimeter",
"PluralName": "DynesPerSquareCentimeter",
"FromUnitToBaseFunc": "x*1.0e-1",
"FromBaseToUnitFunc": "x/1.0e-1",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "dyn/cm²" ]
}
]
},
{
"SingularName": "PoundPerInchSecondSquared",
"PluralName": "PoundsPerInchSecondSquared",
Copy link
Owner

Choose a reason for hiding this comment

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

Is this a pressure unit? Second seems out of place to me and I can't Google it in context of pressure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, see here.

You can also see it corresponds to the base dimensions: mass / (length * time²)

  "BaseDimensions": {
    "L": -1,
    "M": 1,
    "T": -2
  }

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

"FromUnitToBaseFunc": "x*1.785796732283465e1",
"FromBaseToUnitFunc": "x/1.785796732283465e1",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lbm/(in·s²)", "lb/(in·s²)" ]
}
]
}
]
}
6 changes: 6 additions & 0 deletions UnitsNet.Tests/CustomCode/PressureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ public class PressureTests : PressureTestsBase

protected override double MillibarsInOnePascal => 1e-2;

protected override double MicrobarsInOnePascal => 1.0e1;

protected override double MillimetersOfMercuryInOnePascal => 7.50061561302643e-3;

protected override double InchesOfMercuryInOnePascal => 2.95299830714159e-4;

protected override double DynesPerSquareCentimeterInOnePascal => 1.0e1;

protected override double PoundsPerInchSecondSquaredInOnePascal => 5.599741459495891e-2;

[Fact]
public void AreaTimesPressureEqualsForce()
{
Expand Down
Loading