Skip to content

Commit

Permalink
fix algorithm difftype
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Nov 17, 2017
1 parent 35a4ef4 commit 073d6e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/alg_utils.jl
Expand Up @@ -32,7 +32,7 @@ alg_interpretation(alg::StochasticDiffEqAlgorithm) = :Ito
alg_interpretation(alg::EulerHeun) = :Stratonovich
alg_interpretation(alg::RKMil{interpretation}) where {interpretation} = interpretation
alg_interpretation(alg::RKMilCommute{interpretation}) where {interpretation} = interpretation
alg_interpretation(alg::ImplicitRKMil{CS,AD,F,K,T,T2,Controller,interpretation}) where {CS,AD,F,K,T,T2,Controller,interpretation} = interpretation
alg_interpretation(alg::ImplicitRKMil{CS,AD,F,S,K,T,T2,Controller,interpretation}) where {CS,AD,F,S,K,T,T2,Controller,interpretation} = interpretation

alg_compatible(prob,alg::Union{StochasticDiffEqAlgorithm,StochasticDiffEqRODEAlgorithm}) = true

Expand Down
24 changes: 12 additions & 12 deletions src/algorithms.jl
Expand Up @@ -60,9 +60,9 @@ Base.@pure IIF1Mil(;nlsolve=NLSOLVEJL_SETUP()) = IIF1Mil{typeof(nlsolve)}(nlsolv

# SDIRK

struct ImplicitEM{CS,AD,F,K,T,T2,Controller} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
struct ImplicitEM{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::Symbol
diff_type::S
κ::K
tol::T
theta::T2
Expand All @@ -72,23 +72,23 @@ struct ImplicitEM{CS,AD,F,K,T,T2,Controller} <: StochasticDiffEqNewtonAlgorithm{
new_jac_conv_bound::T2
symplectic::Bool
end
Base.@pure ImplicitEM(;chunk_size=0,autodiff=true,diff_type=:central,
Base.@pure ImplicitEM(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
theta = 1/2,symplectic=false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ImplicitEM{chunk_size,autodiff,typeof(linsolve),
ImplicitEM{chunk_size,autodiff,typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
symplectic ? 1/2 : theta,
extrapolant,
min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)

struct ImplicitEulerHeun{CS,AD,F,K,T,T2,Controller} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
struct ImplicitEulerHeun{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::Symbol
diff_type::S
κ::K
tol::T
theta::T2
Expand All @@ -98,22 +98,22 @@ struct ImplicitEulerHeun{CS,AD,F,K,T,T2,Controller} <: StochasticDiffEqNewtonAlg
new_jac_conv_bound::T2
symplectic::Bool
end
Base.@pure ImplicitEulerHeun(;chunk_size=0,autodiff=true,diff_type=:central,
Base.@pure ImplicitEulerHeun(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
theta = 1/2,symplectic = false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ImplicitEulerHeun{chunk_size,autodiff,typeof(linsolve),
ImplicitEulerHeun{chunk_size,autodiff,typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
symplectic ? 1/2 : theta,
extrapolant,min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)

struct ImplicitRKMil{CS,AD,F,K,T,T2,Controller,interpretation} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
struct ImplicitRKMil{CS,AD,F,S,K,T,T2,Controller,interpretation} <: StochasticDiffEqNewtonAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::Symbol
diff_type::S
κ::K
tol::T
theta::T2
Expand All @@ -123,13 +123,13 @@ struct ImplicitRKMil{CS,AD,F,K,T,T2,Controller,interpretation} <: StochasticDiff
new_jac_conv_bound::T2
symplectic::Bool
end
Base.@pure ImplicitRKMil(;chunk_size=0,autodiff=true,diff_type=:central,
Base.@pure ImplicitRKMil(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
theta = 1/2,symplectic = false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
controller = :Predictive,interpretation=:Ito) =
ImplicitRKMil{chunk_size,autodiff,typeof(linsolve),
ImplicitRKMil{chunk_size,autodiff,typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),
controller,interpretation}(
linsolve,diff_type,κ,tol,
Expand Down
2 changes: 1 addition & 1 deletion test/sde/sde_twodimlinear_tests.jl
Expand Up @@ -42,7 +42,7 @@ sim = test_convergence(dts,prob,ImplicitRKMil(),numMonte=100)
sim = test_convergence(dts,prob,ImplicitRKMil(theta=1),numMonte=100)
@test abs(sim.𝒪est[:l2]-1) < 0.1

sim = test_convergence(dts,prob,ImplicitRKMil(theta=1,autodiff=false),numMonte=100)
sim = test_convergence(dts,prob,ImplicitRKMil(theta=1,autodiff=false),numMonte=200)
@test abs(sim.𝒪est[:l2]-1) < 0.1

sim = test_convergence(dts,prob,ImplicitRKMil(symplectic=true),numMonte=100)
Expand Down

0 comments on commit 073d6e0

Please sign in to comment.