-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
In the vectorfield function
AlgebraicPetri.jl/src/AlgebraicPetri.jl
Lines 283 to 307 in e76f7cb
| """ vectorfield(pn::AbstractPetriNet) | |
| Generates a Julia function which calculates the vectorfield of the Petri net | |
| being simulated under the law of mass action. | |
| The resulting function has a signature of the form `f!(du, u, p, t)` and can be | |
| passed to the DifferentialEquations.jl solver package. | |
| """ | |
| vectorfield(pn::AbstractPetriNet) = begin | |
| tm = TransitionMatrices(pn) | |
| dt = tm.output - tm.input | |
| (du, u, p, t) -> begin | |
| rates = zeros(valtype(du), nt(pn)) | |
| u_m = [u[sname(pn, i)] for i in 1:ns(pn)] | |
| p_m = [p[tname(pn, i)] for i in 1:nt(pn)] | |
| for i in 1:nt(pn) | |
| rates[i] = valueat(p_m[i], u, t) * prod(u_m[j]^tm.input[i, j] for j in 1:ns(pn)) | |
| end | |
| for j in 1:ns(pn) | |
| du[sname(pn, j)] = sum(rates[i] * dt[i, j] for i in 1:nt(pn); init=0.0) | |
| end | |
| du | |
| end | |
| end | |
it is assumed that the state and parameter arrays u, p etc can be indexed by the species name. This is fine when the species name is a symbol, but its also possible to have species names that are tuples of symbols e.g. from using typed_product.
Is there a recommended way to define arrays that can be indexed by Tuples of symbols?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels