Skip to content

Commit 9eb65dd

Browse files
Leaping new controller interface
1 parent 01b0097 commit 9eb65dd

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

lib/OrdinaryDiffEqCore/src/integrators/controllers.jl

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ function sync_controllers!(cache1::IControllerCache, cache2::IControllerCache)
245245
return nothing
246246
end
247247

248-
function sync_controllers!(cache1::IControllerCache, cache2::IControllerCache)
249-
cache1.dtreject = cache2.dtreject
250-
return nothing
251-
end
252-
253248
# PI step size controller
254249
"""
255250
PIController(beta1, beta2)
@@ -457,20 +452,20 @@ Some standard controller parameters suggested in the literature are
457452
[DOI: 10.1145/641876.641877](https://doi.org/10.1145/641876.641877)
458453
- Söderlind, Wang (2006)
459454
Adaptive time-stepping and computational stability
460-
[DOI: 10.1016/j.cam.2005.03.008](https://doi.org/10.1016/j.cam.2005.03.008) # controller coefficients
461-
- Ranocha, Dalcin, Parsani, Ketcheson (2021) # history of the error estimates
462-
Optimized Runge-Kutta Methods with Automatic Step Size Control for # accept a step if the predicted change of the step size
463-
Compressible Computational Fluid Dynamics # is bigger than this parameter
455+
[DOI: 10.1016/j.cam.2005.03.008](https://doi.org/10.1016/j.cam.2005.03.008)
456+
- Ranocha, Dalcin, Parsani, Ketcheson (2021)
457+
Optimized Runge-Kutta Methods with Automatic Step Size Control for
458+
Compressible Computational Fluid Dynamics
464459
[arXiv:2104.06836](https://arxiv.org/abs/2104.06836) # limiter of the dt factor (before clipping)
465460
"""
466-
struct PIDController{QT, Limiter} <: AbstractLegacyController
461+
struct PIDController{QT, Limiter} <: AbstractController
467462
beta::NTuple{3, QT} # controller coefficients
468463
err::MVector{3, QT} # history of the error estimates (mutable via indexing)
469464
accept_safety::QT # accept a step if the predicted change of the step size
470465
# is bigger than this parameter
471466
limiter::Limiter # limiter of the dt factor (before clipping)
472-
qsteady_min::T
473-
qsteady_max::T
467+
qsteady_min::QT
468+
qsteady_max::QT
474469
end
475470

476471
@inline default_dt_factor_limiter(x) = one(x) + atan(x - one(x))

lib/StochasticDiffEqLeaping/src/algorithms.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ Critical parameter: tau should be small enough that jump rates don't change sign
3232
3333
- Gillespie, D.T., "Approximate accelerated stochastic simulation of chemically reacting systems"
3434
"""
35-
struct TauLeaping <: StochasticDiffEqJumpAdaptiveAlgorithm end
35+
@kwdef struct TauLeaping{QT} <: StochasticDiffEqJumpAdaptiveAlgorithm
36+
gamma::QT = 9 // 10
37+
qmax::QT = 10 // 1
38+
end
3639

3740
"""
3841
CaoTauLeaping()
@@ -74,7 +77,9 @@ Automatically adjusts tau based on:
7477
7578
- Cao, Y., Gillespie, D.T., Petzold, L.R., "Efficient step size selection for the tau-leaping method"
7679
"""
77-
struct CaoTauLeaping <: StochasticDiffEqJumpAdaptiveAlgorithm end
80+
@kwdef struct CaoTauLeaping <: StochasticDiffEqJumpAdaptiveAlgorithm
81+
gamma::QT = 9 // 10
82+
end
7883

7984
"""
8085
ImplicitTauLeaping(; nlsolve=NLFunctional())

lib/StochasticDiffEqLeaping/src/stepsize_controllers.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ function stepsize_controller!(integrator, alg::TauLeaping)
1010
end
1111

1212
function step_accept_controller!(integrator, alg::TauLeaping)
13-
integrator.q = min(integrator.opts.gamma / integrator.EEst, integrator.opts.qmax)
13+
integrator.q = min(integrator.alg.gamma / integrator.EEst, integrator.alg.qmax)
1414
return integrator.dt * integrator.q
1515
end
1616

1717
function step_reject_controller!(integrator, alg::TauLeaping)
18-
return integrator.dt = integrator.opts.gamma * integrator.dt / integrator.EEst
18+
return integrator.dt = integrator.alg.gamma * integrator.dt / integrator.EEst
1919
end
2020

2121
function stepsize_controller!(integrator, alg::CaoTauLeaping)

0 commit comments

Comments
 (0)