Formulas
ChemistryLab.AtomGroupChemistryLab.AtomGroupChemistryLab.FormulaBase.convertChemistryLab.chargeChemistryLab.check_mendeleevChemistryLab.coloredChemistryLab.compositionChemistryLab.exprChemistryLab.phreeqcChemistryLab.stoichtypeChemistryLab.unicode
ChemistryLab.AtomGroup — Type
struct AtomGroup{T}Simple container pairing an atomic symbol with a numeric coefficient.
Fields
coef::T: numeric coefficient.sym::Symbol: atomic symbol.
Examples
julia> AtomGroup(:H, 2)
AtomGroup{Int64}(2, :H)
julia> AtomGroup(:Ca)
AtomGroup{Int64}(1, :Ca)ChemistryLab.AtomGroup — Method
AtomGroup(sym::Symbol) -> AtomGroup
AtomGroup(sym::Symbol, coef::T) where {T<:Number} -> AtomGroup{T}Constructors for AtomGroup.
Arguments
sym: atomic symbol.coef: numeric coefficient (default 1).
Examples
julia> AtomGroup(:C)
AtomGroup{Int64}(1, :C)
julia> AtomGroup(:C, 3)
AtomGroup{Int64}(3, :C)Base.convert — Method
Base.convert(::Type{AtomGroup}, sym::Symbol) -> AtomGroupConvert a Symbol to a unit AtomGroup (coefficient = 1).
Examples
julia> convert(AtomGroup, :O)
AtomGroup{Int64}(1, :O)ChemistryLab.stoichtype — Function
stoichtype(f::Formula{T}) where {T} -> Type{T}Return the numeric stoichiometric coefficient type T for formula f.
Examples
julia> stoichtype(Formula("H2O"))
Int64ChemistryLab.Formula — Type
struct Formula{T}Canonical container for a chemical formula.
Fields
expr::String: original input expression.phreeqc::String: PHREEQC-compatible representation.unicode::String: Unicode pretty representation.colored::String: colored terminal representation.composition::OrderedDict{Symbol,T}: mapping element symbol to coefficient.charge::Int8: formal integer charge.
Examples
julia> f = Formula("H2O");
julia> composition(f)[:H]
2ChemistryLab.expr — Method
expr(f::Formula) -> StringReturn the original expression string stored in f.
Examples
julia> expr(Formula("H2O"))
"H2O"ChemistryLab.phreeqc — Method
phreeqc(f::Formula) -> StringReturn the PHREEQC-compatible representation of f.
Examples
julia> phreeqc(Formula("H2O"))
"H2O"ChemistryLab.unicode — Method
unicode(f::Formula) -> StringReturn the Unicode pretty representation of f.
Examples
julia> phreeqc(Formula("C3A"))
"C3A"ChemistryLab.colored — Method
colored(f::Formula) -> StringReturn the colored terminal representation of f.
Examples
julia> colored(Formula("Ca(HSiO3)+"))ChemistryLab.composition — Method
composition(f::Formula) -> OrderedDict{Symbol,T}Return the composition mapping (element symbol => coefficient).
Examples
julia> composition(Formula("Ca(HSiO3)+"))ChemistryLab.charge — Method
charge(f::Formula) -> Int8Return the formal integer charge of the formula.
Examples
julia> charge(Formula("Ca(HSiO3)+"))
1ChemistryLab.check_mendeleev — Method
check_mendeleev(f::Formula) -> BoolValidate that all element symbols in f exist in the package elements registry. Returns true when valid; otherwise throws an informative error.
Examples
julia> check_mendeleev(Formula("NaCl"))
true