diff --git a/README.md b/README.md index 005843e..c3a35b5 100644 --- a/README.md +++ b/README.md @@ -4,26 +4,28 @@ [![Build Status](https://github.com/bmad-sim/AtomicAndPhysicalConstants.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/bmad-sim/AtomicAndPhysicalConstants.jl/actions/workflows/CI.yml?query=branch%3Amain) +# AtomicAndPhysicalConstants.jl + +`AtomicAndPhysicalConstants.jl` provides a quick way to access information about different species and physical constants. -`AtomicAndPhysicalConstants.jl` is a Julia package designed to provide atomic and physical constants including things like the speed of light, subatomic particle properties, atomic isotope properties, etc. +It is designed to provide atomic and physical constants including things like the speed of light, subatomic particle properties, atomic isotope properties, etc. Values are obtained from CODATA (Committee on Data of the International Science Council), NIST (National Institute of Standards and Technology), and PDG (Particle Data Group). This package enables users to access and customize units for the constants. -The package is compatible with Julia's Unitful.jl library for convenient unit manipulation. +The package is compatible with Julia's `Unitful.jl` library for convenient unit manipulation. `AtomicAndPhysicalConstants.jl` has the following main features and advantages: -1. **Speed**: `GTPSA.jl` is significantly faster than `ForwardDiff.jl` for 2nd-order calculations and above, and has very similar performance at 1st-order -2. **Easy Monomial Indexing**: Beyond 2nd order, accessing/manipulating the partial derivatives in an organized way can be a significant challenge when using other AD packages. In GTPSA, three simple indexing schemes for getting/setting monomial coefficients in a truncated power series is provided, as well as a `cycle!` function for cycling through all nonzero monomials -3. **Custom Orders in Individual Variables**: Other packages use a single maximum order for all variables. With GTPSA, the maximum order can be set differently for individual variables, as well as for a separate part of the monomial. For example, computing the Taylor expansion of $f(x_1,x_2)$ to 2nd order in $x_1$ and 6th order in $x_2$ is possible -4. **Complex Numbers**: GTPSA natively supports complex numbers and allows for mixing of complex and real truncated power series -5. **Distinction Between State Variables and Parameters**: Distinguishing between dependent variables and parameters in the solution of a differential equation expressed as a power series in the dependent variables/parameters can be advantageous in analysis +1. **Simple Unit Manipulation**: Users can define the units they want to use in a simple and consistent way. `Unitful.jl` provides a simple way to do unit conversion and calculations. +2. **Rigorous and Up-to-Date Data**: We uses the most updated values from creditable sources. We also provided the option to use past data for specific purposes. +3. **Simple usage**: Users can access data of a wide range of particles and physic constants by simply defining a species with their name or call a variable in the namespace. ## Setup +## Basic Usage +### Defining Physical Constants -## Basic Usage -First, to define physical constants, call the macro `@APCdef`. +The macro `@APCdef` helps you define a set of useful physical constants in your namespace. ```julia julia> @APCdef @@ -31,38 +33,24 @@ julia> C_LIGHT 2.99792458e8 ``` +Users have the options for choosing the type and unit of the constants, see [this page](units.md) -Next, to create a species. - -```julia -using GTPSA +### Defining Species -# Descriptor for TPSA with 2 variables to 6th order -d = Descriptor(2, 6) +The constructor `Species()` helps you create a structure with all the information of the species stored in it. -# Get the TPSs corresponding to each variable based on the Descriptor -x = vars(d) -# x[1] corresponds to the first variable and x[2] corresponds to the second variable - -# Manipulate the TPSs as you would any other mathematical variable in Julia -f = cos(x[1]) + im*sin(x[2]) -# f is a new ComplexTPS64 +```julia +julia> e = Species("electron") +julia> hydrogen = Species("H") ``` -Note that scalars do not need to be defined as TPSs when writing expressions. Running `print(f)` gives the output +You could use getter functions to access its properties or directly calling its fields. +```julia +julia> massof(e) +510998.95069 +julia> hydrogen.spin +1.0 h_bar ``` -ComplexTPS64: - Real Imag Order Exponent - 1.0000000000000000e+00 0.0000000000000000e+00 0 0 0 - 0.0000000000000000e+00 1.0000000000000000e+00 1 0 1 - -5.0000000000000000e-01 0.0000000000000000e+00 2 2 0 - 0.0000000000000000e+00 -1.6666666666666666e-01 3 0 3 - 4.1666666666666664e-02 0.0000000000000000e+00 4 4 0 - 0.0000000000000000e+00 8.3333333333333332e-03 5 0 5 - -1.3888888888888887e-03 0.0000000000000000e+00 6 6 0 -``` - -The GTPSA library currently only supports truncated power series representing `Float64` and `ComplexF64` number types. -For more details, including using TPSs with differing truncation orders for each variable, see the [GTPSA documentation](https://bmad-sim.github.io/GTPSA.jl/). +See more about `Species()` constructors and getter functions [here](species.md) \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md index 4056d26..fd10f1f 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,5 +1,50 @@ # AtomicAndPhysicalConstants.jl -`AtomicAndPhysicalConstants.jl` provides a quick way to store informations about different atomic species and other physical constants +`AtomicAndPhysicalConstants.jl` provides a quick way to access information about different species and physical constants. +It is designed to provide atomic and physical constants including things like the speed of light, subatomic particle properties, atomic isotope properties, etc. + +Values are obtained from CODATA (Committee on Data of the International Science Council), NIST (National Institute of Standards and Technology), and PDG (Particle Data Group). This package enables users to access and customize units for the constants. + +The package is compatible with Julia's `Unitful.jl` library for convenient unit manipulation. + +`AtomicAndPhysicalConstants.jl` has the following main features and advantages: + +1. **Simple Unit Manipulation**: Users can define the units they want to use in a simple and consistent way. `Unitful.jl` provides a simple way to do unit conversion and calculations. +2. **Rigorous and Up-to-Date Data**: We uses the most updated values from creditable sources. We also provided the option to use past data for specific purposes. +3. **Simple usage**: Users can access data of a wide range of particles and physic constants by simply defining a species with their name or call a variable in the namespace. + +## Setup ## Basic Usage + +### Defining Physical Constants + +The macro `@APCdef` helps you define a set of useful physical constants in your namespace. + +```julia +julia> @APCdef +julia> C_LIGHT +2.99792458e8 +``` + +Users have the options for choosing the type and unit of the constants, see [this page](units.md) + +### Defining Species + +The constructor `Species()` helps you create a structure with all the information of the species stored in it. + +```julia +julia> e = Species("electron") +julia> hydrogen = Species("H") +``` + +You could use getter functions to access its properties or directly calling its fields. + +```julia +julia> massof(e) +510998.95069 +julia> hydrogen.spin +1.0 h_bar +``` + +See more about `Species()` constructors and getter functions [here](species.md) \ No newline at end of file diff --git a/docs/src/species.md b/docs/src/species.md index a7796b4..2be2b72 100644 --- a/docs/src/species.md +++ b/docs/src/species.md @@ -72,17 +72,19 @@ julia> Species("C#13+") #Carbon-13 with a single positive charge - If mass number is not provided, the average will be used - If charge is not provided, a neutral atom will be returned. -- charge can be provided by the following format +- Charge can be provided by the following format - "+" represents single positive charge - "++" represents double positive charge - "+n" represents n positive charge - "-" represents single negative charge - "--" represents double negative charge - "-n" represents n negative charge +- To construct an anti atom, put "anti-" in the front. Example: ```julia julia> Species("Al+4") #average Aluminum with 3 positive charge +julia> Species("anti-H") #anti-hydrogen ``` ### Alternative Way of Constructing Atomic Species @@ -116,6 +118,8 @@ Species functions take a `Species` as their only parameter and returns a specifi - `g_nucleon()` - `fullname()` +**Note**: One must call `@APCdef` before calling `massof()` and `chargeof()`. + ## List of Available subatomic species - `photon` diff --git a/src/2018_constants.jl b/src/2018_constants.jl index a07e1d1..18cb836 100644 --- a/src/2018_constants.jl +++ b/src/2018_constants.jl @@ -3,10 +3,6 @@ # the 2018 CODATA release - - - - ##################################################################### # constants with dimension [mass] #####################################################################