-
Notifications
You must be signed in to change notification settings - Fork 188
Codata constants. #800
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
Codata constants. #800
Changes from all commits
Commits
Show all changes
146 commits
Select commit
Hold shift + click to select a range
d0fbca0
Add codata constants.
MilanSkocic be97e8c
Add generic facility and mimic scipy constant module.
MilanSkocic 31e2ce1
Uncomment fypp include statement.
MilanSkocic 2dcca26
Fix typo in gravitation_constant.
MilanSkocic 4750e7b
Set KINDS as REAL_KINDS from common.fypp
MilanSkocic 359694d
Set KINDS as REAL_KINDS from common.fypp.
MilanSkocic 4cfd815
Automatic generation of PI with different precisions from KINDS.
MilanSkocic 912b590
Add doc stdlib_constants.md in docs/specs/
MilanSkocic e73f743
ENH: Add example_constants.f90 in example/constants/.
MilanSkocic 1994601
Modify doc stdlib_constants.md
MilanSkocic ac8eb45
Add constants documentation in index.
MilanSkocic d4fa81e
Add to_real for consistency with stdlib.
MilanSkocic 40fa472
Update example and add CMakeLists.txt in constant folder.
MilanSkocic 68d38d3
Update docs/specs/stdlib_constants.md.
MilanSkocic cc64658
Update doc/specs/stdlib_constants.md
MilanSkocic 7875707
Update doc/specs/stdlib_constants.md. Spelling error.
MilanSkocic d230ea3
Update example/constants/example_constants.f90.
MilanSkocic 3f88e5c
Update example/constants/example_constants.f90
MilanSkocic c044980
Update src/stdlib_codata_type.fypp. Consistency with DT in stdlib.
MilanSkocic 2843c81
Update src/stdlib_codata_type.fypp. Docstring for real function.
MilanSkocic 3e29a0a
Update src/stdlib_codata_type.fypp. Docstring for DT.
MilanSkocic 891c611
Rename DT tp codata_constant_type for consistency with the stdlib.
MilanSkocic c74828e
Update doc/specs/stdlib_constants.
MilanSkocic dcb52fe
Update codata constants with the 2022 release.
MilanSkocic 85233d5
Update documentation with the link to the Python script for generatin…
MilanSkocic 49463c0
Update documentation for the interface to_real.
MilanSkocic f222f80
Fix underscores in 2 variables.
MilanSkocic 067b77c
Add tests for codata constants (values and uncertainties).
MilanSkocic 5d14342
Set cmake files for the tests of the codata constants.
MilanSkocic 8b67f04
Fix format for the print function.
MilanSkocic 6edd907
Fix reference to codata_constant_type in documentation.
MilanSkocic c47399f
Fix link to the repo where the python script for generating the codat…
MilanSkocic 2cad5e7
Fix typo.
MilanSkocic 9730f3d
Update doc/specs/stdlib_constants.md
MilanSkocic 202b8ff
Update doc/specs/stdlib_constants.md
MilanSkocic 2853bde
Update doc/specs/stdlib_constants.md
MilanSkocic d97fa2a
Update doc/specs/stdlib_constants.md
MilanSkocic 4b67e99
Update doc/specs/stdlib_constants.md
MilanSkocic 73568a7
Update test/constants/test_constants.f90
MilanSkocic f4428b4
Update test/constants/test_constants.f90
MilanSkocic 9b08666
Update test/constants/test_constants.f90
MilanSkocic 30570b6
Update test/constants/test_constants.f90
MilanSkocic 7ba4787
Update test/constants/test_constants.f90
MilanSkocic b404273
Update test/constants/test_constants.f90
MilanSkocic e171775
Update test/constants/test_constants.f90
MilanSkocic 0142cbb
Update test/constants/test_constants.f90
MilanSkocic 6506424
Update test/constants/test_constants.f90
MilanSkocic e8e529a
Update test/constants/test_constants.f90
MilanSkocic 2c828ab
Update test/constants/test_constants.f90
MilanSkocic 0d15a22
Update test/constants/test_constants.f90
MilanSkocic 9154070
Update test/constants/test_constants.f90
MilanSkocic 50609ca
Update test/constants/test_constants.f90
MilanSkocic 8623efb
Update test/constants/test_constants.f90
MilanSkocic e407ad6
Update test/constants/test_constants.f90
MilanSkocic 43a90bd
Update test/constants/test_constants.f90
MilanSkocic 2731820
Update test/constants/test_constants.f90
MilanSkocic 7bfbd51
Update test/constants/test_constants.f90
MilanSkocic 27575d7
Update test/constants/test_constants.f90
MilanSkocic 5dcecb7
Update test/constants/test_constants.f90
MilanSkocic 97a4c88
Update test/constants/test_constants.f90
MilanSkocic baed382
Update test/constants/test_constants.f90
MilanSkocic 5fea52f
Update test/constants/test_constants.f90
MilanSkocic 37791c0
Update test/constants/test_constants.f90
MilanSkocic 2e93d3c
Update test/constants/test_constants.f90
MilanSkocic 443ddf6
Update test/constants/test_constants.f90
MilanSkocic f281240
Update test/constants/test_constants.f90
MilanSkocic 2490030
Update test/constants/test_constants.f90
MilanSkocic 83d46a8
Update test/constants/test_constants.f90
MilanSkocic 6eaea45
Add fac as module level variable.
MilanSkocic 3120376
Direct comparison for tests.
MilanSkocic 8ca1088
Fix arguments order in call to check function.
MilanSkocic e331d56
Add codata constants.
MilanSkocic 912608f
Add codata constants.
MilanSkocic 3326151
Uncomment fypp include statement.
MilanSkocic 2bddb54
Fix typo in gravitation_constant.
MilanSkocic 064828d
Set KINDS as REAL_KINDS from common.fypp
MilanSkocic 970ee5f
Set KINDS as REAL_KINDS from common.fypp.
MilanSkocic 6d2c9f2
Automatic generation of PI with different precisions from KINDS.
MilanSkocic a77709b
Add doc stdlib_constants.md in docs/specs/
MilanSkocic 1342ae3
ENH: Add example_constants.f90 in example/constants/.
MilanSkocic e14f83a
Modify doc stdlib_constants.md
MilanSkocic 409991d
Add constants documentation in index.
MilanSkocic c536ee5
Add to_real for consistency with stdlib.
MilanSkocic dc51fab
Update example and add CMakeLists.txt in constant folder.
MilanSkocic dc56497
Update docs/specs/stdlib_constants.md.
MilanSkocic a061a11
Update doc/specs/stdlib_constants.md
MilanSkocic dba4a5a
Update doc/specs/stdlib_constants.md. Spelling error.
MilanSkocic 546d54c
Update example/constants/example_constants.f90.
MilanSkocic 0427b01
Update example/constants/example_constants.f90
MilanSkocic 4ad9ae8
Update src/stdlib_codata_type.fypp. Consistency with DT in stdlib.
MilanSkocic 9090c6b
Update src/stdlib_codata_type.fypp. Docstring for real function.
MilanSkocic b5bdc14
Update src/stdlib_codata_type.fypp. Docstring for DT.
MilanSkocic e74ec41
Rename DT tp codata_constant_type for consistency with the stdlib.
MilanSkocic 00c789a
Update doc/specs/stdlib_constants.
MilanSkocic 3ddef7a
Update codata constants with the 2022 release.
MilanSkocic 4ac5d84
Update documentation with the link to the Python script for generatin…
MilanSkocic 6557d91
Update documentation for the interface to_real.
MilanSkocic 9821c0d
Fix underscores in 2 variables.
MilanSkocic add6ff5
Add tests for codata constants (values and uncertainties).
MilanSkocic 5c49605
Set cmake files for the tests of the codata constants.
MilanSkocic 1c6fc23
Fix format for the print function.
MilanSkocic 340454d
Fix reference to codata_constant_type in documentation.
MilanSkocic d07d9c8
Fix link to the repo where the python script for generating the codat…
MilanSkocic c62e526
Fix typo.
MilanSkocic 26ff73c
Update doc/specs/stdlib_constants.md
MilanSkocic 35b5da6
Update doc/specs/stdlib_constants.md
MilanSkocic de867cc
Update doc/specs/stdlib_constants.md
MilanSkocic 5775ff7
Update doc/specs/stdlib_constants.md
MilanSkocic d999a01
Update doc/specs/stdlib_constants.md
MilanSkocic 304519a
Update test/constants/test_constants.f90
MilanSkocic 7bfcd51
Update test/constants/test_constants.f90
MilanSkocic 7a9437c
Update test/constants/test_constants.f90
MilanSkocic 98427e4
Update test/constants/test_constants.f90
MilanSkocic c751fd0
Update test/constants/test_constants.f90
MilanSkocic 415b3b6
Update test/constants/test_constants.f90
MilanSkocic 9a120f5
Update test/constants/test_constants.f90
MilanSkocic fa6bd80
Update test/constants/test_constants.f90
MilanSkocic f729f89
Update test/constants/test_constants.f90
MilanSkocic 852a02a
Update test/constants/test_constants.f90
MilanSkocic ccaa29f
Update test/constants/test_constants.f90
MilanSkocic ba13328
Update test/constants/test_constants.f90
MilanSkocic 0317123
Update test/constants/test_constants.f90
MilanSkocic d1e1b74
Update test/constants/test_constants.f90
MilanSkocic 6ac6333
Update test/constants/test_constants.f90
MilanSkocic a413e24
Update test/constants/test_constants.f90
MilanSkocic 32a3920
Update test/constants/test_constants.f90
MilanSkocic 6131205
Update test/constants/test_constants.f90
MilanSkocic 62d6473
Update test/constants/test_constants.f90
MilanSkocic 28e3760
Update test/constants/test_constants.f90
MilanSkocic c5c1d5d
Update test/constants/test_constants.f90
MilanSkocic acd099c
Update test/constants/test_constants.f90
MilanSkocic 81d987f
Update test/constants/test_constants.f90
MilanSkocic e75bb8a
Update test/constants/test_constants.f90
MilanSkocic 262595c
Update test/constants/test_constants.f90
MilanSkocic b9a16a6
Update test/constants/test_constants.f90
MilanSkocic bac6e47
Update test/constants/test_constants.f90
MilanSkocic bbcc33e
Update test/constants/test_constants.f90
MilanSkocic a79e01f
Update test/constants/test_constants.f90
MilanSkocic a184072
Update test/constants/test_constants.f90
MilanSkocic 5948700
Add fac as module level variable.
MilanSkocic 18989aa
Direct comparison for tests.
MilanSkocic caa5034
Fix arguments order in call to check function.
MilanSkocic 1bd2716
Merge after rebase.
MilanSkocic 79e0300
Merge branch 'fortran-lang:master' into master
MilanSkocic b24f3c6
Add warning for short names and how to alias them.
MilanSkocic b824cab
Fix spelling in example.
MilanSkocic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: constants | ||
--- | ||
|
||
[TOC] | ||
|
||
## Introduction | ||
|
||
|
||
The [[stdlib_constants]] module provides mathematical constants and the most common physical constants. | ||
|
||
**Warning**: The names of the most common physical constants are kept short as they are inside a dedicated module. | ||
Nonetheless, in case of overlapping names, they can always be renamed as following: | ||
|
||
```fortran | ||
use stdlib_constants, only: clight => c | ||
``` | ||
|
||
## Codata | ||
|
||
The [[stdlib_codata(module)]] module defines all codata (physical) constants as derived | ||
type. The module is automatically generated with a simple | ||
[parser written in Python](https://github.com/MilanSkocic/codata/) | ||
The latest codata constants were released in 2022 by the [NIST](http://physics.nist.gov/constants) | ||
All values for the codata constants are provided as double precision reals. | ||
The names are quite long and can be aliased with shorter names. | ||
|
||
The derived type [[stdlib_codata_type(module):codata_constant_type(type)]] defines: | ||
|
||
* 4 members: | ||
|
||
* `name` (string) | ||
* `value` (double precision real) | ||
* `uncertainty` (double precision real) | ||
* `unit` (string) | ||
|
||
* 2 type-bound procedures: | ||
|
||
* `print`: to print the values of the constant members; | ||
* `to_real`: to get the value or the uncertainty to the desired precision. | ||
|
||
A module level interface [[stdlib_codata_type(module):to_real(interface)]] is | ||
available for getting the constant value or uncertainty of a constant. | ||
|
||
## `to_real` - Get the constant value or its uncertainty. | ||
|
||
### Status | ||
|
||
Experimental | ||
|
||
### Description | ||
|
||
Convert a [[stdlib_codata_type(module):codata_constant_type(type)]] to a `real` (at least `sp`, or `dp`) scalar. | ||
**Warning**: Some constants cannot be converted to single precision `sp` reals due to the value of the exponents. | ||
|
||
### Syntax | ||
|
||
`r = ` [[stdlib_codata_type(module):to_real(interface)]] `(c, mold [, uncertainty])` | ||
|
||
### Arguments | ||
|
||
`c`: argument has `intent(in) ` and shall be of type [[stdlib_codata_type(module):codata_constant_type(type)]]. | ||
|
||
`mold`: argument has `intent(in)` and shall be of `real` type. | ||
**Note**: The type of the `mold` argument defines the type of the result. | ||
|
||
`uncertainty` (optional): argument has `intent(in)` and shall be of `logical` type. | ||
It specifies if the uncertainty needs to be returned instead of the value. Default to `.false.`. | ||
|
||
### Return value | ||
|
||
Returns a scalar of `real` type which is either the value or the uncertainty of a codata constant. | ||
|
||
## Example | ||
|
||
```fortran | ||
{!example/constants/example_constants.f90!} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ADD_EXAMPLE(constants) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
program example_constants | ||
use stdlib_constants, only: c, pi=>PI_dp | ||
use stdlib_codata, only: alpha=>ALPHA_PARTICLE_ELECTRON_MASS_RATIO | ||
use stdlib_codata_type, only : to_real | ||
use stdlib_kinds, only: dp, sp | ||
|
||
! Use most common physical constants defined as double precision reals | ||
print *, "speed of light in vacuum= ", c | ||
|
||
! Use of mathematical constants such as PI | ||
print *, "PI as double precision real= ", pi | ||
|
||
! Use codata_constant type for evaluating the value to the desired precision | ||
print *, "Value of alpha... evaluated to double precision=", alpha%to_real(1.0_dp) | ||
print *, "Uncertainty of alpha... evaluated to double precision=", alpha%to_real(1.0_sp, .true.) | ||
print *, "Value of alpha... evaluated to single precision=", alpha%to_real(1.0_sp) | ||
|
||
! Convert a codata constant to a real | ||
print *, "Value of the alpha... evaluated to double precision=", to_real(alpha, 1.0_dp) | ||
|
||
|
||
! Print out codata constant attributes: name, value, uncertainty and unit | ||
call alpha%print() | ||
|
||
end program example_constants |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.