Skip to content

Commit 0b36e9b

Browse files
residual update
1 parent b0c91f5 commit 0b36e9b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/simple_regular_solve.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct SimpleImplicitTauLeaping <: DiffEqBase.DEAlgorithm
5656
critical_threshold::Float64
5757
end
5858

59-
SimpleImplicitTauLeaping(; epsilon=0.05, L=10.0) = SimpleImplicitTauLeaping(epsilon, L)
59+
SimpleImplicitTauLeaping(; epsilon=0.05, critical_threshold=10.0) = SimpleImplicitTauLeaping(epsilon, critical_threshold)
6060

6161
function compute_hor(nu)
6262
hor = zeros(Int64, size(nu, 2))
@@ -116,9 +116,10 @@ function implicit_tau_step(u_prev, t_prev, tau, rate_cache, counts, nu, p, rate,
116116
function f(u_new, p)
117117
rate_new = zeros(eltype(u_new), numjumps)
118118
rate(rate_new, u_new, p, t_prev + tau)
119-
residual = u_new - u_prev
119+
residual = zeros(eltype(u_new), length(u_new))
120+
residual .= u_new - u_prev
120121
for j in 1:numjumps
121-
residual -= nu[:, j] * (counts[j] - tau * (rate_cache[j] - rate_new[j]))
122+
residual .-= nu[:, j] * (counts[j] - tau * (rate_cache[j] - rate_new[j]))
122123
end
123124
return residual
124125
end

test/regular_jumps.jl

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

@@ -32,4 +32,4 @@ prob_disc = DiscreteProblem(u0, tspan, p)
3232
rj = RegularJump(regular_rate, regular_c, 3)
3333
jump_prob_tau = JumpProblem(prob_disc, Direct(), rj; rng=StableRNG(12345))
3434

35-
sol_implicit = solve(EnsembleProblem(jump_prob_tau), SimpleImplicitTauLeaping(), EnsembleSerial(); trajectories=Nsims, saveat=1.0)
35+
sol = solve(EnsembleProblem(jump_prob_tau), SimpleImplicitTauLeaping(), EnsembleSerial(); trajectories=Nsims, saveat=1.0)

0 commit comments

Comments
 (0)