Skip to content

Commit

Permalink
Changed definition of a perm to pound mass based.
Browse files Browse the repository at this point in the history
  • Loading branch information
point85 committed Mar 18, 2023
1 parent f5e5359 commit 128116b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CaliperSharp/MeasurementSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,9 @@ private UnitOfMeasure CreateCustomaryUnit(Unit unit)
// inches of Mercury
uom = CreateScalarUOM(UnitType.PRESSURE, Unit.IN_HG, UnitsManager.GetString("inhg.name"),
UnitsManager.GetString("inhg.symbol"), UnitsManager.GetString("inhg.desc"));
uom.SetConversion(0.4911531047, GetUOM(Unit.PSI));
UnitOfMeasure u1 = CreateProductUOM(GetUOM(Unit.FOOT), GetUOM(Unit.SQUARE_SECOND));
UnitOfMeasure u2 = CreateQuotientUOM(GetUOM(Unit.POUND_MASS), u1);
uom.SetConversion(2275.520677, u2);
break;

case Unit.SQUARE_INCH:
Expand Down
Binary file modified CaliperSharp/bin/Release/CaliperSharp.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions CaliperSharpTests/TestPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ public class TestPartial : BaseTest
[TestMethod]
public void TestSnippet()
{
UnitOfMeasure gUOM = sys.GetUOM(Unit.NEWTON_METRE).Multiply(sys.GetUOM(Unit.METRE)).Divide(sys.CreatePowerUOM(sys.GetUOM(Unit.KILOGRAM), 2));
Quantity G = new Quantity(6.743015E-11, gUOM);
Quantity mEarth = new Quantity(5.96E24, sys.GetUOM(Unit.KILOGRAM));
Quantity mMoon = new Quantity(7.33E22, sys.GetUOM(Unit.KILOGRAM));
Quantity distance = new Quantity(3.84E08, sys.GetUOM(Unit.METRE));
Quantity force = G.Multiply(mEarth).Multiply(mMoon).Divide(distance.Multiply(distance));

Console.WriteLine("Done");


}
}
}
51 changes: 51 additions & 0 deletions CaliperSharpTests/TestUnits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,5 +1768,56 @@ public void TestMeasurementTypes()
Assert.IsTrue(a.GetMeasurementType().Equals(UnitOfMeasure.MeasurementType.POWER));
}

[TestMethod]
public void TestPerm()
{
UnitOfMeasure inHg = sys.GetUOM(Unit.IN_HG);
UnitOfMeasure hr = sys.GetUOM(Unit.HOUR);
UnitOfMeasure ft2 = sys.GetUOM(Unit.SQUARE_FOOT);
UnitOfMeasure s = sys.GetUOM(Unit.SECOND);
UnitOfMeasure day = sys.GetUOM(Unit.DAY);
UnitOfMeasure msq = sys.GetUOM(Unit.SQUARE_METRE);
UnitOfMeasure Pa = sys.GetUOM(Unit.PASCAL);
UnitOfMeasure ng = sys.GetUOM(Prefix.NANO, Unit.GRAM);
UnitOfMeasure g = sys.GetUOM(Unit.GRAM);
UnitOfMeasure grain = sys.GetUOM(Unit.GRAIN);

// mm of Mercury pressure
UnitOfMeasure mmHg = sys.CreateScalarUOM(UnitType.PRESSURE, "mmHg", "mmHg", "mmHg");
mmHg.SetConversion(133.3223684d, Pa);

// US perm
UnitOfMeasure us1 = sys.CreateQuotientUOM(grain, inHg);
UnitOfMeasure us2 = sys.CreateQuotientUOM(us1, ft2);
UnitOfMeasure perm = sys.CreateQuotientUOM(UnitType.UNCLASSIFIED, "perm", "perm", "gn/hr/ft2/inHg", us2, hr);

// metric perm
UnitOfMeasure m1 = sys.CreateQuotientUOM(g, day);
UnitOfMeasure m2 = sys.CreateQuotientUOM(m1, msq);
UnitOfMeasure mperm = sys.CreateQuotientUOM(UnitType.UNCLASSIFIED, "mperm", "mperm", "g/day/m2/mmHg", m2, mmHg);

// Equivalent SI unit
UnitOfMeasure si1 = sys.CreateQuotientUOM(ng, s);
UnitOfMeasure si2 = sys.CreateQuotientUOM(si1, msq);
UnitOfMeasure eqSI = sys.CreateQuotientUOM(si2, Pa);

// US perm to equivalent SI
double f = perm.GetConversionFactor(eqSI);
Assert.IsTrue(IsCloseTo(f, 57.214184d, DELTA6));
f = eqSI.GetConversionFactor(perm);
Assert.IsTrue(IsCloseTo(f, 0.0174781d, DELTA6));

// metric perm to US perm
f = perm.GetConversionFactor(mperm);
Assert.IsTrue(IsCloseTo(f, 0.659053d, DELTA6));
f = mperm.GetConversionFactor(perm);
Assert.IsTrue(IsCloseTo(f, 1.517328d, DELTA6));

// metric perm to equivalent SI
f = mperm.GetConversionFactor(eqSI);
Assert.IsTrue(IsCloseTo(f, 86.812694d, DELTA6));
f = eqSI.GetConversionFactor(mperm);
Assert.IsTrue(IsCloseTo(f, 0.0115190d, DELTA6));
}
} // end TestUnits
} // end namespace

0 comments on commit 128116b

Please sign in to comment.