chemistry_tools.formulae.composition

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]

Elemental composition of a Formula.

Classes:

Composition(formula)

Class to represent the elemental composition of a Formula.

CompositionSort(value)

Lookup for sorting elemental composition output.

class Composition(formula)[source]

Bases: DataArray

Class to represent the elemental composition of a Formula.

Parameters

formula (Formula) – A Formula object to create the composition for

Methods:

__str__()

Return str(self).

as_array([sort_by, reverse])

Returns the elemental composition as a list of lists.

Attributes:

n_elements

The number of elements in the composition.

total_mass

The total mass of the composition.

__str__()[source]

Return str(self).

Return type

str

as_array(sort_by=<CompositionSort.symbol: 'symbol'>, reverse=False)[source]

Returns the elemental composition as a list of lists.

Parameters
  • sort_by (CompositionSort) – The column to sort by. Default <CompositionSort.symbol: 'symbol'>.

  • reverse (bool) – Whether the isotopologues should be sorted in reverse order. Default False.

Return type

List[List[Any]]

property n_elements

The number of elements in the composition.

Return type

int

property total_mass

The total mass of the composition.

Return type

float

enum CompositionSort(value)[source]

Bases: enum.Enum

Lookup for sorting elemental composition output.

Valid values are as follows:

symbol = <CompositionSort.symbol: 'symbol'>
count = <CompositionSort.count: 'count'>
rel_mass = <CompositionSort.rel_mass: 'rel_mass'>
mass_fraction = <CompositionSort.mass_fraction: 'mass_fraction'>