From 3e7fa80197cf8af3e705f6897035125f9d0c061c Mon Sep 17 00:00:00 2001 From: xiaoming Date: Thu, 5 Jan 2023 16:17:43 +0100 Subject: [PATCH 1/3] Update coevolve.jl this pull request is related to https://github.com/SciML/JumpProcesses.jl/pull/276#issuecomment-1372219257 --- src/aggregators/coevolve.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From e310141df1377c38ed5ef9c57753bd8f86201500 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Thu, 5 Jan 2023 11:55:10 -0500 Subject: [PATCH 2/3] add test --- test/variable_rate.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/variable_rate.jl b/test/variable_rate.jl index a520535a..0d661798 100644 --- a/test/variable_rate.jl +++ b/test/variable_rate.jl @@ -144,3 +144,30 @@ 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.] + 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 \ No newline at end of file From d6021f93631d397d7ffe664b9c83489c5049d177 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Thu, 5 Jan 2023 11:56:57 -0500 Subject: [PATCH 3/3] format --- test/variable_rate.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/variable_rate.jl b/test/variable_rate.jl index 0d661798..99032fe3 100644 --- a/test/variable_rate.jl +++ b/test/variable_rate.jl @@ -148,15 +148,16 @@ 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.] + 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) + 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] + 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_) @@ -164,10 +165,11 @@ let tspan = (0.0, 30.0) dprob_ = DiscreteProblem(u0, tspan) alg = Coevolve() - @test_throws ErrorException JumpProblem(dprob_, alg, jumpset_, save_positions=(false, false)) + @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)) + rateinterval = ((u, p, t) -> 1.0)) @test_throws ErrorException JumpProblem(dprob_, alg, mass_action_jump_, vrj; - save_positions=(false, false)) -end \ No newline at end of file + save_positions = (false, false)) +end