Skip to content
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

Update to new SI definition and CODATA 2018 #811

Merged
merged 4 commits into from
May 25, 2019
Merged

Conversation

Jellby
Copy link
Contributor

@Jellby Jellby commented May 23, 2019

The SI has been redefined, by giving exact values to the Planck, Boltzmann and Avogadro constants, and the elementary charge. There are also new recommended values for other constants (CODATA 2018).

I've rewritten the constants-en.txt and default-en.txt according to these changes and also, I believe, for a better structure. The most significant changes:

  • All units and constants defined from a few "experimental" values.
  • For as much as I could find them, all factors are exact, except when noted. Floating point representation can introduce inaccuracies, though.
  • US and imperial units may have changed their "reference" (to what I considered is most reasonable or authoritative), in practice values stay the same within floating point errors.
  • Added some units and quantities.
  • Fixed some units like Nm or au and parsec.
  • Set the default Btu to the "ISO" Btu, and the default year to the Julian year (as recommended by the IAU)
  • Defined units of the Gaussian system consistently, which makes them have different dimensionality from the corresponding SI units. Added a Gaussian context to allow conversions (with some caveats).
  • Removed some units for which I could find no definition or reasonable use: chemical_faraday, physical_faraday, sidereal_hour, sidereal_minute, sidereal_second, work_year, work_month (they can of course be added back, hopefully with a better formal definition).
  • Added atomic and Planck systems.
  • Rearranged the order of units to "importance" (kind of) or field, rather than alphabetic.

I'm happy to undo some of the changes if they are considered undesirable. Note if/when #809 is accepted, I'd like to apply some minor fixes here.

Had to modify a couple of tests:

  • For some reason (floating point errors, I guess), 4 mM -> mole/liter is no longer equal to 4e-3 M, only "almost equal".
  • Updated the value of the Boltzmann constant in a test, a difference of 1.45e-5 % seems to be too much.

Adopt new SI definition and CODATA 2018 values, create Gaussian context
@hgrecco
Copy link
Owner

hgrecco commented May 23, 2019

I have merged #809 This commit still has problems.

@Jellby
Copy link
Contributor Author

Jellby commented May 23, 2019

You mean the checks? I'm trying to debug it. It fails only with python 2, with:

molar = mole / (1e-3 * meter ** 3) = M

it passes, but with;

molar = mole / liter = M

it fails, saying:

======================================================================
ERROR: test_issue29 (test_issues.TestIssues)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ignacio/test/pint/pint/testsuite/test_issues.py", line 46, in test_issue29
    self.assertAlmostEqual(t.to('mole / liter'), 4e-3 * ureg('M'))
  File "/usr/lib/python2.7/unittest/case.py", line 555, in assertAlmostEqual
    if round(abs(second-first), places) == 0:
  File "/home/ignacio/test/pint/pint/quantity.py", line 600, in __float__
    raise DimensionalityError(self._units, 'dimensionless')
DimensionalityError: Cannot convert from 'molar' to 'dimensionless'

which makes no sense to me. It looks like there is some bug unrelated to this PR.

@hgrecco
Copy link
Owner

hgrecco commented May 23, 2019

agreed. Weird.

@Jellby
Copy link
Contributor Author

Jellby commented May 23, 2019

Should I change test_issue29 to: watt = joule / second instead of molar = mole / liter ? It seems to pass that way, but I don't know if that is fully equivalent for the purpose. Any other idea?

@hgrecco
Copy link
Owner

hgrecco commented May 25, 2019

Change it as you have suggested.

Jellby added 2 commits May 25, 2019 09:00
Add _ for no-symbol, update degrees, remove duplicates in xtranslated.txt, change test from M to W.
@hgrecco
Copy link
Owner

hgrecco commented May 25, 2019

bors r+

bors bot added a commit that referenced this pull request May 25, 2019
811: Update to new SI definition and CODATA 2018 r=hgrecco a=Jellby

The SI has been redefined, by giving exact values to the Planck, Boltzmann and Avogadro constants, and the elementary charge. There are also new recommended values for other constants (CODATA 2018).

I've rewritten the `constants-en.txt` and `default-en.txt` according to these changes and also, I believe, for a better structure. The most significant changes:

* All units and constants defined from a few "experimental" values.
* For as much as I could find them, all factors are exact, except when noted. Floating point representation can introduce inaccuracies, though.
* US and imperial units may have changed their "reference" (to what I considered is most reasonable or authoritative), in practice values stay the same within floating point errors.
* Added some units and quantities.
* Fixed some units like Nm or au and parsec.
* Set the default Btu to the "ISO" Btu, and the default year to the Julian year (as recommended by the IAU)
* Defined units of the Gaussian system consistently, which makes them have different dimensionality from the corresponding SI units. Added a Gaussian context to allow conversions (with some caveats).
* Removed some units for which I could find no definition or reasonable use: chemical_faraday, physical_faraday, sidereal_hour, sidereal_minute, sidereal_second, work_year, work_month (they can of course be added back, hopefully with a better formal definition).
* Added atomic and Planck systems.
* Rearranged the order of units to "importance" (kind of) or field, rather than alphabetic.

I'm happy to undo some of the changes if they are considered undesirable. Note if/when #809 is accepted, I'd like to apply some minor fixes here.


Had to modify a couple of tests:

* For some reason (floating point errors, I guess), 4 mM -> mole/liter is no longer equal to 4e-3 M, only "almost equal".
* Updated the value of the Boltzmann constant in a test, a difference of 1.45e-5 % seems to be too much.

Co-authored-by: Jellby <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 25, 2019

Build succeeded

@crusaderky
Copy link
Contributor

Closes #506
Closes #542

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.

4 participants