Skip to content

Commit da0418e

Browse files
authored
Merge pull request #282 from palmtree2013/coevolve_tiny_fix
Tiny fix of `Coevolve()` with the dependency graph check
2 parents e7b8752 + d6021f9 commit da0418e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/aggregators/coevolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function CoevolveJumpAggregation(nj::Int, njt::T, et::T, crs::Vector{T}, sr::Not
2727
rng::RNG; u::U, dep_graph = nothing, lrates, urates,
2828
rateintervals, haslratevec) where {T, S, F1, F2, RNG, U}
2929
if dep_graph === nothing
30-
if (get_num_majumps(maj) == 0) || !isempty(rs)
30+
if (get_num_majumps(maj) == 0) || !isempty(urates)
3131
error("To use Coevolve a dependency graph between jumps must be supplied.")
3232
else
3333
dg = make_dependency_graph(length(u), maj)

test/variable_rate.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,32 @@ x₀ = 1.0 + 0.0im
144144
prob = ODEProblem(f4, [x₀], Δt)
145145
jumpProblem = JumpProblem(prob, Direct(), jump)
146146
sol = solve(jumpProblem, Tsit5())
147+
148+
# test to check lack of dependency graphs is caught in Coevolve for systems with non-maj
149+
# jumps
150+
let
151+
maj_rate = [1.0]
152+
react_stoich_ = [Vector{Pair{Int, Int}}()]
153+
net_stoich_ = [[1 => 1]]
154+
mass_action_jump_ = MassActionJump(maj_rate, react_stoich_, net_stoich_;
155+
scale_rates = false)
156+
157+
affect! = function (integrator)
158+
integrator.u[1] -= 1
159+
end
160+
cs_rate1(u, p, t) = 0.2 * u[1]
161+
constant_rate_jump = ConstantRateJump(cs_rate1, affect!)
162+
jumpset_ = JumpSet((), (constant_rate_jump,), nothing, mass_action_jump_)
163+
164+
u0 = [0]
165+
tspan = (0.0, 30.0)
166+
dprob_ = DiscreteProblem(u0, tspan)
167+
alg = Coevolve()
168+
@test_throws ErrorException JumpProblem(dprob_, alg, jumpset_,
169+
save_positions = (false, false))
170+
171+
vrj = VariableRateJump(cs_rate1, affect!; urate = ((u, p, t) -> 1.0),
172+
rateinterval = ((u, p, t) -> 1.0))
173+
@test_throws ErrorException JumpProblem(dprob_, alg, mass_action_jump_, vrj;
174+
save_positions = (false, false))
175+
end

0 commit comments

Comments
 (0)