Skip to content

Commit 26634d3

Browse files
TorkelEisaacsas
andcommitted
Update src/spatial_reaction_systems/spatial_ODE_systems.jl
Co-authored-by: Sam Isaacson <[email protected]>
1 parent 121f2c2 commit 26634d3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/spatial_reaction_systems/spatial_ODE_systems.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ function build_jac_prototype(ns_jac_prototype::SparseMatrixCSC{Float64, Int64},
159159
# Set element values.
160160
if set_nonzero
161161
for (s, rates) in trans_rates, (e_idx, e) in enumerate(edges(lrs.lattice))
162-
jac_prototype[get_index(e.src, s, lrs.num_species), get_index(e.src, s, lrs.num_species)] -= get_component_value(rates, e_idx) # Term due to species leaving source vertex.
163-
jac_prototype[get_index(e.src, s, lrs.num_species), get_index(e.dst, s, lrs.num_species)] += get_component_value(rates, e_idx) # Term due to species arriving to destination vertex.
162+
srcidx = get_index(e.src, s, lrs.num_species)
163+
dstidx = get_index(e.dst, s, lrs.num_species)
164+
val = get_component_value(rates, e_idx)
165+
# Term due to species leaving source vertex.
166+
jac_prototype[srcidx, srcidx] -= val
167+
168+
# Term due to species arriving to destination vertex.
169+
jac_prototype[srcidx, dstidx] += val
164170
end
165171
end
166172

0 commit comments

Comments
 (0)