Elements
Let's start by a global import; everything that is intended to be accessible to the end user is found here:
using AuChimiste
Elements database
A built-in elements database is provided by ChemicalElements
, which is the base building block of AuChimiste
. It is an extremely simple module and below we go through the whole of its exposed functionalities in just a few lines of code
In general you only need to worry about using ChemicalElements
directly if your calculations require isotopes to be added. The default table of elements provides access only to stable elements.
You can get a list of available atomic symbols with list_elements
. Suppose you want to check if deuterium D is present in the list, you can use its symbol for inspection:
:D ∈ list_elements()
false
Since it is not present but your calculations require this isotope, you feed the database with add_element
; you also decide to add tritium. In fact add_element
will not fail if the element exists, but issue a warning. You can try adding an existing element to see what happens:
add_element("D", "deuterium", 1, 2.0141017781)
add_element("Tr", "tritium", 1, 3.0160492820)
add_element("H", "hydrogen", 1, 1.008)
┌ Warning: The provided element H is already present in the elements dictionary. If you are trying to create an isotope, please chose a different name. Also notice that default stable elements cannot be modified.
└ @ AuChimiste ~/work/AuChimiste.jl/AuChimiste.jl/src/AuChimiste.jl:187
If you wish to get back to the standard data you can do so with reset_elements_table
. Notice below that deuterium mass is no longer available.
reset_elements_table()
has_element(:D)
false
Element data retrieval
It is possible to retrieve the atomic_mass
. Other data retrieval functions include atomic_number
and element_name
. All of these work with both string and symbols.
atomic_mass(:C), atomic_number(:C), element_name(:C)
(12.011, 6, "carbon")
Getting the whole element
data can be achieved at once as follows:
element(:Cl)
Cl (17, chlorine) 35.45 kg/kmol
In this case is also possible to query the data through the atomic number:
element(26)
Fe (26, iron) 55.845 kg/kmol
On the other hand atomic masses of unstable elements are not accessible:
try atomic_mass(:Po) catch e; @error(e) end
┌ Error: NoIsotopeProvidedError: Accessing the atomic mass of unstable element Po is not supported. Please consider creating a named isotope of this element with `add_isotope`.
└ @ Main.var"Main" elements.md:61
To have an unstable element listed, you need to add_isotope
before. For instance, let's add Po-187 to the database.
add_isotope(:Po, 187.003030)
Po187 (84, polonium-187) 187.00303 kg/kmol