chemistry_tools.formulae.species
¶
Attention
This module has the following additional requirements:
cawdrey>=0.1.7 mathematical>=0.1.13 pyparsing>=2.2.0 tabulate>=0.8.3
These can be installed as follows:
python -m pip install chemistry_tools[formulae]
Classes:
|
Formula with phase information (e.g. |
Data:
Invariant |
-
S
= TypeVar(S, bound=Species)¶ Type:
TypeVar
Invariant
TypeVar
bound tochemistry_tools.formulae.species.Species
.
-
class
Species
(composition=None, charge=0, phase=None)[source]¶ Bases:
Formula
Formula with phase information (e.g. solid, liquid, gas, or aqueous).
Species extends
Formula
with the new attributephase
- Parameters
composition (
Optional
[Dict
[str
,int
]]) – AFormula
object with the elemental composition of a substance, or adict
representing the same. IfNone
an empty object is created. DefaultNone
.charge (
int
) – Default0
.phase – Either
's'
,'l'
,'g'
, or'aq'
.None
represents an unknown phase. DefaultNone
.
Methods:
__eq__
(other)Returns
self == other
.copy
()Returns a copy of the
Species
.from_kwargs
(*[, charge, phase])Create a new
Species
object from keyword arguments representing the elements in the compound.from_string
(formula[, charge, phase])Create a new
Species
object by parsing a string.Attributes:
Returns the empirical formula in Hill notation.
Returns the formula in Hill notation.
-
property
empirical_formula
¶ Returns the empirical formula in Hill notation.
The empirical formula has the simplest whole number ratio of atoms of each element present in the formula.
Examples:
>>> Formula.from_string('H2O').empirical_formula 'H2O' >>> Formula.from_string('S4').empirical_formula 'S' >>> Formula.from_string('C6H12O6').empirical_formula 'CH2O'
- Return type
-
classmethod
from_kwargs
(*, charge=0, phase=None, **kwargs)[source]¶ Create a new
Species
object from keyword arguments representing the elements in the compound.
-
classmethod
from_string
(formula, charge=0, phase=None)[source]¶ Create a new
Species
object by parsing a string.Note
Isotopes cannot (currently) be parsed using this method
- Parameters
Examples:
>>> water = Species.from_string('H2O') >>> water.phase None >>> NaCl = Species.from_string('NaCl(s)') >>> NaCl.phase s >>> Hg_l = Species.from_string('Hg(l)') >>> Hg_l.phase l >>> CO2g = Species.from_string('CO2(g)') >>> CO2g.phase g >>> CO2aq = Species.from_string('CO2(aq)') >>> CO2aq.phase aq
- Return type