chemistry_tools.formulae.species
Attention
This module has the following additional requirements:
cawdrey>=0.5.0 mathematical>=0.5.1 pyparsing>=2.4.6 tabulate>=0.8.9
These can be installed as follows:
python -m pip install chemistry-tools[formulae]
Class to represent a formula with phase information (e.g. solid, liquid, gas, or aqueous).
Data:
Invariant |
Classes:
|
Formula with phase information (e.g. |
-
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 (
Optional
[Literal
['s'
,'l'
,'g'
,'aq'
]]) – 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.
The phase of the species (e.g.
-
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
- Return type
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
-
property
hill_formula
Returns the formula in Hill notation.
Examples:
>>> Species.from_string('BrC2H5').hill_formula 'C2H5Br' >>> Species.from_string('HBr').hill_formula 'BrH' >>> Species.from_string('[(CH3)3Si2]2NNa').hill_formula 'C6H18NNaSi4'
- Return type