Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
chemreac.util.stoich --------------------
Collects stoichiometry related functions.
"""
""" 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))
"""
""" 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.
""" # Sanity check:
raise ValueError("atol not satisfied")
# def get_reaction_orders(stoich_reac, stoich_actv=None): # """ # Return the order of the reactions (assuming mass-action # behaviour).
# Parameters # ---------- # stoich_reac: list of lists of integer indices # stoichs: list of lists of integer indices (optional)
# Returns # ------- # iterable of integers corresponding to the total reaction orders
# See also # -------- # :class:`chemreac.core.ReactionDiffusion`
# """ # res = [] # if stoich_actv is None: # stoich_actv = [[]]*len(stoich_reac) # for reac, actv in zip(stoich_reac, stoich_actv): # if actv == []: # actv = reac # res.append(len(actv)) # return res
""" 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
""" |