# Fix unit conversions

## Description

A small number of conversion problems show up when tested against the NIST data.

1. ‘ofhg’

The value of 'ofhg' appears is off by 10 compared to the NIST values and other sources. Moreover, a more exact value can be derived from the density of mercury (in kg/m^3^) and the value of gravity in the constants we defined. Fixing that would result in the following change:

<convertUnit source='ofhg' baseUnit='kilogram-per-square-meter-square-second' factor='10132500000/760000'/>
=>
<convertUnit source='ofhg' baseUnit='kilogram-per-square-meter-square-second' factor='13595.1*gravity'/>

[Note: sdiff = 2*(a-b)/(a+b)]

Errors:
inch-ofhg ⟹ kilopascal
expected 3.386389
actual: 0.3386388157894737
sdiff: 1.63636371856976
xdata: PRESSURE or STRESS (FORCE DIVIDED BY AREA)
«inch of mercury, conventional (inHg) 12 kilopascal (kPa) 3.386 389 E+00»

millimeter-ofhg ⟹ pascal
expected 133.3224
actual: 13.33223684210526
sdiff: 1.63636371466497
xdata: PRESSURE or STRESS (FORCE DIVIDED BY AREA)
«millimeter of mercury, conventional (mmHg) 12 pascal (Pa) 1.333 224 E+02»

2. calorie, BTU, and therm
There are many different definitions of calorie, BTU, and therm, which are interrelated units.
That is, they should have the following relationships:

Unit

Definition

1 calorie

energy required to raise the temperature of one gram of water by 1 °C

1 BTU

energy required to raise the one pound of water by 1 °F

1 pound-fahrenheit

2,267.96185/9 gram-celsius

(exact)

1 therm

100,000 British thermal units

However, there are many ways to measure, depending on the starting temperature of the water, etc. See https://en.wikipedia.org/wiki/Calorie and other sources. So from a given value for calorie, we can precisely calculate the BTU and therm values. We chose the Thermochemical calorie, where 1 calorie (th) ≡ 4.184 joule.

We don't actually support the plain therm, just the therm-us, so that can be independent. But we should align the calorie and BTU. Secondly, in reviewing the situation I found that there was a mistake in transcribing the therm (US) conversion rate.

So the following are proposed:

<convertUnit source='british-thermal-unit' baseUnit='kilogram-square-meter-per-square-second' factor='1055.06' systems="ussystem uksystem"/>

<convertUnit source='british-thermal-unit' baseUnit='kilogram-square-meter-per-square-second' factor='4.184*2,267.96185/9 systems="ussystem uksystem"/> <!-- th -->

[we could also introduce 1 or more constants to make the derivation clearer]

<convertUnit source='therm-us' baseUnit='kilogram-square-meter-per-square-second' factor='105506000' systems="ussystem"/>

<convertUnit source='therm-us' baseUnit='kilogram-square-meter-per-square-second' factor='105480400' systems="ussystem"/>

Errors:
british-thermal-unit ⟹ joule
expected 1054.35
actual: 1055.06
sdiff: 6.731740154830024E-4
xdata: ENERGY (includes WORK)
«British thermal unitth (Btuth) 9 joule (J) 1.054 350 E+03»

therm-us ⟹ joule
expected 1.054804E8
actual: 1.05506E8
sdiff: 2.426696697038293E-4
xdata: ENERGY (includes WORK)
«therm (U.S.) 24 joule (J) 1.054 804 E+08»

Note that in the future we could introduce more unit variants if we find a need. We would just qualify the unit ID appropriately, eg calorie-mean, calorieit (for International Steam Table calorie), calorie-15C, etc.

3. fahrenheit-hour-square-foot-per-british-thermal-unit-inch

We also have the following error, which hasn't been analyzed yet, but is another off-by a factor of 10 bug. Might be a software bug.

fahrenheit-hour-square-foot-per-british-thermal-unit-inch ⟹ meter-kelvin-per-watt
expected 69381.12
actual: 6.938111789203321
sdiff: 1.999600040008151
xdata: Thermal Resistivity
«degree Fahrenheit hour square foot per British thermal unitth inch [°F · h · ft2/(Btuth · in)] meter kelvin per watt (m · K/W) 6.938 112 E+04»

Update on #3, looks like an error in the NIST document, so no action is needed

The 3rd one was a puzzler for me. I gnawed away at it until I finally figured out that the NIST line was faulty. They have the following on https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b9

 degree Fahrenheit hour square foot per British thermal unitIT inch [°F · h · ft2/(BtuIT · in)] meter kelvin per watt (m · K/W) 933 472 E+00 degree Fahrenheit hour square foot per British thermal unitth inch [°F · h · ft2/(Btuth · in)] meter kelvin per watt (m · K/W) 938 112 E+04

Note that the two values are off by a factor of E+04. That doesn't make sense, since the difference between British thermal unitIT and British thermal unitth is not very big.

As it turns out, https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b8 (which is supposed to differ just by order!) has the correct values:

 degree Fahrenheit hour square foot per British thermal unitIT inch [°F · h · ft2/(BtuIT · in)] meter kelvin per watt (m · K/W) 933 472 E+00 degree Fahrenheit hour square foot per British thermal unitth inch [°F · h · ft2/(Btuth · in)] meter kelvin per watt (m · K/W) 938 112 E+00

None

None

## Priority major

Mark Davis

Mark Davis

Shane Carr

None

rc
Configure