Skip to content

Commit 128116b

Browse files
committed
Changed definition of a perm to pound mass based.
1 parent f5e5359 commit 128116b

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

CaliperSharp/MeasurementSystem.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,9 @@ private UnitOfMeasure CreateCustomaryUnit(Unit unit)
968968
// inches of Mercury
969969
uom = CreateScalarUOM(UnitType.PRESSURE, Unit.IN_HG, UnitsManager.GetString("inhg.name"),
970970
UnitsManager.GetString("inhg.symbol"), UnitsManager.GetString("inhg.desc"));
971-
uom.SetConversion(0.4911531047, GetUOM(Unit.PSI));
971+
UnitOfMeasure u1 = CreateProductUOM(GetUOM(Unit.FOOT), GetUOM(Unit.SQUARE_SECOND));
972+
UnitOfMeasure u2 = CreateQuotientUOM(GetUOM(Unit.POUND_MASS), u1);
973+
uom.SetConversion(2275.520677, u2);
972974
break;
973975

974976
case Unit.SQUARE_INCH:
0 Bytes
Binary file not shown.

CaliperSharpTests/TestPartial.cs

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ public class TestPartial : BaseTest
1010
[TestMethod]
1111
public void TestSnippet()
1212
{
13+
UnitOfMeasure gUOM = sys.GetUOM(Unit.NEWTON_METRE).Multiply(sys.GetUOM(Unit.METRE)).Divide(sys.CreatePowerUOM(sys.GetUOM(Unit.KILOGRAM), 2));
14+
Quantity G = new Quantity(6.743015E-11, gUOM);
15+
Quantity mEarth = new Quantity(5.96E24, sys.GetUOM(Unit.KILOGRAM));
16+
Quantity mMoon = new Quantity(7.33E22, sys.GetUOM(Unit.KILOGRAM));
17+
Quantity distance = new Quantity(3.84E08, sys.GetUOM(Unit.METRE));
18+
Quantity force = G.Multiply(mEarth).Multiply(mMoon).Divide(distance.Multiply(distance));
19+
20+
Console.WriteLine("Done");
21+
22+
1323
}
1424
}
1525
}

CaliperSharpTests/TestUnits.cs

+51
Original file line numberDiff line numberDiff line change
@@ -1768,5 +1768,56 @@ public void TestMeasurementTypes()
17681768
Assert.IsTrue(a.GetMeasurementType().Equals(UnitOfMeasure.MeasurementType.POWER));
17691769
}
17701770

1771+
[TestMethod]
1772+
public void TestPerm()
1773+
{
1774+
UnitOfMeasure inHg = sys.GetUOM(Unit.IN_HG);
1775+
UnitOfMeasure hr = sys.GetUOM(Unit.HOUR);
1776+
UnitOfMeasure ft2 = sys.GetUOM(Unit.SQUARE_FOOT);
1777+
UnitOfMeasure s = sys.GetUOM(Unit.SECOND);
1778+
UnitOfMeasure day = sys.GetUOM(Unit.DAY);
1779+
UnitOfMeasure msq = sys.GetUOM(Unit.SQUARE_METRE);
1780+
UnitOfMeasure Pa = sys.GetUOM(Unit.PASCAL);
1781+
UnitOfMeasure ng = sys.GetUOM(Prefix.NANO, Unit.GRAM);
1782+
UnitOfMeasure g = sys.GetUOM(Unit.GRAM);
1783+
UnitOfMeasure grain = sys.GetUOM(Unit.GRAIN);
1784+
1785+
// mm of Mercury pressure
1786+
UnitOfMeasure mmHg = sys.CreateScalarUOM(UnitType.PRESSURE, "mmHg", "mmHg", "mmHg");
1787+
mmHg.SetConversion(133.3223684d, Pa);
1788+
1789+
// US perm
1790+
UnitOfMeasure us1 = sys.CreateQuotientUOM(grain, inHg);
1791+
UnitOfMeasure us2 = sys.CreateQuotientUOM(us1, ft2);
1792+
UnitOfMeasure perm = sys.CreateQuotientUOM(UnitType.UNCLASSIFIED, "perm", "perm", "gn/hr/ft2/inHg", us2, hr);
1793+
1794+
// metric perm
1795+
UnitOfMeasure m1 = sys.CreateQuotientUOM(g, day);
1796+
UnitOfMeasure m2 = sys.CreateQuotientUOM(m1, msq);
1797+
UnitOfMeasure mperm = sys.CreateQuotientUOM(UnitType.UNCLASSIFIED, "mperm", "mperm", "g/day/m2/mmHg", m2, mmHg);
1798+
1799+
// Equivalent SI unit
1800+
UnitOfMeasure si1 = sys.CreateQuotientUOM(ng, s);
1801+
UnitOfMeasure si2 = sys.CreateQuotientUOM(si1, msq);
1802+
UnitOfMeasure eqSI = sys.CreateQuotientUOM(si2, Pa);
1803+
1804+
// US perm to equivalent SI
1805+
double f = perm.GetConversionFactor(eqSI);
1806+
Assert.IsTrue(IsCloseTo(f, 57.214184d, DELTA6));
1807+
f = eqSI.GetConversionFactor(perm);
1808+
Assert.IsTrue(IsCloseTo(f, 0.0174781d, DELTA6));
1809+
1810+
// metric perm to US perm
1811+
f = perm.GetConversionFactor(mperm);
1812+
Assert.IsTrue(IsCloseTo(f, 0.659053d, DELTA6));
1813+
f = mperm.GetConversionFactor(perm);
1814+
Assert.IsTrue(IsCloseTo(f, 1.517328d, DELTA6));
1815+
1816+
// metric perm to equivalent SI
1817+
f = mperm.GetConversionFactor(eqSI);
1818+
Assert.IsTrue(IsCloseTo(f, 86.812694d, DELTA6));
1819+
f = eqSI.GetConversionFactor(mperm);
1820+
Assert.IsTrue(IsCloseTo(f, 0.0115190d, DELTA6));
1821+
}
17711822
} // end TestUnits
17721823
} // end namespace

0 commit comments

Comments
 (0)