chemistry_tools.formulae.compound

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]

Parse formulae into a Python object.

Classes:

Compound(name[, formula, data, latex_name, …])

Class representing a chemical compound.

class Compound(name, formula=None, data=None, latex_name=None, unicode_name=None, html_name=None)[source]

Bases: Dictable

Class representing a chemical compound.

Parameters

data could be simple such as {'mp': 0, 'bp': 100} or considerably more involved, e.g.:

{
    'diffusion_coefficient': {
        'water': lambda T: 2.1*m**2/s/K*(T - 273.15*K),
    }
}

Methods:

__eq__(other)

Return self == other.

__repr__()

Return a string representation of the Compound.

__str__()

Return str(self).

molar_mass()

Returns the molar mass (with units) of the substance.

Attributes:

charge

The charge of the compound.

mass

The mass of the compound.

__eq__(other)[source]

Return self == other.

Return type

bool

__repr__()[source]

Return a string representation of the Compound.

Return type

str

__str__()[source]

Return str(self).

Return type

str

property charge

The charge of the compound.

Return type

int

property mass

The mass of the compound.

Return type

float

molar_mass()[source]

Returns the molar mass (with units) of the substance.

Example:

>>> nh4p = Compound('NH4+')
>>> import quantities
>>> nh4p.molar_mass(quantities)
array(18.0384511...) * g/mol
Return type

Quantity