@@ -17,6 +17,10 @@ struct LatticeTransportODEf{S,T}
17
17
"""
18
18
mtk_ps
19
19
"""
20
+ Work in progress.
21
+ """
22
+ p_setters
23
+ """
20
24
The non-spatial `ReactionSystem` which was used to create the `LatticeReactionSystem` contain
21
25
a set of parameters (either identical to, or a sub set of, `parameters(lrs)`). This vector
22
26
contain the indexes of the non-spatial system's parameters in `parameters(lrs)`. These are
@@ -77,7 +81,9 @@ struct LatticeTransportODEf{S,T}
77
81
nonspatial_rs_p_idxs = subset_indexes_of (parameters (reactionsystem (lrs)), parameters (lrs))
78
82
79
83
# WIP.
80
- mtk_ps = ModelingToolkit. MTKParameters (complete (convert (ODESystem, reactionsystem (lrs))), [e[1 ] => e[2 ][1 ] for e in vert_ps])
84
+ nonspatial_osys = complete (convert (ODESystem, reactionsystem (lrs)))
85
+ mtk_ps = MT. MTKParameters (nonspatial_osys, [e[1 ] => e[2 ][1 ] for e in vert_ps])
86
+ p_setters = [MT. setp (nonspatial_osys, p) for p in parameters (nonspatial_osys)]
81
87
82
88
# Computes the indexes of the vertex parameters in the vector of parameters.
83
89
# Input `vert_ps` is a vector map taking each parameter symbolic to its value (potentially a
@@ -97,7 +103,7 @@ struct LatticeTransportODEf{S,T}
97
103
# Declares `work_ps` (used as storage during computation) and the edge iterator.
98
104
work_ps = zeros (length (parameters (lrs)))
99
105
edge_iterator = Catalyst. edge_iterator (lrs)
100
- new {S,T} (ofunc, num_verts (lrs), num_species (lrs), vert_p_idxs, edge_p_idxs, mtk_ps,
106
+ new {S,T} (ofunc, num_verts (lrs), num_species (lrs), vert_p_idxs, edge_p_idxs, mtk_ps, p_setters,
101
107
nonspatial_rs_p_idxs, vert_ps, work_ps, v_ps_idx_types, transport_rates,
102
108
t_rate_idx_types, leaving_rates, edge_iterator)
103
109
end
@@ -120,6 +126,10 @@ struct LatticeTransportODEjac{R,S,T}
120
126
"""
121
127
mtk_ps
122
128
"""
129
+ Work in progress.
130
+ """
131
+ p_setters
132
+ """
123
133
The non-spatial `ReactionSystem` which was used to create the `LatticeReactionSystem` contain
124
134
a set of parameters (either identical to, or a sub set of, `parameters(lrs)`). This vector
125
135
contain the indexes of the non-spatial system's parameters in `parameters(lrs)`. These are
@@ -157,7 +167,9 @@ struct LatticeTransportODEjac{R,S,T}
157
167
nonspatial_rs_p_idxs = subset_indexes_of (parameters (reactionsystem (lrs)), parameters (lrs))
158
168
159
169
# WIP.
160
- mtk_ps = ModelingToolkit. MTKParameters (complete (convert (ODESystem, reactionsystem (lrs))), [e[1 ] => e[2 ][1 ] for e in vert_ps])
170
+ nonspatial_osys = complete (convert (ODESystem, reactionsystem (lrs)))
171
+ mtk_ps = MT. MTKParameters (nonspatial_osys, [e[1 ] => e[2 ][1 ] for e in vert_ps])
172
+ p_setters = [MT. setp (nonspatial_osys, p) for p in parameters (nonspatial_osys)]
161
173
162
174
# Input `vert_ps` is a vector map taking each parameter symbolic to its value (potentially a
163
175
# vector). This vector is already sorted according to the order of the parameters. Here, we extract
@@ -167,7 +179,7 @@ struct LatticeTransportODEjac{R,S,T}
167
179
work_ps = zeros (length (parameters (lrs)))
168
180
v_ps_idx_types = map (vp -> length (vp) == 1 , vert_ps)
169
181
new {R,S,typeof(jac_transport)} (ofunc, num_verts (lrs), num_species (lrs) , vert_p_idxs,
170
- edge_p_idxs, mtk_ps, nonspatial_rs_p_idxs, vert_ps,
182
+ edge_p_idxs, mtk_ps, p_setters, nonspatial_rs_p_idxs, vert_ps,
171
183
work_ps, v_ps_idx_types, sparse, jac_transport)
172
184
end
173
185
end
@@ -344,7 +356,7 @@ function (f_func::LatticeTransportODEf)(du, u, p, t)
344
356
update_work_vert_ps! (f_func, p, vert_i)
345
357
346
358
# Evaluate reaction contributions to du at vert_i.
347
- f_func. ofunc ((@view du[idxs]), (@view u[idxs]), nonspatial_ps ( f_func) , t)
359
+ f_func. ofunc ((@view du[idxs]), (@view u[idxs]), f_func. mtk_ps , t)
348
360
end
349
361
350
362
# s_idx is the species index among transport species, s is the index among all species.
@@ -372,7 +384,7 @@ function (jac_func::LatticeTransportODEjac)(J, u, p, t)
372
384
for vert_i in 1 : (jac_func. num_verts)
373
385
idxs = get_indexes (vert_i, jac_func. num_species)
374
386
update_work_vert_ps! (jac_func, p, vert_i)
375
- jac_func. ofunc. jac ((@view J[idxs, idxs]), (@view u[idxs]), nonspatial_ps ( jac_func) , t)
387
+ jac_func. ofunc. jac ((@view J[idxs, idxs]), (@view u[idxs]), jac_func. mtk_ps , t)
376
388
end
377
389
378
390
# Updates for the spatial reactions (adds the Jacobian values from the transportation reactions).
0 commit comments