Skip to content

Decompose unit conversion functions to exact coefficients (breaking) #1499

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 5 commits into from
Apr 6, 2025
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
40 changes: 22 additions & 18 deletions Common/UnitDefinitions/HeatFlux.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
{
"SingularName": "WattPerSquareInch",
"PluralName": "WattsPerSquareInch",
"FromUnitToBaseFunc": "{x} * 1.5500031e3",
"FromBaseToUnitFunc": "{x} / 1.5500031e3",
"FromUnitToBaseFunc": "{x} / (2.54e-2 * 2.54e-2)",
"FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -39,8 +39,8 @@
{
"SingularName": "WattPerSquareFoot",
"PluralName": "WattsPerSquareFoot",
"FromUnitToBaseFunc": "{x} * 1.07639e1",
"FromBaseToUnitFunc": "{x} / 1.07639e1",
"FromUnitToBaseFunc": "{x} / (0.3048 * 0.3048)",
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -51,8 +51,9 @@
{
"SingularName": "BtuPerSecondSquareInch",
"PluralName": "BtusPerSecondSquareInch",
"FromUnitToBaseFunc": "{x} * 1.63533984e6",
"FromBaseToUnitFunc": "{x} / 1.63533984e6",
"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.",
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (2.54e-2 * 2.54e-2)",
"FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2) / 1055.05585262",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -63,8 +64,9 @@
{
"SingularName": "BtuPerSecondSquareFoot",
"PluralName": "BtusPerSecondSquareFoot",
"FromUnitToBaseFunc": "{x} * 1.13565267e4",
"FromBaseToUnitFunc": "{x} / 1.13565267e4",
"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.",
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048)",
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048) / 1055.05585262",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -75,8 +77,9 @@
{
"SingularName": "BtuPerMinuteSquareFoot",
"PluralName": "BtusPerMinuteSquareFoot",
"FromUnitToBaseFunc": "{x} * 1.89275445e2",
"FromBaseToUnitFunc": "{x} / 1.89275445e2",
"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.",
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 60)",
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 60) / 1055.05585262",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -87,8 +90,9 @@
{
"SingularName": "BtuPerHourSquareFoot",
"PluralName": "BtusPerHourSquareFoot",
"FromUnitToBaseFunc": "{x} * 3.15459075",
"FromBaseToUnitFunc": "{x} / 3.15459075",
"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.",
"FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 3600)",
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 3600) / 1055.05585262",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -99,8 +103,8 @@
{
"SingularName": "CaloriePerSecondSquareCentimeter",
"PluralName": "CaloriesPerSecondSquareCentimeter",
"FromUnitToBaseFunc": "{x} * 4.1868e4",
"FromBaseToUnitFunc": "{x} / 4.1868e4",
"FromUnitToBaseFunc": "{x} * 4.184e4",
"FromBaseToUnitFunc": "{x} / 4.184e4",
"Prefixes": [ "Kilo" ],
"Localization": [
{
Expand All @@ -112,8 +116,8 @@
{
"SingularName": "KilocaloriePerHourSquareMeter",
"PluralName": "KilocaloriesPerHourSquareMeter",
"FromUnitToBaseFunc": "{x} * 1.163",
"FromBaseToUnitFunc": "{x} / 1.163",
"FromUnitToBaseFunc": "{x} * 4.184e3 / 3600",
"FromBaseToUnitFunc": "{x} * 3600 / 4.184e3",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -124,8 +128,8 @@
{
"SingularName": "PoundForcePerFootSecond",
"PluralName": "PoundsForcePerFootSecond",
"FromUnitToBaseFunc": "{x} * 1.459390293720636e1",
"FromBaseToUnitFunc": "{x} / 1.459390293720636e1",
"FromUnitToBaseFunc": "{x} * 1.3558179483314004 / 9.290304e-2",
"FromBaseToUnitFunc": "{x} * 9.290304e-2 / 1.3558179483314004",
"Localization": [
{
"Culture": "en-US",
Expand Down
8 changes: 4 additions & 4 deletions Common/UnitDefinitions/HeatTransferCoefficient.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
{
"SingularName": "BtuPerHourSquareFootDegreeFahrenheit",
"PluralName": "BtusPerHourSquareFootDegreeFahrenheit",
"FromUnitToBaseFunc": "{x} * 5.6782633411134878",
"FromBaseToUnitFunc": "{x} / 5.6782633411134878",
"FromUnitToBaseFunc": "{x} * ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)",
"FromBaseToUnitFunc": "{x} / ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -58,8 +58,8 @@
"SingularName": "CaloriePerHourSquareMeterDegreeCelsius",
"PluralName": "CaloriesPerHourSquareMeterDegreeCelsius",
"Prefixes": [ "Kilo" ],
"FromUnitToBaseFunc": "({x} * 4.1868) / 3600",
"FromBaseToUnitFunc": "({x} / 4.1868) * 3600",
"FromUnitToBaseFunc": "({x} * 4.184) / 3600",
"FromBaseToUnitFunc": "({x} / 4.184) * 3600",
"Localization": [
{
"Culture": "en-US",
Expand Down
12 changes: 6 additions & 6 deletions Common/UnitDefinitions/Impulse.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"M": "Pound",
"T": "Second"
},
"FromUnitToBaseFunc": "{x} / 7.230657989877",
"FromBaseToUnitFunc": "{x} * 7.230657989877",
"FromUnitToBaseFunc": "{x} * (0.45359237 * 0.3048)",
"FromBaseToUnitFunc": "{x} / (0.45359237 * 0.3048)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -63,8 +63,8 @@
{
"SingularName": "PoundForceSecond",
"PluralName": "PoundForceSeconds",
"FromUnitToBaseFunc": "{x} / 0.2248089430997",
"FromBaseToUnitFunc": "{x} * 0.2248089430997",
"FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665",
"FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -80,8 +80,8 @@
"M": "Slug",
"T": "Second"
},
"FromUnitToBaseFunc": "{x} / 0.224735720691",
"FromBaseToUnitFunc": "{x} * 0.224735720691",
"FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665)",
"FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)",
"Localization": [
{
"Culture": "en-US",
Expand Down
7 changes: 4 additions & 3 deletions Common/UnitDefinitions/Luminosity.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
{
"SingularName": "SolarLuminosity",
"PluralName": "SolarLuminosities",
"FromUnitToBaseFunc": "{x} * 3.846e26",
"FromBaseToUnitFunc": "{x} / 3.846e26",
"XmlDocRemarks": "https://www.britannica.com/science/luminosity",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity#Measurement",
"FromUnitToBaseFunc": "{x} * 3.828e26",
"FromBaseToUnitFunc": "{x} / 3.828e26",
"Localization": [
{
"Culture": "en-US",
Expand Down
27 changes: 19 additions & 8 deletions Common/UnitDefinitions/Power.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
{
"SingularName": "MechanicalHorsepower",
"PluralName": "MechanicalHorsepower",
"FromUnitToBaseFunc": "{x} * 745.69",
"FromBaseToUnitFunc": "{x} / 745.69",
"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",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Imperial_horsepower",
"FromUnitToBaseFunc": "{x} * 76.0402249 * 9.80665",
"FromBaseToUnitFunc": "{x} / (76.0402249 * 9.80665)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -41,8 +43,10 @@
{
"SingularName": "MetricHorsepower",
"PluralName": "MetricHorsepower",
"FromUnitToBaseFunc": "{x} * 735.49875",
"FromBaseToUnitFunc": "{x} / 735.49875",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Metric_horsepower_(PS,_KM,_cv,_hk,_pk,_k,_ks,_ch)",
"FromUnitToBaseFunc": "{x} * 75 * 9.80665",
"FromBaseToUnitFunc": "{x} / (75 * 9.80665)",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -53,6 +57,8 @@
{
"SingularName": "ElectricalHorsepower",
"PluralName": "ElectricalHorsepower",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Electrical_horsepower",
"FromUnitToBaseFunc": "{x} * 746",
"FromBaseToUnitFunc": "{x} / 746",
"Localization": [
Expand All @@ -65,6 +71,8 @@
{
"SingularName": "BoilerHorsepower",
"PluralName": "BoilerHorsepower",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Boiler_horsepower",
"FromUnitToBaseFunc": "{x} * 9812.5",
"FromBaseToUnitFunc": "{x} / 9812.5",
Copy link
Owner

Choose a reason for hiding this comment

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

Hard to say which value to go with..
https://en.wikipedia.org/wiki/Horsepower#Boiler_horsepower

This revised definition is equivalent to a boiler heat output of 33,469 Btu/h (9.809 kW)
Present industrial practice is to define "boiler horsepower" as a boiler thermal output equal to 33,475 Btu/h (9.811 kW),[citation needed] which is very close to the original and revised definitions.

So.. 9811 then?

"Localization": [
Expand All @@ -77,8 +85,10 @@
{
"SingularName": "HydraulicHorsepower",
"PluralName": "HydraulicHorsepower",
"FromUnitToBaseFunc": "{x} * 745.69988145",
"FromBaseToUnitFunc": "{x} / 745.69988145",
"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.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Hydraulic_horsepower",
"FromUnitToBaseFunc": "{x} * 745.69987158227022",
"FromBaseToUnitFunc": "{x} / 745.69987158227022",
"Localization": [
{
"Culture": "en-US",
Expand All @@ -89,8 +99,9 @@
{
"SingularName": "BritishThermalUnitPerHour",
"PluralName": "BritishThermalUnitsPerHour",
"FromUnitToBaseFunc": "{x} * 0.29307107017",
"FromBaseToUnitFunc": "{x} / 0.29307107017",
"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.",
"FromUnitToBaseFunc": "{x} * 1055.05585262 / 3600",
"FromBaseToUnitFunc": "{x} * 3600 / 1055.05585262",
"Prefixes": [ "Kilo", "Mega" ],
"Localization": [
{
Expand Down
Loading