Skip to content

Commit 5fe0ab2

Browse files
TorkelEisaacsas
andcommitted
Update src/spatial_reaction_systems/spatial_ODE_systems.jl
Co-authored-by: Sam Isaacson <[email protected]>
1 parent b93bcb1 commit 5fe0ab2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/spatial_reaction_systems/spatial_ODE_systems.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@ end
140140
# Defines the forcing functor's effect on the (spatial) ODE system.
141141
function (f_func::LatticeTransportODEf)(du, u, p, t)
142142
# Updates for non-spatial reactions.
143-
for vert_i in 1:(f_func.num_verts) # Loops through each vertex of the lattice. Applies the (non-spatial) ODEFunction to the species in that vertex.
144-
f_func.ofunc((@view du[get_indexes(vert_i, f_func.num_species)]), # Get the indexes of the i'th vertex (current one in the loop) in the u vector. Uses this to create a view of the vector to which the new species concentrations are written.
145-
(@view u[get_indexes(vert_i, f_func.num_species)]), # Same as above, but reads the current species concentrations.
146-
view_vert_ps_vector!(f_func.work_vert_ps, p, vert_i, f_func.enum_v_ps_idx_types), # Gets a vector with the values of the (vertex) parameters in the current vertex.
147-
t) # Time.
143+
for vert_i in 1:(f_func.num_verts)
144+
# gets the indices of species at vertex i
145+
idxs = get_indexes(vert_i, f_func.num_species)
146+
147+
# vector of vertex ps at vert_i
148+
vert_i_ps = view_vert_ps_vector!(f_func.work_vert_ps, p, vert_i, f_func.enum_v_ps_idx_types)
149+
150+
# evaluate reaction contributions to du at vert_i
151+
f_func.ofunc((@view du[idxs]), (@view u[idxs]), vert_i_ps, t)
148152
end
149153

150154
# Updates for spatial reactions.

0 commit comments

Comments
 (0)