Skip to content

Commit 5a280b9

Browse files
authored
Decompose unit conversion functions to exact coefficients (breaking) (#1499)
This is a port of #1393, targeting the release-v6 consisting of the changes that broke one test or another. Most of these are related to conversions involving the US/British units but there is also some confusion regarding the [Calorie](https://en.wikipedia.org/wiki/Calorie) - the value of `4.1868` was used (instead of `4.184`) in a few places, which is a note-worthy difference. Here are all the tests that broke: - `HeatFlux` : due to the change in `Calorie` - `HeatTransferCoefficient` : due to the change in `Calorie` - `Impulse` : `PoundFootPerSecond`, `SlugFootPerSecond` were represented by a single coefficient that is significantly different from what got: see #1393 (comment) - `Luminosity` : see #1393 (comment). - `Power`: MechanicalHorsepower changed from `{x} * 745.69` to `{x} * 76.0402249 * 9.80665` as given by [this article](https://en.wikipedia.org/wiki/Horsepower#Imperial_horsepower) - `Pressure` the [TechnicalAtmosphere](https://en.wikipedia.org/wiki/Kilogram-force_per_square_centimetre) coefficient (no idea where the old one was taken from), see also #1393 (comment) - `SpecificFuelConsumption` : I'm not a domain expert, but `{x} * 28.33` doesn't look right for `PoundMassPerPoundForceHour` (lb/(lbf·h))- here's what I got: `{x} * 453.59237 / (0.0044482216152605 * 3600)` - `ThermalResistance`: using different conversion coefficients for `BTU` and `Calorie` from the one defined in `Energy` (note: I wasn't able to confirm the "correct" conversion coefficient for BTU). - `VolumetricHeatCapacity`: using different conversion coefficient for `Calorie`
1 parent 3a62360 commit 5a280b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+516
-312
lines changed

Common/UnitDefinitions/HeatFlux.json

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
{
2828
"SingularName": "WattPerSquareInch",
2929
"PluralName": "WattsPerSquareInch",
30-
"FromUnitToBaseFunc": "{x} * 1.5500031e3",
31-
"FromBaseToUnitFunc": "{x} / 1.5500031e3",
30+
"FromUnitToBaseFunc": "{x} / (2.54e-2 * 2.54e-2)",
31+
"FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2)",
3232
"Localization": [
3333
{
3434
"Culture": "en-US",
@@ -39,8 +39,8 @@
3939
{
4040
"SingularName": "WattPerSquareFoot",
4141
"PluralName": "WattsPerSquareFoot",
42-
"FromUnitToBaseFunc": "{x} * 1.07639e1",
43-
"FromBaseToUnitFunc": "{x} / 1.07639e1",
42+
"FromUnitToBaseFunc": "{x} / (0.3048 * 0.3048)",
43+
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048)",
4444
"Localization": [
4545
{
4646
"Culture": "en-US",
@@ -51,8 +51,9 @@
5151
{
5252
"SingularName": "BtuPerSecondSquareInch",
5353
"PluralName": "BtusPerSecondSquareInch",
54-
"FromUnitToBaseFunc": "{x} * 1.63533984e6",
55-
"FromBaseToUnitFunc": "{x} / 1.63533984e6",
54+
"XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.",
55+
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (2.54e-2 * 2.54e-2)",
56+
"FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2) / 1055.05585262",
5657
"Localization": [
5758
{
5859
"Culture": "en-US",
@@ -63,8 +64,9 @@
6364
{
6465
"SingularName": "BtuPerSecondSquareFoot",
6566
"PluralName": "BtusPerSecondSquareFoot",
66-
"FromUnitToBaseFunc": "{x} * 1.13565267e4",
67-
"FromBaseToUnitFunc": "{x} / 1.13565267e4",
67+
"XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.",
68+
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048)",
69+
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048) / 1055.05585262",
6870
"Localization": [
6971
{
7072
"Culture": "en-US",
@@ -75,8 +77,9 @@
7577
{
7678
"SingularName": "BtuPerMinuteSquareFoot",
7779
"PluralName": "BtusPerMinuteSquareFoot",
78-
"FromUnitToBaseFunc": "{x} * 1.89275445e2",
79-
"FromBaseToUnitFunc": "{x} / 1.89275445e2",
80+
"XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.",
81+
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 60)",
82+
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 60) / 1055.05585262",
8083
"Localization": [
8184
{
8285
"Culture": "en-US",
@@ -87,8 +90,9 @@
8790
{
8891
"SingularName": "BtuPerHourSquareFoot",
8992
"PluralName": "BtusPerHourSquareFoot",
90-
"FromUnitToBaseFunc": "{x} * 3.15459075",
91-
"FromBaseToUnitFunc": "{x} / 3.15459075",
93+
"XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.",
94+
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 3600)",
95+
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 3600) / 1055.05585262",
9296
"Localization": [
9397
{
9498
"Culture": "en-US",
@@ -99,8 +103,8 @@
99103
{
100104
"SingularName": "CaloriePerSecondSquareCentimeter",
101105
"PluralName": "CaloriesPerSecondSquareCentimeter",
102-
"FromUnitToBaseFunc": "{x} * 4.1868e4",
103-
"FromBaseToUnitFunc": "{x} / 4.1868e4",
106+
"FromUnitToBaseFunc": "{x} * 4.184e4",
107+
"FromBaseToUnitFunc": "{x} / 4.184e4",
104108
"Prefixes": [ "Kilo" ],
105109
"Localization": [
106110
{
@@ -112,8 +116,8 @@
112116
{
113117
"SingularName": "KilocaloriePerHourSquareMeter",
114118
"PluralName": "KilocaloriesPerHourSquareMeter",
115-
"FromUnitToBaseFunc": "{x} * 1.163",
116-
"FromBaseToUnitFunc": "{x} / 1.163",
119+
"FromUnitToBaseFunc": "{x} * 4.184e3 / 3600",
120+
"FromBaseToUnitFunc": "{x} * 3600 / 4.184e3",
117121
"Localization": [
118122
{
119123
"Culture": "en-US",
@@ -124,8 +128,8 @@
124128
{
125129
"SingularName": "PoundForcePerFootSecond",
126130
"PluralName": "PoundsForcePerFootSecond",
127-
"FromUnitToBaseFunc": "{x} * 1.459390293720636e1",
128-
"FromBaseToUnitFunc": "{x} / 1.459390293720636e1",
131+
"FromUnitToBaseFunc": "{x} * 1.3558179483314004 / 9.290304e-2",
132+
"FromBaseToUnitFunc": "{x} * 9.290304e-2 / 1.3558179483314004",
129133
"Localization": [
130134
{
131135
"Culture": "en-US",

Common/UnitDefinitions/HeatTransferCoefficient.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
{
4646
"SingularName": "BtuPerHourSquareFootDegreeFahrenheit",
4747
"PluralName": "BtusPerHourSquareFootDegreeFahrenheit",
48-
"FromUnitToBaseFunc": "{x} * 5.6782633411134878",
49-
"FromBaseToUnitFunc": "{x} / 5.6782633411134878",
48+
"FromUnitToBaseFunc": "{x} * ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)",
49+
"FromBaseToUnitFunc": "{x} / ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)",
5050
"Localization": [
5151
{
5252
"Culture": "en-US",
@@ -58,8 +58,8 @@
5858
"SingularName": "CaloriePerHourSquareMeterDegreeCelsius",
5959
"PluralName": "CaloriesPerHourSquareMeterDegreeCelsius",
6060
"Prefixes": [ "Kilo" ],
61-
"FromUnitToBaseFunc": "({x} * 4.1868) / 3600",
62-
"FromBaseToUnitFunc": "({x} / 4.1868) * 3600",
61+
"FromUnitToBaseFunc": "({x} * 4.184) / 3600",
62+
"FromBaseToUnitFunc": "({x} / 4.184) * 3600",
6363
"Localization": [
6464
{
6565
"Culture": "en-US",

Common/UnitDefinitions/Impulse.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
"M": "Pound",
5252
"T": "Second"
5353
},
54-
"FromUnitToBaseFunc": "{x} / 7.230657989877",
55-
"FromBaseToUnitFunc": "{x} * 7.230657989877",
54+
"FromUnitToBaseFunc": "{x} * (0.45359237 * 0.3048)",
55+
"FromBaseToUnitFunc": "{x} / (0.45359237 * 0.3048)",
5656
"Localization": [
5757
{
5858
"Culture": "en-US",
@@ -63,8 +63,8 @@
6363
{
6464
"SingularName": "PoundForceSecond",
6565
"PluralName": "PoundForceSeconds",
66-
"FromUnitToBaseFunc": "{x} / 0.2248089430997",
67-
"FromBaseToUnitFunc": "{x} * 0.2248089430997",
66+
"FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665",
67+
"FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)",
6868
"Localization": [
6969
{
7070
"Culture": "en-US",
@@ -80,8 +80,8 @@
8080
"M": "Slug",
8181
"T": "Second"
8282
},
83-
"FromUnitToBaseFunc": "{x} / 0.224735720691",
84-
"FromBaseToUnitFunc": "{x} * 0.224735720691",
83+
"FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665)",
84+
"FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)",
8585
"Localization": [
8686
{
8787
"Culture": "en-US",

Common/UnitDefinitions/Luminosity.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
{
3131
"SingularName": "SolarLuminosity",
3232
"PluralName": "SolarLuminosities",
33-
"FromUnitToBaseFunc": "{x} * 3.846e26",
34-
"FromBaseToUnitFunc": "{x} / 3.846e26",
35-
"XmlDocRemarks": "https://www.britannica.com/science/luminosity",
33+
"XmlDocSummary": "The IAU has defined a nominal solar luminosity of 3.828×10^26 W to promote publication of consistent and comparable values in units of the solar luminosity.",
34+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity#Measurement",
35+
"FromUnitToBaseFunc": "{x} * 3.828e26",
36+
"FromBaseToUnitFunc": "{x} / 3.828e26",
3637
"Localization": [
3738
{
3839
"Culture": "en-US",

Common/UnitDefinitions/Power.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
{
3030
"SingularName": "MechanicalHorsepower",
3131
"PluralName": "MechanicalHorsepower",
32-
"FromUnitToBaseFunc": "{x} * 745.69",
33-
"FromBaseToUnitFunc": "{x} / 745.69",
32+
"XmlDocSummary": "Assuming the third CGPM (1901, CR 70) definition of standard gravity, gn = 9.80665 m/s2, is used to define the pound-force as well as the kilogram force, and the international avoirdupois pound (1959), one imperial horsepower is: 76.0402249 × 9.80665 kg⋅m2/s3",
33+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Imperial_horsepower",
34+
"FromUnitToBaseFunc": "{x} * 76.0402249 * 9.80665",
35+
"FromBaseToUnitFunc": "{x} / (76.0402249 * 9.80665)",
3436
"Localization": [
3537
{
3638
"Culture": "en-US",
@@ -41,8 +43,10 @@
4143
{
4244
"SingularName": "MetricHorsepower",
4345
"PluralName": "MetricHorsepower",
44-
"FromUnitToBaseFunc": "{x} * 735.49875",
45-
"FromBaseToUnitFunc": "{x} / 735.49875",
46+
"XmlDocSummary": "DIN 66036 defines one metric horsepower as the power to raise a mass of 75 kilograms against the Earth's gravitational force over a distance of one metre in one second:[18] 75 kg × 9.80665 m/s2 × 1 m / 1 s = 75 kgf⋅m/s = 1 PS. This is equivalent to 735.49875 W, or 98.6% of an imperial horsepower.",
47+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Metric_horsepower_(PS,_KM,_cv,_hk,_pk,_k,_ks,_ch)",
48+
"FromUnitToBaseFunc": "{x} * 75 * 9.80665",
49+
"FromBaseToUnitFunc": "{x} / (75 * 9.80665)",
4650
"Localization": [
4751
{
4852
"Culture": "en-US",
@@ -53,6 +57,8 @@
5357
{
5458
"SingularName": "ElectricalHorsepower",
5559
"PluralName": "ElectricalHorsepower",
60+
"XmlDocSummary": "Nameplates on electrical motors show their power output, not the power input (the power delivered at the shaft, not the power consumed to drive the motor). This power output is ordinarily stated in watts or kilowatts. In the United States, the power output is stated in horsepower, which for this purpose is defined as exactly 746 W.",
61+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Electrical_horsepower",
5662
"FromUnitToBaseFunc": "{x} * 746",
5763
"FromBaseToUnitFunc": "{x} / 746",
5864
"Localization": [
@@ -65,6 +71,8 @@
6571
{
6672
"SingularName": "BoilerHorsepower",
6773
"PluralName": "BoilerHorsepower",
74+
"XmlDocSummary": "Boiler horsepower is a boiler's capacity to deliver steam to a steam engine and is not the same unit of power as the 550 ft lb/s definition. One boiler horsepower is equal to the thermal energy rate required to evaporate 34.5 pounds (15.6 kg) of fresh water at 212 °F (100 °C) in one hour.",
75+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Boiler_horsepower",
6876
"FromUnitToBaseFunc": "{x} * 9812.5",
6977
"FromBaseToUnitFunc": "{x} / 9812.5",
7078
"Localization": [
@@ -77,8 +85,10 @@
7785
{
7886
"SingularName": "HydraulicHorsepower",
7987
"PluralName": "HydraulicHorsepower",
80-
"FromUnitToBaseFunc": "{x} * 745.69988145",
81-
"FromBaseToUnitFunc": "{x} / 745.69988145",
88+
"XmlDocSummary": "Hydraulic horsepower can represent the power available within hydraulic machinery, power through the down-hole nozzle of a drilling rig, or can be used to estimate the mechanical power needed to generate a known hydraulic flow rate.",
89+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Hydraulic_horsepower",
90+
"FromUnitToBaseFunc": "{x} * 745.69987158227022",
91+
"FromBaseToUnitFunc": "{x} / 745.69987158227022",
8292
"Localization": [
8393
{
8494
"Culture": "en-US",
@@ -89,8 +99,9 @@
8999
{
90100
"SingularName": "BritishThermalUnitPerHour",
91101
"PluralName": "BritishThermalUnitsPerHour",
92-
"FromUnitToBaseFunc": "{x} * 0.29307107017",
93-
"FromBaseToUnitFunc": "{x} / 0.29307107017",
102+
"XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.",
103+
"FromUnitToBaseFunc": "{x} * 1055.05585262 / 3600",
104+
"FromBaseToUnitFunc": "{x} * 3600 / 1055.05585262",
94105
"Prefixes": [ "Kilo", "Mega" ],
95106
"Localization": [
96107
{

0 commit comments

Comments
 (0)