d-ming / AR-tools

A set of utility functions and Jupyter notebooks for attainable region (AR) computations.
2 stars 7 forks source link

Stoich_mat builder #53

Closed d-ming closed 7 years ago

d-ming commented 7 years ago

The stoichiometric coefficient matrix is an important part of AR, but creating it (as a numpy 2-D array) is tiresome and error-prone because the coefficients need to be entered manually. genStoichMat() and associated functions help to generate this matrix from a more natural string format.

e.g genStoichMat(['1.5*A + 0.35*B -> C + 4*D', 'A + D -> E']) generates the matrix

[[-1.5, -1.0],
 [-0.35, 0.0],
 [1.0, 0.0],
 [4.0, -1.0],
 [0.0, 1.0]]

with the following dictionary corresponding to component indices:

{'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4}