Skip to content

Commit

Permalink
introduces another example as worked out together with Elad Noor
Browse files Browse the repository at this point in the history
  • Loading branch information
rgiessmann committed Mar 16, 2022
1 parent b8b1af4 commit 0b564bd
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
99 changes: 97 additions & 2 deletions materials/test-cycle-finding-algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

## one-substrate one-product scenarios:

if True:
if False:
## figure a) minimal trivial cycle of length 3
##
# rxn0 : A = B
Expand Down Expand Up @@ -368,7 +368,7 @@
# [0, 0, 0, 0, 0, 0]]


if False:
if True:
## figure f) multiple distinct equally-well solutions: three cycles of length 3 each
##
# rxn0 : A = B
Expand Down Expand Up @@ -434,6 +434,47 @@
# [0, 0, 1, 0, 1, 1],
# [0, 0, 0, 0, 0, 0]])

if False:
#### FEEDBACK SESSION WITH ELAD:
##
## figure f) connects A to "0" / null
stoich_matrix = np.array(
[ ## mol ...
# rxn ... ---> ## |
# rxn 0 1 2 3 4 5 6 ##
[-1, -1, -1, 00, 00, 00, +1 ], ## mol A
[+1, 00, 00, -1, -1, 00, 00 ], ## B
[00, +1, 00, +1, 00, -1, 00 ], ## C
[00, 00, +1, 00, +1, +1, 00 ], ## D
])
#


## figure c)
# B + D = C + F
## -> possible to calculate reaction energy

## figure f) disconnect C -> any reaction involving C cannot be fully in the span space
stoich_matrix = np.array(
[ ## mol ...
# rxn ... ---> ## |
# rxn 0 2 4 6 ##
[-1, -1, 00, +1 ], ## mol A
[+1, 00, -1, 00 ], ## B
[00, 00, 00, 00 ], ## C
[00, +1, +1, 00 ], ## D
])
#

# orthogonal bases
# nullspace = alpha*nullspace_vector_0 + beta*nullspace_vector_1 + gamma*nullspace_vector_2
#
# nullspace_vector_0 =
# [1,-1,0,1,0,0]
# nullspace_vector_0 * row_0 = 0
# nullspace_vector_0 * row_1 = 0
# ...


if False:
## figure g) trade-off between objectives: two cycles of length 4, 3; or three cycles of length 3, 3, 3?
Expand Down Expand Up @@ -580,6 +621,60 @@
# [0, 0, 0, 0, 0, 0, 0, 0, 0]])


if False:
## figure i) why are redundant cycles needed?
##
# rxn0 : A = B
# rxn1 : A = C
# rxn2 : A = D
# rxn3 : A = E
# rxn4 : B = F
# rxn5 : C = F
# rxn6 : D = F
# rxn7 : E = F
##
# cycle I: 0 = rxn0 + rxn4 - rxn5 - rxn1 == A-B-F-C-A
# cycle II: 0 = rxn3 + rxn7 - rxn6 - rxn2 == A-E-F-D-A
# cycle III: 0 = rxn1 + rxn5 - rxn6 - rxn2 == A-C-F-D-A
# cycle IV: 0 = rxn0 + rxn4 - rxn7 - rxn3 == A-B-F-E-A
# cycle V: 0 = rxn0 + rxn4 - rxn6 - rxn2 == A-B-F-D-A
# cycle VI: 0 = rxn3 + rxn7 - rxn5 - rxn1 == A-E-F-C-A
##
# solution s1: cycle I + cycle II (NB: not really a solution)
# solution s2: cycle I + cycle II + cycle III
# solution s3: cycle IV + cycle V + cycle VI
##
# Why is solution s1 not sufficient? It covers the whole figure!
# But: from the cycles of solution s1 it is not possible to construct
# all other possible cycles with XOR operations, e.g. it is not possible
# to construct cycle IV.
# In contrast, with solution s2, which adds a seemingly redundant cycle (cycle III),
# it becomes now possible to construct the others: cycle IV, V, VI, ...
##
# number of nodes (mols) in the figure: 6
# number of edges (rxns) in the figure: 8
# linear dependent reactions of the system: 3
##
stoich_matrix = np.array(
[ ## mol ...
# rxn ... ---> ## |
# rxn 0 1 2 3 4 5 6 7 ##
[-1, -1, -1, -1, 00, 00, 00, 00], ## mol A
[+1, 00, 00, 00, -1, 00, 00, 00], ## B
[00, +1, 00, 00, 00, -1, 00, 00], ## C
[00, 00, +1, 00, 00, 00, -1, 00], ## D
[00, 00, 00, +1, 00, 00, 00, -1], ## E
[00, 00, 00, 00, +1, +1, +1, +1], ## F
])
# rref = np.array(
# [[1, 0, 0, 0, 0, 1, 1, 1],
# [0, 1, 0, 0, 0, -1, 0, 0],
# [0, 0, 1, 0, 0, 0, -1, 0],
# [0, 0, 0, 1, 0, 0, 0, -1],
# [0, 0, 0, 0, 1, 1, 1, 1],
# [0, 0, 0, 0, 0, 0, 0, 0]])



## multi-substrate multi-product scenarios:

Expand Down

0 comments on commit 0b564bd

Please sign in to comment.