@@ -19,7 +19,7 @@ Let us illustrate some of the types of network properties that
1919Catalyst can determine.
2020
2121To begin, consider the following reaction network:
22- ``` @example s1
22+ ``` @example s1b
2323using Catalyst
2424rn = @reaction_network begin
2525 (k1,k2), A + B <--> C
@@ -31,7 +31,8 @@ rn = @reaction_network begin
3131end
3232```
3333with graph
34- ``` @example s1
34+ ``` @example s1b
35+ using CairoMakie, GraphMakie, NetworkLayout
3536plot_complexes(rn)
3637```
3738
@@ -45,7 +46,7 @@ these for a given network, returning a vector of the integer indices of reaction
4546complexes participating in each set of linkage-classes. Note, indices of
4647reaction complexes can be determined from the ordering returned by
4748[ ` reactioncomplexes ` ] ( @ref ) .
48- ``` @example s1
49+ ``` @example s1b
4950# we must first calculate the reaction complexes -- they are cached in rn
5051reactioncomplexes(rn)
5152
@@ -54,19 +55,19 @@ lcs = linkageclasses(rn)
5455```
5556It can often be convenient to obtain the disconnected sub-networks as distinct
5657` ReactionSystem ` s, which are returned by the [ ` subnetworks ` ] ( @ref ) function:
57- ``` @example s1
58+ ``` @example s1b
5859subnets = subnetworks(rn)
5960
6061# check the reactions in each subnetwork
6162reactions.(subnets)
6263```
6364The graphs of the reaction complexes in the two sub-networks are then
64- ``` @example s1
65+ ``` @example s1b
6566 plot_complexes(subnets[1])
6667```
6768
6869and,
69- ``` @example s1
70+ ``` @example s1b
7071 plot_complexes(subnets[2])
7172```
7273
@@ -84,7 +85,7 @@ to the number of independent species in a chemical reaction network. That is, if
8485we calculate the linear conservation laws of a network, and use them to
8586eliminate the dependent species of the network, we will have `` r `` independent
8687species remaining. For our current example the conservation laws are given by
87- ``` @example s1
88+ ``` @example s1b
8889# first we calculate the conservation laws -- they are cached in rn
8990conservationlaws(rn)
9091
@@ -95,11 +96,11 @@ show(stdout, MIME"text/plain"(), ans) # hide
9596Here the parameters ` Γ[i] ` represent the constants of the three
9697conservation laws, and we see that there are three dependent species that could
9798be eliminated. As
98- ``` @example s1
99+ ``` @example s1b
99100numspecies(rn)
100101```
101102we find that there are five independent species. Let's check this is correct:
102- ``` @example s1
103+ ``` @example s1b
103104using LinearAlgebra
104105rank(netstoichmat(rn)) == 5
105106```
@@ -112,7 +113,7 @@ The deficiency, ``\delta``, of a reaction network is defined as
112113\delta = \textrm{(number of complexes)} - \textrm{(number of linkage classes)} - \textrm{(rank)}.
113114```
114115For our network this is `` 7 - 2 - 5 = 0 `` , which we can calculate in Catalyst as
115- ``` @example s1
116+ ``` @example s1b
116117# first we calculate the reaction complexes of rn and cache them in rn
117118reactioncomplexes(rn)
118119
@@ -130,7 +131,7 @@ A reaction network is *reversible* if the "arrows" of the reactions are
130131symmetric so that every reaction is accompanied by its reverse reaction.
131132Catalyst's API provides the [ ` isreversible ` ] ( @ref ) function to determine whether
132133a reaction network is reversible. As an example, consider
133- ``` @example s1
134+ ``` @example s1b
134135rn = @reaction_network begin
135136 (k1,k2),A <--> B
136137 (k3,k4),A + C <--> D
@@ -145,7 +146,7 @@ reactioncomplexes(rn)
145146isreversible(rn)
146147```
147148Consider another example,
148- ``` @example s1
149+ ``` @example s1b
149150rn = @reaction_network begin
150151 (k1,k2),A <--> B
151152 k3, A + C --> D
155156reactioncomplexes(rn)
156157isreversible(rn)
157158```
158- ``` @example s1
159+ ``` @example s1b
159160plot_complexes(rn)
160161```
161162
@@ -164,7 +165,7 @@ However, it satisfies a weaker property in that there is a path from each
164165reaction complex back to itself within its associated subgraph. This is known as
165166* weak reversibility* . One can test a network for weak reversibility by using
166167the [ ` isweaklyreversible ` ] ( @ref ) function:
167- ``` @example s1
168+ ``` @example s1b
168169# need subnetworks from the reaction network first
169170subnets = subnetworks(rn)
170171isweaklyreversible(rn, subnets)
@@ -219,12 +220,12 @@ With these definitions we can now see how knowing the deficiency and weak
219220reversibility of the network can tell us about its steady state behavior.
220221Consider the previous example, which we know is weakly reversible. Its
221222deficiency is
222- ``` @example s1
223+ ``` @example s1b
223224deficiency(rn)
224225```
225226We also verify that the system is purely mass action (though it is apparent
226227from the network's definition):
227- ``` @example s1
228+ ``` @example s1b
228229all(rx -> ismassaction(rx, rn), reactions(rn))
229230```
230231We can therefore apply the Deficiency Zero Theorem to draw conclusions about the
@@ -245,7 +246,7 @@ exactly one equilibrium solution which will be positive and locally
245246asymptotically stable.
246247
247248As a final example, consider the following network from [ ^ 1 ]
248- ``` @example s1
249+ ``` @example s1b
249250def0_rn = @reaction_network begin
250251 (k1,k2),A <--> 2B
251252 (k3,k4), A + C <--> D
@@ -265,7 +266,7 @@ RRE ODEs cannot have a positive equilibrium solution.
265266There is an API function [ ` satisfiesdeficiencyzero ` ] ( @ref ) that will let us check
266267all these conditions easily:
267268
268- ``` @example s1
269+ ``` @example s1b
269270satisfiesdeficiencyzero(def0_rn)
270271```
271272
@@ -287,7 +288,7 @@ to have stable solutions.
287288
288289Let's look at an example network.
289290
290- ``` @example s1
291+ ``` @example s1b
291292def1_network = @reaction_network begin
292293 (k1, k2), A <--> 2B
293294 k3, C --> 2D
@@ -300,15 +301,15 @@ plot_complexes(def1_network)
300301We can see from the complex graph that there are two linkage classes, the deficiency of the bottom one is zero and the deficiency of the top one is one.
301302The total deficiency is one:
302303
303- ``` @example s1
304+ ``` @example s1b
304305deficiency(def1_network)
305306```
306307
307308And there is only one terminal linkage class in each, so our network satisfies all three conditions.
308309As in the deficiency zero case, there is the API function [ ` satisfiesdeficiencyone ` ] ( @ref )
309310for quickly checking these conditions:
310311
311- ``` @example s1
312+ ``` @example s1b
312313satisfiesdeficiencyone(def1_network)
313314```
314315
@@ -330,13 +331,13 @@ please consult Martin Feinberg's *Foundations of Chemical Reaction Network Theor
330331knowing that a network is complex balanced is really quite powerful.
331332
332333Let's check whether the deficiency 0 reaction network that we defined above is complex balanced by providing a set of rates:
333- ``` @example s1
334+ ``` @example s1b
334335rates = Dict([:k1 => 2.4, :k2 => 4., :k3 => 10., :k4 => 5.5, :k5 => 0.4])
335336iscomplexbalanced(rn, rates)
336337```
337338
338339We can do a similar check for detailed balance.
339- ``` @example s1
340+ ``` @example s1b
340341isdetailedbalanced(rn, rates)
341342```
342343
0 commit comments