Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed Dec 17, 2024
1 parent 6e33f5b commit 569f468
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/spatial_reaction_systems/lattice_reaction_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ struct LatticeReactionSystem{Q, R, S, T} <: MT.AbstractTimeDependentSystem
sr -> check_spatial_reaction_validity(rs, sr; edge_parameters = edge_parameters),
spatial_reactions)

# Additional error checks.
if any(haskey(Symbolics.unwrap(symvar).metadata, Symbolics.ArrayShapeCtx)
for symvar in [ps; species(rs)])
println([ps; species(rs)])
throw(ArgumentError("Some species and/or parameters used to create the `LatticeReactionSystem` are array variables ($(filter(symvar -> haskey(Symbolics.unwrap(symvar).metadata, Symbolics.ArrayShapeCtx), [ps; species(rs)]))). This is currently not supported."))
end

return new{Q, R, S, T}(
rs, spatial_reactions, lattice, num_verts, num_edges, num_species,
spat_species, ps, vertex_parameters, edge_parameters, edge_iterator)
Expand Down
19 changes: 19 additions & 0 deletions test/spatial_modelling/lattice_reaction_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ let
@test_throws ArgumentError LatticeReactionSystem(rs, [tr], CartesianGrid((2,2)))
end

# Tests for array parameters/species.
let
tr = @transport_reaction D Y

rs1 = @reaction_network begin
@species X(t)[1:2] Y(t)
(k1,k2), X[1] <--> X[2]
end
@test_throws ArgumentError LatticeReactionSystem(rs1, [tr], CartesianGrid((2,2)))

rs2 = @reaction_network begin
@species Y(t)
@parameters k[1:2,1:2]
(k[1,1],k[1,2]), X11 <--> X12
(k[2,1],k[2,2]), X21 <--> X22
end
@test_throws ArgumentError LatticeReactionSystem(rs2, [tr], CartesianGrid((2,2)))
end

### Tests Grid Vertex and Edge Number Computation ###

# Tests that the correct numbers are computed for num_edges.
Expand Down

0 comments on commit 569f468

Please sign in to comment.