Skip to content

Commit 0a6835f

Browse files
authored
Merge pull request #462 from isaacsas/add_vrj_test
add implicit solver VariableRateJump test
2 parents 5f9f84a + 4c6cff2 commit 0a6835f

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

HISTORY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
## JumpProcesses unreleased (master branch)
44

55
## 9.14
6-
- Added the constant complexity next reaction method (CCNRM).
6+
7+
- Added the constant complexity next reaction method (CCNRM).
78

89
## 9.13
910

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ julia = "1.10"
4949
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
5050
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
5151
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
52+
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
5253
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
5354
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
5455
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
@@ -57,4 +58,5 @@ StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
5758
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5859

5960
[targets]
60-
test = ["DiffEqCallbacks", "LinearAlgebra", "OrdinaryDiffEq", "SafeTestsets", "StableRNGs", "Statistics", "StochasticDiffEq", "Test", "FastBroadcast"]
61+
test = ["DiffEqCallbacks", "LinearAlgebra", "LinearSolve", "OrdinaryDiffEq",
62+
"SafeTestsets", "StableRNGs", "Statistics", "StochasticDiffEq", "Test", "FastBroadcast"]

test/table_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ end
6565
##### PRIORITY TIME TABLE TESTS FOR CCNRM
6666
mintime = 0.0;
6767
maxtime = 100.0;
68-
timestep = 1.5/16;
68+
timestep = 1.5 / 16;
6969
times = [2.0, 8.0, 13.0, 15.0, 74.0]
7070

7171
ptt = DJ.PriorityTimeTable(times, mintime, timestep)
@@ -89,7 +89,7 @@ end
8989
@test DJ.getfirst(ptt) === (0, 0) # No more left.
9090

9191
mintime = 66.0;
92-
timestep = 0.75/16;
92+
timestep = 0.75 / 16;
9393
DJ.rebuild!(ptt, mintime, timestep)
9494
@test ptt.groups[11].numpids == 2 # 73.5-74.25
9595
@test ptt.groups[18].numpids == 1

test/variable_rate.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DiffEqBase, JumpProcesses, OrdinaryDiffEq, StochasticDiffEq, Test
2-
using Random
2+
using Random, LinearSolve
33
using StableRNGs
44
rng = StableRNG(12345)
55

@@ -275,6 +275,16 @@ end
275275
# https://github.com/SciML/JumpProcesses.jl/issues/320
276276
# note that even with the seeded StableRNG this test is not
277277
# deterministic for some reason.
278+
function getmean(Nsims, prob, alg, dt, tsave)
279+
umean = zeros(length(tsave))
280+
for i in 1:Nsims
281+
sol = solve(prob, alg; saveat = dt)
282+
umean .+= Array(sol(tsave; idxs = 1))
283+
end
284+
umean ./= Nsims
285+
return umean
286+
end
287+
278288
let
279289
rng = StableRNG(12345)
280290
b = 2.0
@@ -309,11 +319,8 @@ let
309319
sjm_prob = JumpProblem(ode_prob, b_jump, d_jump; rng)
310320
dt = 0.1
311321
tsave = range(tspan[1], tspan[2]; step = dt)
312-
umean = zeros(length(tsave))
313-
for i in 1:Nsims
314-
sol = solve(sjm_prob, Tsit5(); saveat = dt)
315-
umean .+= Array(sol(tsave; idxs = 1))
322+
for alg in (Tsit5(), Rodas5P(linsolve = QRFactorization()))
323+
umean = getmean(Nsims, sjm_prob, alg, dt, tsave)
324+
@test all(abs.(umean .- n.(tsave)) .< 0.05 * n.(tsave))
316325
end
317-
umean ./= Nsims
318-
@test all(abs.(umean .- n.(tsave)) .< 0.05 * n.(tsave))
319326
end

0 commit comments

Comments
 (0)