Skip to content

Fix five conversion factors that disagree with their definitions - #1743

Open
tmilnthorp wants to merge 2 commits into
angularsen:masterfrom
tmilnthorp:tmilntho/fix-conversion-factors
Open

tmilnthorp wants to merge 2 commits into
angularsen:masterfrom
tmilnthorp:tmilntho/fix-conversion-factors

Conversation

@tmilnthorp

Copy link
Copy Markdown
Collaborator

Five units convert with a factor that doesn't match the unit's definition. This fixes them and updates the test values to the exact reciprocals.

Unit Old New Relative change
Power.BoilerHorsepower 9812.5 W 9809.5 W −3.1e-4
Energy.ThermEc 1.05505585262e8 J 1.05506e8 J +3.9e-6
LeakRate.TorrLiterPerSecond 1/7.5 = 0.133333 Pa·m³/s 101325/760 × 1e-3 = 0.1333224 Pa·m³/s −8.2e-5
Temperature.SolarTemperature 5778 K 5772 K −1.0e-3
Mass.SolarMass 1.98947e30 kg 1.98847e30 kg −5.0e-4

Sources and history

BoilerHorsepower. NIST SP 811, Appendix B.8: horsepower (boiler) = 9.80950 E+03 W. The old value came from the original horsepower units in 2015 (#65, "as defined on Wikipedia"); the value itself was never discussed.

There are two boiler horsepower variants (Wikipedia):

  • the 1884 ASME definition, about 33,469.5 BTU/h (9809.5 W), which is the NIST value used here;
  • current industrial practice, 33,475 BTU/h (about 9811 W).

The old 9812.5 W matches neither. The unit's doc now says which variant it is.

ThermEc. NIST SP 811, Appendix B.8: therm (EC) = 1.05506 E+08 J. The EC therm is defined as 100,000 BTU_ISO = exactly 105,506,000 J (Wikipedia, citing the EC Official Journal L 073 of 1972). The old value was 100,000 BTU_IT instead. ThermUs (1.054804e8) and ThermImperial already match their definitions and are unchanged.

TorrLiterPerSecond. 1 Torr is exactly 101325/760 Pa (NIST SP 811: 1.333224 E+02 Pa), and 1 L = 1e-3 m³. This is the same torr that Pressure.Torr already uses ({x} * 101325 / 760), so today a leak rate in Torr·L/s and a pressure in Torr times a volume flow in L/s disagree by 82 ppm.

The value 7.5 was added with LeakRate in #1222, and verified at the time against sensorsone.com, which shows the rounded figure. Leak rate references commonly quote 1 mbar·L/s ≈ 0.75 Torr·L/s for the same reason, but the exact ratio is 0.750062.

SolarTemperature. IAU 2015 Resolution B3 adopts a nominal solar effective temperature of 5772 K as a conversion constant (Prša et al. 2016, arXiv:1510.07674). The same resolution defines the nominal solar radius and luminosity:

5778 K is an older literature value. It was added in #683 without a source.

SolarMass. The old value, 1.98947e30, doesn't match any published value. It looks like a typo of 1.98847e30. The unit links to Wikipedia, which currently gives two values:

  • Best estimate: (1.988475 ± 0.000092)e30 kg.
  • Nominal solar mass: 1.988416e30 kg.

The IAU defines only a nominal mass parameter (GM), so the nominal mass in kg is that parameter divided by the measured G, and it changes when G is revised. This PR uses 1.98847e30, within the uncertainty of the best estimate, as the smallest correction. If you'd prefer the IAU-derived nominal value for consistency with SolarRadius, I'm happy to change it. The value was added in #680.

Docs

Each changed unit's XmlDocSummary now states the value used and its source, and XmlDocRemarks links to that source:

  • NIST SP 811 Appendix B.8 for BoilerHorsepower, ThermEc and TorrLiterPerSecond;
  • arXiv:1510.07674 for SolarTemperature;
  • the existing Wikipedia link for SolarMass.

ThermEc had the generic therm description shared by all three therms; it now describes the EC therm specifically. TorrLiterPerSecond and SolarTemperature had no docs.

Also

Mass.json had a trailing comma after its last unit, which isn't valid JSON. CodeGen's parser tolerates it, but other tools don't.

Not included

A broader audit of the unit definitions found other candidates. They need a decision about which variant to use, so they're left for separate PRs:

  • Pressure.MeterOfHead uses a water density of 999.744 kg/m³; MeterOfWaterColumn uses 1000.
  • The thermochemical calorie is mixed with the IT BTU in several heat-transfer quantities.
  • Speed.Mach uses a fixed 340.29 m/s with no reference conditions.

Testing

  • The test values (...InOne<BaseUnit>) are updated to the exact reciprocals of the new factors.
  • UnitsNet.Tests passes on net10.0. The only failures are two FeetInchesTests de-CH cases, which fail on master on my machine too and pass on CI.

The regenerated code is a separate commit.

🤖 Generated with Claude Code

https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG

tmilnthorp and others added 2 commits October 6, 2026 21:09
- BoilerHorsepower: 9812.5 W -> 9809.5 W (NIST SP 811, Appendix B.8).
- ThermEc: 1.05505585262e8 J (100,000 BTU_IT) -> 1.05506e8 J, the
  defined EC therm (NIST SP 811, Appendix B.8).
- TorrLiterPerSecond: 1/7.5 Pa·m³/s -> 101325/760 * 1e-3 Pa·m³/s, using
  the exact torr, as Pressure.Torr already does. 7.5 is a rounding.
- SolarTemperature: 5778 K -> 5772 K, the IAU 2015 Resolution B3 nominal
  solar effective temperature, like SolarRadius and SolarLuminosity.
- SolarMass: 1.98947e30 kg -> 1.98847e30 kg. The old value matches no
  source and looks like a typo; the new one is within the uncertainty of
  the current best estimate (1.988475 ± 0.000092) e30 kg.

Each changed unit's XmlDocSummary now states the value used and its
source, and XmlDocRemarks links to it. ThermEc gets a description of the
EC therm instead of the generic one, and TorrLiterPerSecond and
SolarTemperature get docs.

Also removes a trailing comma in Mass.json, which isn't valid JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98%. Comparing base (3bf1ef4) to head (00be8c8).

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1743   +/-   ##
======================================
  Coverage      98%     98%           
======================================
  Files         515     515           
  Lines       24092   24092           
======================================
  Hits        23692   23692           
  Misses        400     400           
Flag Coverage Δ
net48 97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant