Skip to content

Commit b00b44f

Browse files
authored
Merge pull request #1285 from SciML/isaacsas-patch-1
Update crn_theory.md
2 parents b2ef2f9 + 610d0a4 commit b00b44f

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

docs/src/network_analysis/crn_theory.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Let us illustrate some of the types of network properties that
1919
Catalyst can determine.
2020

2121
To begin, consider the following reaction network:
22-
```@example s1
22+
```@example s1b
2323
using Catalyst
2424
rn = @reaction_network begin
2525
(k1,k2), A + B <--> C
@@ -31,7 +31,8 @@ rn = @reaction_network begin
3131
end
3232
```
3333
with graph
34-
```@example s1
34+
```@example s1b
35+
using CairoMakie, GraphMakie, NetworkLayout
3536
plot_complexes(rn)
3637
```
3738

@@ -45,7 +46,7 @@ these for a given network, returning a vector of the integer indices of reaction
4546
complexes participating in each set of linkage-classes. Note, indices of
4647
reaction 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
5051
reactioncomplexes(rn)
5152
@@ -54,19 +55,19 @@ lcs = linkageclasses(rn)
5455
```
5556
It 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
5859
subnets = subnetworks(rn)
5960
6061
# check the reactions in each subnetwork
6162
reactions.(subnets)
6263
```
6364
The 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

6869
and,
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
8485
we calculate the linear conservation laws of a network, and use them to
8586
eliminate the dependent species of the network, we will have ``r`` independent
8687
species 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
8990
conservationlaws(rn)
9091
@@ -95,11 +96,11 @@ show(stdout, MIME"text/plain"(), ans) # hide
9596
Here the parameters `Γ[i]` represent the constants of the three
9697
conservation laws, and we see that there are three dependent species that could
9798
be eliminated. As
98-
```@example s1
99+
```@example s1b
99100
numspecies(rn)
100101
```
101102
we find that there are five independent species. Let's check this is correct:
102-
```@example s1
103+
```@example s1b
103104
using LinearAlgebra
104105
rank(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
```
114115
For 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
117118
reactioncomplexes(rn)
118119
@@ -130,7 +131,7 @@ A reaction network is *reversible* if the "arrows" of the reactions are
130131
symmetric so that every reaction is accompanied by its reverse reaction.
131132
Catalyst's API provides the [`isreversible`](@ref) function to determine whether
132133
a reaction network is reversible. As an example, consider
133-
```@example s1
134+
```@example s1b
134135
rn = @reaction_network begin
135136
(k1,k2),A <--> B
136137
(k3,k4),A + C <--> D
@@ -145,7 +146,7 @@ reactioncomplexes(rn)
145146
isreversible(rn)
146147
```
147148
Consider another example,
148-
```@example s1
149+
```@example s1b
149150
rn = @reaction_network begin
150151
(k1,k2),A <--> B
151152
k3, A + C --> D
@@ -155,7 +156,7 @@ end
155156
reactioncomplexes(rn)
156157
isreversible(rn)
157158
```
158-
```@example s1
159+
```@example s1b
159160
plot_complexes(rn)
160161
```
161162

@@ -164,7 +165,7 @@ However, it satisfies a weaker property in that there is a path from each
164165
reaction 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
166167
the [`isweaklyreversible`](@ref) function:
167-
```@example s1
168+
```@example s1b
168169
# need subnetworks from the reaction network first
169170
subnets = subnetworks(rn)
170171
isweaklyreversible(rn, subnets)
@@ -219,12 +220,12 @@ With these definitions we can now see how knowing the deficiency and weak
219220
reversibility of the network can tell us about its steady state behavior.
220221
Consider the previous example, which we know is weakly reversible. Its
221222
deficiency is
222-
```@example s1
223+
```@example s1b
223224
deficiency(rn)
224225
```
225226
We also verify that the system is purely mass action (though it is apparent
226227
from the network's definition):
227-
```@example s1
228+
```@example s1b
228229
all(rx -> ismassaction(rx, rn), reactions(rn))
229230
```
230231
We 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
245246
asymptotically stable.
246247

247248
As a final example, consider the following network from [^1]
248-
```@example s1
249+
```@example s1b
249250
def0_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.
265266
There is an API function [`satisfiesdeficiencyzero`](@ref) that will let us check
266267
all these conditions easily:
267268

268-
```@example s1
269+
```@example s1b
269270
satisfiesdeficiencyzero(def0_rn)
270271
```
271272

@@ -287,7 +288,7 @@ to have stable solutions.
287288

288289
Let's look at an example network.
289290

290-
```@example s1
291+
```@example s1b
291292
def1_network = @reaction_network begin
292293
(k1, k2), A <--> 2B
293294
k3, C --> 2D
@@ -300,15 +301,15 @@ plot_complexes(def1_network)
300301
We 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.
301302
The total deficiency is one:
302303

303-
```@example s1
304+
```@example s1b
304305
deficiency(def1_network)
305306
```
306307

307308
And there is only one terminal linkage class in each, so our network satisfies all three conditions.
308309
As in the deficiency zero case, there is the API function [`satisfiesdeficiencyone`](@ref)
309310
for quickly checking these conditions:
310311

311-
```@example s1
312+
```@example s1b
312313
satisfiesdeficiencyone(def1_network)
313314
```
314315

@@ -330,13 +331,13 @@ please consult Martin Feinberg's *Foundations of Chemical Reaction Network Theor
330331
knowing that a network is complex balanced is really quite powerful.
331332

332333
Let'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
334335
rates = Dict([:k1 => 2.4, :k2 => 4., :k3 => 10., :k4 => 5.5, :k5 => 0.4])
335336
iscomplexbalanced(rn, rates)
336337
```
337338

338339
We can do a similar check for detailed balance.
339-
```@example s1
340+
```@example s1b
340341
isdetailedbalanced(rn, rates)
341342
```
342343

0 commit comments

Comments
 (0)