Skip to content

Commit 1caacd5

Browse files
committed
save progress
1 parent 2409dcc commit 1caacd5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/spatial_reaction_systems/spatial_ODE_systems.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct LatticeTransportODEf{S,T}
6868
"""An iterator over all the edges of the lattice."""
6969
edge_iterator::Vector{Pair{Int64, Int64}}
7070

71-
function LatticeTransportODEf(ofunc::S, vert_ps,
71+
function LatticeTransportODEf(ofunc::S, vert_ps::Vector{Pair{BasicSymbolic{Real},Vector{T}}}, edge_ps,
7272
transport_rates::Vector{Pair{Int64, SparseMatrixCSC{T, Int64}}},
7373
lrs::LatticeReactionSystem) where {S,T}
7474
# Records which parameters and rates are uniform and which are not.
@@ -82,7 +82,7 @@ struct LatticeTransportODEf{S,T}
8282

8383
# WIP.
8484
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)]
8686
mtk_ps = MT.MTKParameters(nonspatial_osys, p_init)
8787
p_setters = [MT.setp(nonspatial_osys, p) for p in parameters(nonspatial_osys)]
8888

@@ -158,7 +158,7 @@ struct LatticeTransportODEjac{R,S,T}
158158
"""The transport rates. This is a dense or sparse matrix (depending on what type of Jacobian is used)."""
159159
jac_transport::T
160160

161-
function LatticeTransportODEjac(ofunc::R, vert_ps,
161+
function LatticeTransportODEjac(ofunc::R, vert_ps::Vector{Pair{BasicSymbolic{Real},Vector{S}}}, edge_ps,
162162
jac_transport::Union{Nothing, SparseMatrixCSC{Float64, Int64}},
163163
lrs::LatticeReactionSystem, sparse::Bool) where {R,S}
164164

@@ -169,7 +169,8 @@ struct LatticeTransportODEjac{R,S,T}
169169

170170
# WIP.
171171
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)
173174
p_setters = [MT.setp(nonspatial_osys, p) for p in parameters(nonspatial_osys)]
174175

175176
# 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
251252
ofunc_sparse = ODEFunction(osys; jac = true, sparse = true)
252253
jac_transport = build_jac_prototype(ofunc_sparse.jac_prototype, transport_rates, lrs; set_nonzero = true)
253254
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)
255256
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)
257258
jac_prototype = jac_transport
258259
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)
261262
jac_prototype = nothing
262263
end
263264
else
264265
if sparse
265266
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)
267268
jac_prototype = build_jac_prototype(ofunc_sparse.jac_prototype, transport_rates, lrs; set_nonzero = false)
268269
else
269270
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)
271272
jac_prototype = nothing
272273
end
273274
J = nothing
@@ -347,7 +348,7 @@ function build_jac_prototype(ns_jac_prototype::SparseMatrixCSC{Float64, Int64},
347348
end
348349

349350
# 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)
351352
# Updates for non-spatial reactions.
352353
for vert_i in 1:(f_func.num_verts)
353354
# Gets the indices of all the species at vertex i.
@@ -378,7 +379,7 @@ function (f_func::LatticeTransportODEf)(du, u, p, t)
378379
end
379380

380381
# 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)
382383
J .= 0.0
383384

384385
# Update the Jacobian from non-spatial reaction terms.

0 commit comments

Comments
 (0)