Physical constants

Welcome to the Discourse, Bob! :slightly_smiling_face:

One other thing: this has been tested with gfortran 9 & 10 on Linux, Windows, and MacOS because those are relatively accessible. I’ve tried to stick with F2018 compliance but I don’t have access to commercial compilers (Intel, PGI, IBM, etc.). There is an issue with single precision support - several parameters overflow or underflow to nothing in REAL32; in those cases single precision constants aren’t provided. I haven’t tested on anything but x86_64 with gfortran so I’m curious how well the code compiles on other architectures and using different compilers.

2 Likes

Thanks again for posting a link to the code; hopefully I’ll be less of a hermit going forward :slight_smile:

3 Likes

I have created a dev branch in my project:
https://github.com/vmagnin/fundamental_constants/tree/dev
where I have:

  • renamed all the validated modules using the following model: CODATA_2018_constants.f90,
  • moved them in the src directory,
  • created CODATA_latest_constants.f90 simply using the latest available module (2018 at the moment).

I have tested that it could be imported by fpm as a dependency by putting into a fpm.toml file ā€œdepenciesā€ section:

fundamental_constants = { git="https://github.com/vmagnin/fundamental_constants.git", branch="dev"}

Any comments welcome!

2 Likes

The structure constructor is needed if the codata has parameter attribute.

1 Like

The 2014 and 2010 URLs have changed on the NIST website. I have modified them in my project GitHub - vmagnin/fundamental_constants: Fortran modules with the CODATA fundamental physical constants, generated by a Python script.

The 2022 CODATA values should be made available in 2023:

The results of the 2022 CODATA-TGFC adjustment will be made available later in 2023 with the accepted input data and analysis published in a review article.

3 Likes

This is a good point, but the definitions of the fundamental and derived constants can change over time. Before a decade ago, the speed of light was a measured quantity, now it is a defined constant. Similarly, a meter used to be a defined constant, then it became a derived quantity. Avagodro’s number used to be a measured value, now it is a defined integer. So if we use these values in our programs in an automatic way, it must be able to adapt to those changes in the future.

Good point. This is a question of units. A particular value might overflow or underflow in one set of units, say SI units, while it has a reasonable value O(1) in another set of units, say cgs units, or in my field of quantum chemistry, in what we call atomic units. Is there a good way to extract values from the module and do the unit conversions at the same time in order to avoid the over/under flow issue?

2 Likes