This suggests that we might benefit from a tool that simulates the interactions that occur in a network of reacting chemical species. In the next two weeks we will consider two standard means for modeling and simulating such systems. The first is associated with the name of Gillespie and the second with the names of Michaelis and Menten.
We begin with N reacting chemical species, S1, S2, ..., SN, and their initial quantities
X1, X2, ..., XN
R1, R2, ..., RM
c1, c2, ..., cM
X1+X2&rarr X3
For more general reactions we will write hm for the number of distinct Rm molecular reactant combinations available in the state (X1,...,Xn). We then arrive at the reaction probability am=hmcm. We shall have occasion to call on
a0 = a1+a2+...+aM
Given this list of reactions and their propensities one naturally asks Which reaction is likely to happen next? and When is it likely to occurr?
Gillespie answered both questions at once by calculating
P(T,m)dT = probability that, given the state (X1,...,Xn) at time t,
the next reaction will be reaction m and it will occur in the interval (t+T,t+T+dT).
P(T,m)dT = P0(T)amdT
P0(T+dT) = P0(T)(1-a0dT)
(P0(T+dT)-P0(T))/dT = -a0P0(T)
P0'(T) = -a0P0(T)
P0(T) = exp(-a0T)
P(T,m) = amexp(-a0T)
(G1) r1 = exp(-a0T)
(G2) a1+a2+...+am-1 < r2a0 < a1+a2+...+am
Gather propensities, reactions, initial molecular counts,
and maxiter from user/driver. Set t = 0 and iter = 0;
While iter < maxiter
Plot each Xj at time t
Calculate each aj
Generate r1 and r2
Solve (G1) and (G2) for T and m
Set t = t + T
Adjust each Xj according to Rm
Set iter = iter + 1
End
The first is his equation (29)
X&infin + Y &rarr 2Y with propensity c1
(G29)
2Y &rarr Z with propensity c2
Our second example is Gillespie's equation (33)
X&infin + Y1 &rarr 2Y1 with propensity c1
(G33) Y1 + Y2 &rarr 2Y2 with propensity c2
Y2 &rarr Z with propensity c3
For example, here is the code that generated the lovely figure below.
Of course for larger reaction networks we, I mean you, must proceed more systematically. On the road to a more general robust method we wish to address
1. The user is unsure of how to choose giter and would prefer
to provide the final time, tfin.
2. The user may enter the reaction list as a cell and code
the update of h in a subfunction and so preclude a very
lengthy if clause.
3. A single run of Gillespie is rarely sufficient - for it delivers
but one possible time evolution. The user would prefer that we
made nr runs and collected and presented statistics across runs.
To address the second point, I imagine a cell where each entry encodes a full reaction, say, e.g., by adopting the following convention
rtab{k}(1:2:end) = indicies of reaction species
rtab{k}(2:2:end) = actions for species above
rtab = {[1 1] % Y1 -> Y1 + 1
[1 -1 2 1] % Y1 -> Y1 - 1 and Y2 -> Y2 + 1
[2 -1]} % Y2 -> Y2 - 1
function h = update(y)
h(1) = y(1);
h(2) = y(1)*y(2);
h(3) = y(2);
a = c.*h;
To address the third point above, we should suppress plotting on the fly and instead return the time and desired solution vectors to a master control program that will collect and plot statistics. In particular, if we lay our Gillespie runs along the rows of a big matrix and takes means doen the columns, e.g.,
for j=1:nr
[t,x] = mygill(tfin,rtab,x0,c);
X(j,:) = x;
end
avg = mean(X,1);
tvec = 0:tinc:tfin
Law of Mass Action: The rate of a chemical reaction is directly proportional to the product of the effective concentrations of each participating molecule.
We will come to understand this law by its application. We revisit (G29) in the context of a fixed volume V and reaction rates k1 and k2 (in units of 1/M/s) where M designates Molar (which itself is short for moles per volume) and s designates seconds, and write
X&infin + Y -> 2Y (propensity c1)
(G29)
2Y -> Z (propensity c2)
(G30) d[Y(t)]/dt = 2c1[X&infin][Y(t)] - (c1[X&infin][Y(t)]+2(c2/2)[Y(t)]2)
gains - losses
k1 = c1V and k2 = c2V/2
Now, if, we denote the initial concentration
[Y(0)] = Y0
Y0k1[X&infin]
[Y(t)] = ---------------------------------
2Y0k2 - (2Y0k2-k1[X&infin])exp(-k1[X&infin]t)
We see that the deterministic model does an excellent job of tracking the stochastic trajectory. This is, of course, but one simple example.
The Law of Mass Action applied to the Lotka system
X&infin + Y1 -> 2Y1 (propensity c1)
(G38) Y1 + Y2 -> 2Y2 (propensity c2)
Y2 -> Z (propensity c3)
d[Y1]/dt = c1[X&infin][Y1] - c2[Y1][Y2]
(G39)
d[Y2]/dt = c2[Y1][Y2] - c3[Y2]
As further practice we consider a third example. Namely, the Brusselator of Gillespie, equation (44)
X&infin,1 -> Y1 (propensity c1)
X&infin,2 + Y1 -> Y2 + Z1 (propensity c2)
(G44)
2Y1 + Y2 -> 3Y1 (propensity c3)
Y1 -> Z2 (propensity c4)
d[Y1]/dt = c1[X&infin,1]- c2[X&infin,2][Y1] + (3-2)(c3/2)[Y1]2[Y2] - c4[Y1]
(G45)
d[Y2]/dt = c2[X&infin,2][Y1] - (c3/2)[Y1]2[Y2]