chemreac.util.stoich

Collects stoichiometry related functions.

chemreac.util.stoich.decompose_yield_into_rate_coeffs(yields, stoichs, atol=1e-10)[source]

Decomposes (radiolytic) yields into linear combination of stoichiometric production reactions

Ak = y

A is (n_species x n_reactions) matrix, k is “rate coefficient”, y is yields

Parameters:

yields: OrderedDict

specie names as keys and yields as values

stoichs: list of 2-dict tuples

giving stoiciometry (1st is reactant, 2nd is products), dict keys must match those of yields

Returns:

1-dimensional array of effective rate coefficients.

chemreac.util.stoich.get_coeff_mtx(substances, stoichs)[source]

Create a net stoichiometry matrix from reactions described by pairs of dictionaries.

Parameters:

substances: sequence of keys in stoichs dict pairs

stoichs: sequence of pairs of dicts

pairs of reactant and product dicts mapping substance keys to stoichiometric coefficients (integers)

Returns:

2 dimensional array of shape (len(substances), len(stoichs))

chemreac.util.stoich.identify_equilibria(stoich_reac, stoich_prod)[source]

Identify equilibria from stoichiometry

Parameters:

stoich_reac: iterable of iterables of integers

per reaction iterables of specie indices for reactants

stoich_prod: iterable of iterables of integers

per reaction iterables of specie indices for products

Returns:

Set of tuples of reaction indices forming equilibria

Examples

>>> identify_equilibria([[0,0], [1]], [[1], [0,0]]) == set([(0, 1)])
True