Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 31, 2024
1 parent 8120672 commit 8726e44
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 42 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Introduction

`PhysicalConstants.jl` provides common physical constants. They are defined as
instances of the new `Constant` type, which is subtype of `AbstractQuantity`
(from [`Unitful.jl`](https://github.com/ajkeller34/Unitful.jl) package) and can
(from [`Unitful.jl`](https://github.com/PainterQubits/Unitful.jl) package) and can
also be turned into `Measurement` objects (from
[`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl) package) at
request.

Constants are grouped into different submodules, so that the user can choose
different datasets as needed. Currently, 2014 and 2018 editions of
different datasets as needed. Currently, 2014, 2018, and 2022 editions of
[CODATA](https://physics.nist.gov/cuu/Constants/) recommended values of the
fundamental physical constants are provided.

Expand All @@ -38,41 +38,41 @@ Usage
You can load the package as usual with `using PhysicalConstants` but this module
does not provide anything useful for the end-users. You most probably want to
directly load the submodule with the dataset you are interested in. For
example, for CODATA 2018 load `PhysicalConstants.CODATA2018`:
example, for CODATA 2022 load `PhysicalConstants.CODATA2022`:

```julia
julia> using PhysicalConstants.CODATA2018
julia> using PhysicalConstants.CODATA2022

julia> SpeedOfLightInVacuum
Speed of light in vacuum (c_0)
Value = 2.99792458e8 m s^-1
Standard uncertainty = (exact)
Relative standard uncertainty = (exact)
Reference = CODATA 2018
Reference = CODATA 2022

julia> NewtonianConstantOfGravitation
Newtonian constant of gravitation (G)
Value = 6.6743e-11 m^3 kg^-1 s^-2
Standard uncertainty = 1.5e-15 m^3 kg^-1 s^-2
Relative standard uncertainty = 2.2e-5
Reference = CODATA 2018
Reference = CODATA 2022
```

`SpeedOfLightInVacuum` and `NewtonianConstantOfGravitation` are two of the
`PhysicalConstant`s defined in the `PhysicalConstants.CODATA2018` module, the
`PhysicalConstant`s defined in the `PhysicalConstants.CODATA2022` module, the
full list of available constants is given below.

`PhysicalConstant`s can be readily used in mathematical operations, using by
default their `Float64` value:

```julia
julia> import PhysicalConstants.CODATA2018: c_0, ε_0, μ_0
julia> import PhysicalConstants.CODATA2022: c_0, ε_0, μ_0

julia> 2 * ε_0
1.77083756256e-11 F m^-1
1.77083756376e-11 F m^-1

julia> ε_0 - 1 / (μ_0 * c_0 ^ 2)
-3.8450973786644646e-25 A^2 s^4 kg^-1 m^-3
1.0567555442791707e-23 A^2 s^4 kg^-1 m^-3
```

If you want to use a different precision for the value of the constant, use the
Expand All @@ -83,13 +83,13 @@ julia> float(Float32, ε_0)
8.854188f-12 F m^-1

julia> float(BigFloat, ε_0)
8.854187812799999999999999999999999999999999999999999999999999999999999999999973e-12 F m^-1
8.854187818800000000000000000000000000000000000000000000000000000000000000000059e-12 F m^-1

julia> big(ε_0)
8.854187812799999999999999999999999999999999999999999999999999999999999999999973e-12 F m^-1
8.854187818800000000000000000000000000000000000000000000000000000000000000000059e-12 F m^-1

julia> big(ε_0) - inv(big(μ_0) * big(c_0)^2)
-3.849883307464075736533920296598236938395867709081184624499315166190408485179288e-25 A^2 s^4 kg^-1 m^-3
1.056704162590924117341831987227432956066714823419574007586677144869010778731235e-23 A^2 s^4 kg^-1 m^-3
```

Note that `big(constant)` is an alias for `float(BigFloat, constant)`.
Expand All @@ -100,7 +100,7 @@ the constant, use `measurement(x)`:
```julia
julia> using Measurements

julia> import PhysicalConstants.CODATA2018: h, ħ
julia> import PhysicalConstants.CODATA2022: h, ħ

julia> measurement(ħ)
1.0545718176461565e-34 ± 0.0 J s
Expand Down
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Documenter, PhysicalConstants, Unitful
using PhysicalConstants: CODATA2014, CODATA2018, CODATA2022

## Generate list of constants
open(joinpath(@__DIR__, "src", "constants.md"), "w") do io
Expand All @@ -15,7 +16,7 @@ open(joinpath(@__DIR__, "src", "constants.md"), "w") do io
use most frequently, as shown in the examples above.
"""
)
for set in (PhysicalConstants.CODATA2014, PhysicalConstants.CODATA2018)
for set in (CODATA2014, CODATA2018, CODATA2022)
println(io)
println(io, "### ", nameof(set))
println(io)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
[`PhysicalConstants.jl`](https://github.com/JuliaPhysics/PhysicalConstants.jl)
provides common physical constants. They are defined as instances of the new
`Constant` type, which is subtype of `AbstractQuantity` (from
[`Unitful.jl`](https://github.com/ajkeller34/Unitful.jl) package) and can also
[`Unitful.jl`](https://github.com/PainterQubits/Unitful.jl) package) and can also
be turned into `Measurement` objects (from
[`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl) package) at
request.

Constants are grouped into different submodules, so that the user can choose
different datasets as needed. Currently, 2014 and 2018 editions of
different datasets as needed. Currently, 2014, 2018, and 2022 editions of
[CODATA](https://physics.nist.gov/cuu/Constants/) recommended values of the
fundamental physical constants are provided.

Expand Down
24 changes: 12 additions & 12 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
You can load the package as usual with `using PhysicalConstants` but this module
does not provide anything useful for the end-users. You most probably want to
directly load the submodule with the dataset you are interested in. For
example, for CODATA 2018 load `PhysicalConstants.CODATA2018`:
example, for CODATA 2022 load `PhysicalConstants.CODATA2022`:

```julia
julia> using PhysicalConstants.CODATA2018
julia> using PhysicalConstants.CODATA2022

julia> SpeedOfLightInVacuum
Speed of light in vacuum (c_0)
Value = 2.99792458e8 m s^-1
Standard uncertainty = (exact)
Relative standard uncertainty = (exact)
Reference = CODATA 2018
Reference = CODATA 2022

julia> NewtonianConstantOfGravitation
Newtonian constant of gravitation (G)
Value = 6.6743e-11 m^3 kg^-1 s^-2
Standard uncertainty = 1.5e-15 m^3 kg^-1 s^-2
Relative standard uncertainty = 2.2e-5
Reference = CODATA 2018
Reference = CODATA 2022
```

`SpeedOfLightInVacuum` and `NewtonianConstantOfGravitation` are two of the
`PhysicalConstant`s defined in the `PhysicalConstants.CODATA2018` module, the
`PhysicalConstant`s defined in the `PhysicalConstants.CODATA2022` module, the
full list of available constants is given below.

`PhysicalConstant`s can be readily used in mathematical operations, using by
default their `Float64` value:

```julia
julia> import PhysicalConstants.CODATA2018: c_0, ε_0, μ_0
julia> import PhysicalConstants.CODATA2022: c_0, ε_0, μ_0

julia> 2 * ε_0
1.77083756256e-11 F m^-1
1.77083756376e-11 F m^-1

julia> ε_0 - 1 / (μ_0 * c_0 ^ 2)
-3.8450973786644646e-25 A^2 s^4 kg^-1 m^-3
1.0567555442791707e-23 A^2 s^4 kg^-1 m^-3
```

If you want to use a different precision for the value of the constant, use the
Expand All @@ -48,13 +48,13 @@ julia> float(Float32, ε_0)
8.854188f-12 F m^-1

julia> float(BigFloat, ε_0)
8.854187812799999999999999999999999999999999999999999999999999999999999999999973e-12 F m^-1
8.854187818800000000000000000000000000000000000000000000000000000000000000000059e-12 F m^-1

julia> big(ε_0)
8.854187812799999999999999999999999999999999999999999999999999999999999999999973e-12 F m^-1
8.854187818800000000000000000000000000000000000000000000000000000000000000000059e-12 F m^-1

julia> big(ε_0) - inv(big(μ_0) * big(c_0)^2)
-3.849883307464075736533920296598236938395867709081184624499315166190408485179288e-25 A^2 s^4 kg^-1 m^-3
1.056704162590924117341831987227432956066714823419574007586677144869010778731235e-23 A^2 s^4 kg^-1 m^-3
```

Note that `big(constant)` is an alias for `float(BigFloat, constant)`.
Expand All @@ -65,7 +65,7 @@ the constant, use `measurement(x)`:
```julia
julia> using Measurements

julia> import PhysicalConstants.CODATA2018: h, ħ
julia> import PhysicalConstants.CODATA2022: h, ħ

julia> measurement(ħ)
1.0545718176461565e-34 ± 0.0 J s
Expand Down
26 changes: 13 additions & 13 deletions src/PhysicalConstants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ Return the physical constant as a `Quantity` with the floating type optionally s
`FloatType`, `Float64` by default.
```jldoctest
julia> using PhysicalConstants.CODATA2018: G
julia> using PhysicalConstants.CODATA2022: G
julia> G
Newtonian constant of gravitation (G)
Value = 6.6743e-11 m^3 kg^-1 s^-2
Standard uncertainty = 1.5e-15 m^3 kg^-1 s^-2
Relative standard uncertainty = 2.2e-5
Reference = CODATA 2018
Reference = CODATA 2022
julia> float(G)
6.6743e-11 m^3 kg^-1 s^-2
Expand All @@ -278,22 +278,22 @@ Return the physical constant as a `Quantity` with standard uncertainty. The flo
precision can be optionally specified with the `FloatType`, `Float64` by default.
```jldoctest
julia> using PhysicalConstants.CODATA2018, Measurements
julia> using PhysicalConstants.CODATA2022, Measurements
julia> import PhysicalConstants.CODATA2018: μ_0
julia> import PhysicalConstants.CODATA2022: μ_0
julia> μ_0
Vacuum magnetic permeability (μ_0)
Value = 1.25663706212e-6 N A^-2
Standard uncertainty = 1.9e-16 N A^-2
Relative standard uncertainty = 1.5e-10
Reference = CODATA 2018
Value = 1.25663706127e-6 N A^-2
Standard uncertainty = 2.0e-16 N A^-2
Relative standard uncertainty = 1.6e-10
Reference = CODATA 2022
julia> measurement(μ_0)
1.25663706212e-6 ± 1.9e-16 N A^-2
1.25663706127e-6 ± 2.0e-16 N A^-2
julia> measurement(Float32, μ_0)
1.256637e-6 ± 1.9e-16 N A^-2
1.256637e-6 ± 2.0e-16 N A^-2
```
"""
measurement(::PhysicalConstant)
Expand All @@ -306,17 +306,17 @@ Return the reference defined for the physical constant.
```jldoctest
julia> using PhysicalConstants
julia> using PhysicalConstants.CODATA2018: h
julia> using PhysicalConstants.CODATA2022: h
julia> h
Planck constant (h)
Value = 6.62607015e-34 J s
Standard uncertainty = (exact)
Relative standard uncertainty = (exact)
Reference = CODATA 2018
Reference = CODATA 2022
julia> PhysicalConstants.reference(h)
"CODATA 2018"
"CODATA 2022"
```
"""
function reference end
Expand Down

0 comments on commit 8726e44

Please sign in to comment.