It is not complete answer since paclet we try to use has some typos in it (maybe it needs just version update). At first step we compute data using GillespieSSA
code above with a fixed random generator state
SeedRandom[1234];
As result we have
plot1=Plot[Evaluate@Through@sto@t, {t, 0, 2.5*3600}, Evaluate@op,
PlotLabel -> "stochastic SSA", PlotLegends -> Automatic, PlotRange -> Full]
Now we install paclet (use this line only once)
PacletInstall["RobertNachbar/CompartmentalModeling"]
After installation complete we call
Needs["RobertNachbar`CompartmentalModeling`"]
Now we can use paclet as follows
reactions = {a -> null, a -> b, b -> c, b -> d, c + e -> 2 c,
d + f -> 2 d, 700 c -> g, c + g -> g, 150 d -> h, d + h -> h};
vars = {a, b, c, d, e, f, g, h};
rates = {0.5, 0.5, 0.004, 0.006, 0.000000595, 0.000000411, 1000, 1000,
1000, 1000};
init = <|a -> 500, b -> 0, c -> 0, d -> 0, e -> 700, f -> 150, g -> 0,
h -> 0|>;
model = Table[
Transition[reactions[[i, 1]], rates[[i]], reactions[[i, 2]]], {i,
Length[reactions]}]
vars0 = {a0, b0, c0, d0, e0, f0, g0, h0}; params =
Table[vars0[[i]] -> init[vars[[i]]], {i, Length[vars0]}]
modelData =
PacletSymbol[
"RobertNachbar/CompartmentalModeling",
"RobertNachbar`CompartmentalModeling`KineticCompartmentalModel"][
model, t]
state = Replace[modelData["Variables"],
Join[Thread[vars -> vars0], {_ -> 0}], {1}]; SeedRandom[1234];
sol =
PacletSymbol[
"RobertNachbar/CompartmentalModeling",
"RobertNachbar`CompartmentalModeling`StochasticSolve"][
modelData["Rates"] /. params,
modelData["StoichiometricMatrix"] // Normal, state /. params,
modelData["Variables"], {t, 0, 2.5*3600}]
There are several messages concerning data interpolation, and we have out mixed data where c,d
are not interpolated. It is why we use
lstc = Evaluate[c /. sol[[1]]][[1]]; lstd =
Evaluate[d /. sol[[1]]][[1]];
Finally we compare two models
Show[plot1,Plot[Evaluate[{a@t, b@t, e@t, f@t, g@t, h@t} /. sol[[1]]], {t, 0,
2.5 3600}, PlotStyle -> Dashed, PlotRange -> All],
ListPlot[{lstc, lstd}, PlotStyle -> {Green, Magenta}, PlotLegends -> {c, d}]]
700 c -> g
and150 d -> h
reactions. It seems like these reactions occur very quickly afterc
hits 700 andd
hits 150. Is this what you want? $\endgroup$700 c -> g
would indicate an event when 700c
's ran into each other to react and form oneg
. Doesn't seem right to me, but you know your problem better. Perhaps you could add a description of the system you're modeling? $\endgroup$reactions
? $\endgroup$Null[t]
:) $\endgroup$null
to make model? $\endgroup$