Skip to content

Commit 7f0c960

Browse files
residual update
1 parent 5aa08e4 commit 7f0c960

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
@@ -67,7 +67,7 @@ struct SimpleImplicitTauLeaping <: DiffEqBase.DEAlgorithm
6767
critical_threshold::Float64
6868
end
6969

70-
SimpleImplicitTauLeaping(; epsilon=0.05, L=10.0) = SimpleImplicitTauLeaping(epsilon, L)
70+
SimpleImplicitTauLeaping(; epsilon=0.05, critical_threshold=10.0) = SimpleImplicitTauLeaping(epsilon, critical_threshold)
7171

7272
function compute_hor(nu)
7373
hor = zeros(Int64, size(nu, 2))
@@ -127,9 +127,10 @@ function implicit_tau_step(u_prev, t_prev, tau, rate_cache, counts, nu, p, rate,
127127
function f(u_new, p)
128128
rate_new = zeros(eltype(u_new), numjumps)
129129
rate(rate_new, u_new, p, t_prev + tau)
130-
residual = u_new - u_prev
130+
residual = zeros(eltype(u_new), length(u_new))
131+
residual .= u_new - u_prev
131132
for j in 1:numjumps
132-
residual -= nu[:, j] * (counts[j] - tau * (rate_cache[j] - rate_new[j]))
133+
residual .-= nu[:, j] * (counts[j] - tau * (rate_cache[j] - rate_new[j]))
133134
end
134135
return residual
135136
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)