diff --git a/src/aggregators/coevolve.jl b/src/aggregators/coevolve.jl index 84cf3cac..9414cd78 100644 --- a/src/aggregators/coevolve.jl +++ b/src/aggregators/coevolve.jl @@ -27,7 +27,7 @@ function CoevolveJumpAggregation(nj::Int, njt::T, et::T, crs::Vector{T}, sr::Not rng::RNG; u::U, dep_graph = nothing, lrates, urates, rateintervals, haslratevec) where {T, S, F1, F2, RNG, U} if dep_graph === nothing - if (get_num_majumps(maj) == 0) || !isempty(rs) + if (get_num_majumps(maj) == 0) || !isempty(urates) error("To use Coevolve a dependency graph between jumps must be supplied.") else dg = make_dependency_graph(length(u), maj) diff --git a/test/variable_rate.jl b/test/variable_rate.jl index a520535a..99032fe3 100644 --- a/test/variable_rate.jl +++ b/test/variable_rate.jl @@ -144,3 +144,32 @@ x₀ = 1.0 + 0.0im prob = ODEProblem(f4, [x₀], Δt) jumpProblem = JumpProblem(prob, Direct(), jump) sol = solve(jumpProblem, Tsit5()) + +# test to check lack of dependency graphs is caught in Coevolve for systems with non-maj +# jumps +let + maj_rate = [1.0] + react_stoich_ = [Vector{Pair{Int, Int}}()] + net_stoich_ = [[1 => 1]] + mass_action_jump_ = MassActionJump(maj_rate, react_stoich_, net_stoich_; + scale_rates = false) + + affect! = function (integrator) + integrator.u[1] -= 1 + end + cs_rate1(u, p, t) = 0.2 * u[1] + constant_rate_jump = ConstantRateJump(cs_rate1, affect!) + jumpset_ = JumpSet((), (constant_rate_jump,), nothing, mass_action_jump_) + + u0 = [0] + tspan = (0.0, 30.0) + dprob_ = DiscreteProblem(u0, tspan) + alg = Coevolve() + @test_throws ErrorException JumpProblem(dprob_, alg, jumpset_, + save_positions = (false, false)) + + vrj = VariableRateJump(cs_rate1, affect!; urate = ((u, p, t) -> 1.0), + rateinterval = ((u, p, t) -> 1.0)) + @test_throws ErrorException JumpProblem(dprob_, alg, mass_action_jump_, vrj; + save_positions = (false, false)) +end