Catalyst: the reaction-network view
Start from a lowering — a Gamma(3, 1.5) delay as its chain — the same starting point every backend page uses. See Lowering a distribution to a dynamical system for what lower does.
julia
using LoweredDistributions
using Distributions
d = Gamma(3.0, 1.5)
chain = lower(d)ErlangChain(3 compartments)reaction_system threads a from species, through one species per phase, to a to species. This is the form to reach for when the delay is one transition inside a larger model: an Erlang-distributed infectious period in an SIR model, say, where the I -> R transition needs a non-exponential dwell time.
julia
using Catalyst
t = Catalyst.default_t()
@species Infectious(t) Recovered(t)
rs = reaction_system(d, Infectious, Recovered;
prefix = :Iphase, name = :infectious_period)
Catalyst.reactions(rs)4-element Vector{Catalyst.Reaction}:
0.6666666666666666, Infectious --> Iphase1
0.6666666666666666, Iphase1 --> Iphase2
0.6666666666666666, Iphase2 --> Iphase3
0.6666666666666666, Iphase3 --> RecoveredThree phases give three phase species and, with the entry reaction from Infectious, four reactions: Infectious -> Iphase1, two interior hops, and the exit into Recovered.
julia
Catalyst.species(rs)5-element Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}}:
Infectious(t)
Iphase1(t)
Iphase2(t)
Iphase3(t)
Recovered(t)