Actually that’s apparently the only (visible, i.e in a registered package) use of the PeriodicTable: Stoichiometry and the fancy indexing. As these functionalities are the most used, I’ve decided to split out a separate minimalistic package from Mendeleev, with these functionalities only, no dependencies, no extra data etc… Then however I couldn’t resist a temptation to add some sugar onto these bare-bones. The package is already fully functional and to be registered after adding tests, documentation etc.
using ChemElementsBB
K = chem_els["potassium"]
Ca = chem_els[:Ca]
P = chem_els[15] # three ways of indexing similar to PeriodicTable
O = chem_els.O # one more (Mendeleev)
julia> O
Oxygen (O) - element 8, m=15.999
julia> K / (K + Ca + P + 4*O)
0.22451440791379498
Macro to create element-named-variables (doing in effect the same as the code above).
using ChemElementsBB
@import_els K Ca P O
julia> K
Potassium (K) - element 19, m=39.0983
@import_els O:Ca
julia> F
Fluorine (F) - element 9, m=18.998403163
On this basis another separate package for chemical formulas is feasible, along the lines of ChemEquations.jl. The usage then could be like
julia> K/cf"KCaPO4"
0.22451440791379498