Skip to content

Commit 1693869

Browse files
committed
update for new MTK Parameter structure
1 parent 89fcdf3 commit 1693869

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/spatial_reaction_systems/lattice_jump_systems.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
# Builds a spatial DiscreteProblem from a Lattice Reaction System.
44
function DiffEqBase.DiscreteProblem(lrs::LatticeReactionSystem, u0_in, tspan, p_in = DiffEqBase.NullParameters(), args...; kwargs...)
5-
is_transport_system(lrs) || error("Currently lattice Jump simulations only supported when all spatial reactions are transport reactions.")
5+
if !is_transport_system(lrs)
6+
error("Currently lattice Jump simulations only supported when all spatial reactions are transport reactions.")
7+
end
68

79
# Converts potential symmaps to varmaps
810
# Vertex and edge parameters may be given in a tuple, or in a common vector, making parameter case complicated.
@@ -18,20 +20,20 @@ function DiffEqBase.DiscreteProblem(lrs::LatticeReactionSystem, u0_in, tspan, p_
1820
# These elements are length 1 vectors (if the parameter is uniform),
1921
# or length num_verts/nE, with unique values for each vertex/edge (for vert_ps/edge_ps, respectively).
2022
vert_ps, edge_ps = lattice_process_p(p_in, vertex_parameters(lrs), edge_parameters(lrs), lrs)
21-
23+
2224
# Returns a DiscreteProblem.
2325
# Previously, a Tuple was used for (vert_ps, edge_ps), but this was converted to a Vector internally.
24-
return DiscreteProblem(lrs.rs, u0, tspan, [vert_ps, edge_ps], args...; kwargs...)
26+
return DiscreteProblem(u0, tspan, [vert_ps, edge_ps], args...; kwargs...)
2527
end
2628

2729
# Builds a spatial JumpProblem from a DiscreteProblem containg a Lattice Reaction System.
2830
function JumpProcesses.JumpProblem(lrs::LatticeReactionSystem, dprob, aggregator, args...; name = nameof(lrs.rs),
2931
combinatoric_ratelaws = get_combinatoric_ratelaws(lrs.rs), kwargs...)
3032
# Error checks.
31-
# The second check (Vector{Vector} is needed because on the CI server somehow the Tuple{..., ...} is converted into a Vector[..., ...]).
32-
# It does not happen when I run tests locally, so no ideal how to fix.
33-
(dprob.p isa Vector{Vector{Vector{Float64}}}) || dprob.p isa Vector{Vector} || error("Parameters in input DiscreteProblem is of an unexpected type: $(typeof(dprob.p)). Was a LatticeReactionProblem passed into the DiscreteProblem when it was created?")
34-
33+
if !isnothing(dprob.f.sys)
34+
error("Unexpected `DiscreteProblem` passed into `JumpProblem`. Was a `LatticeReactionSystem` used as input to the initial `DiscreteProblem`?")
35+
end
36+
3537
# Computes hopping constants and mass action jumps (requires some internal juggling).
3638
# Currently, JumpProcesses requires uniform vertex parameters (hence `p=first.(dprob.p[1])`).
3739
# Currently, the resulting JumpProblem does not depend on parameters (no way to incorporate these).

0 commit comments

Comments
 (0)