@@ -68,7 +68,7 @@ struct LatticeTransportODEf{S,T}
68
68
""" An iterator over all the edges of the lattice."""
69
69
edge_iterator:: Vector{Pair{Int64, Int64}}
70
70
71
- function LatticeTransportODEf (ofunc:: S , vert_ps,
71
+ function LatticeTransportODEf (ofunc:: S , vert_ps:: Vector{Pair{BasicSymbolic{Real},Vector{T}}} , edge_ps ,
72
72
transport_rates:: Vector{Pair{Int64, SparseMatrixCSC{T, Int64}}} ,
73
73
lrs:: LatticeReactionSystem ) where {S,T}
74
74
# Records which parameters and rates are uniform and which are not.
@@ -82,7 +82,7 @@ struct LatticeTransportODEf{S,T}
82
82
83
83
# WIP.
84
84
nonspatial_osys = complete (convert (ODESystem, reactionsystem (lrs)))
85
- p_init = [p => Dict (vert_ps)[p][1 ] for p in parameters (nonspatial_osys)]
85
+ p_init = [p => Dict ([ vert_ps; edge_ps] )[p][1 ] for p in parameters (nonspatial_osys)]
86
86
mtk_ps = MT. MTKParameters (nonspatial_osys, p_init)
87
87
p_setters = [MT. setp (nonspatial_osys, p) for p in parameters (nonspatial_osys)]
88
88
@@ -158,7 +158,7 @@ struct LatticeTransportODEjac{R,S,T}
158
158
""" The transport rates. This is a dense or sparse matrix (depending on what type of Jacobian is used)."""
159
159
jac_transport:: T
160
160
161
- function LatticeTransportODEjac (ofunc:: R , vert_ps,
161
+ function LatticeTransportODEjac (ofunc:: R , vert_ps:: Vector{Pair{BasicSymbolic{Real},Vector{S}}} , edge_ps ,
162
162
jac_transport:: Union{Nothing, SparseMatrixCSC{Float64, Int64}} ,
163
163
lrs:: LatticeReactionSystem , sparse:: Bool ) where {R,S}
164
164
@@ -169,7 +169,8 @@ struct LatticeTransportODEjac{R,S,T}
169
169
170
170
# WIP.
171
171
nonspatial_osys = complete (convert (ODESystem, reactionsystem (lrs)))
172
- mtk_ps = MT. MTKParameters (nonspatial_osys, [e[1 ] => e[2 ][1 ] for e in vert_ps])
172
+ p_init = [p => Dict ([vert_ps; edge_ps])[p][1 ] for p in parameters (nonspatial_osys)]
173
+ mtk_ps = MT. MTKParameters (nonspatial_osys, p_init)
173
174
p_setters = [MT. setp (nonspatial_osys, p) for p in parameters (nonspatial_osys)]
174
175
175
176
# Input `vert_ps` is a vector map taking each parameter symbolic to its value (potentially a
@@ -251,23 +252,23 @@ function build_odefunction(lrs::LatticeReactionSystem, vert_ps::Vector{Pair{Basi
251
252
ofunc_sparse = ODEFunction (osys; jac = true , sparse = true )
252
253
jac_transport = build_jac_prototype (ofunc_sparse. jac_prototype, transport_rates, lrs; set_nonzero = true )
253
254
if sparse
254
- f = LatticeTransportODEf (ofunc_sparse, [ vert_ps; edge_ps] , transport_rates, lrs)
255
+ f = LatticeTransportODEf (ofunc_sparse, vert_ps, edge_ps, transport_rates, lrs)
255
256
jac_transport = build_jac_prototype (ofunc_sparse. jac_prototype, transport_rates, lrs; set_nonzero = true )
256
- J = LatticeTransportODEjac (ofunc_dense, [ vert_ps; edge_ps] , jac_transport, lrs, true )
257
+ J = LatticeTransportODEjac (ofunc_dense, vert_ps, edge_ps, jac_transport, lrs, true )
257
258
jac_prototype = jac_transport
258
259
else
259
- f = LatticeTransportODEf (ofunc_dense, [ vert_ps; edge_ps] , transport_rates, lrs)
260
- J = LatticeTransportODEjac (ofunc_dense, [ vert_ps; edge_ps] , jac_transport, lrs, false )
260
+ f = LatticeTransportODEf (ofunc_dense, vert_ps, edge_ps, transport_rates, lrs)
261
+ J = LatticeTransportODEjac (ofunc_dense, vert_ps, edge_ps, jac_transport, lrs, false )
261
262
jac_prototype = nothing
262
263
end
263
264
else
264
265
if sparse
265
266
ofunc_sparse = ODEFunction (osys; jac = false , sparse = true )
266
- f = LatticeTransportODEf (ofunc_sparse, [ vert_ps; edge_ps] , transport_rates, lrs)
267
+ f = LatticeTransportODEf (ofunc_sparse, vert_ps, edge_ps, transport_rates, lrs)
267
268
jac_prototype = build_jac_prototype (ofunc_sparse. jac_prototype, transport_rates, lrs; set_nonzero = false )
268
269
else
269
270
ofunc_dense = ODEFunction (osys; jac = false , sparse = false )
270
- f = LatticeTransportODEf (ofunc_dense, [ vert_ps; edge_ps] , transport_rates, lrs)
271
+ f = LatticeTransportODEf (ofunc_dense, vert_ps, edge_ps, transport_rates, lrs)
271
272
jac_prototype = nothing
272
273
end
273
274
J = nothing
@@ -347,7 +348,7 @@ function build_jac_prototype(ns_jac_prototype::SparseMatrixCSC{Float64, Int64},
347
348
end
348
349
349
350
# Defines the forcing functor's effect on the (spatial) ODE system.
350
- function (f_func:: LatticeTransportODEf )(du, u, p, t)
351
+ function (f_func:: LatticeTransportODEf )(du:: AbstractVector , u, p, t)
351
352
# Updates for non-spatial reactions.
352
353
for vert_i in 1 : (f_func. num_verts)
353
354
# Gets the indices of all the species at vertex i.
@@ -378,7 +379,7 @@ function (f_func::LatticeTransportODEf)(du, u, p, t)
378
379
end
379
380
380
381
# Defines the Jacobian functor's effect on the (spatial) ODE system.
381
- function (jac_func:: LatticeTransportODEjac )(J, u, p, t)
382
+ function (jac_func:: LatticeTransportODEjac )(J:: AbstractMatrix , u, p, t)
382
383
J .= 0.0
383
384
384
385
# Update the Jacobian from non-spatial reaction terms.
0 commit comments