Skip to content

Commit

Permalink
Merge pull request #99 from JuliaDiffEq/myb/nlsolve
Browse files Browse the repository at this point in the history
Upgrade implicit solvers to the latest nlsolve
  • Loading branch information
YingboMa committed Aug 19, 2018
2 parents e50f9ab + cf456dd commit ad44fc7
Show file tree
Hide file tree
Showing 18 changed files with 671 additions and 947 deletions.
5 changes: 5 additions & 0 deletions src/StochasticDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ module StochasticDiffEq
include("options_type.jl")
include("derivative_wrappers.jl")
include("interp_func.jl")
include("nlsolve/type.jl")
include("nlsolve/newton.jl")
include("nlsolve/functional.jl")
include("caches/cache_types.jl")
include("caches/basic_method_caches.jl")
include("caches/lamba_caches.jl")
Expand Down Expand Up @@ -112,4 +115,6 @@ module StochasticDiffEq
#Misc Tools
export checkSRIOrder, checkSRAOrder, constructSRIW1, constructSRA1

export NLFunctional, NLNewton, NLAnderson

end # module
2 changes: 1 addition & 1 deletion src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ alg_interpretation(alg::EulerHeun) = :Stratonovich
alg_interpretation(alg::LambaEulerHeun) = :Stratonovich
alg_interpretation(alg::RKMil{interpretation}) where {interpretation} = interpretation
alg_interpretation(alg::RKMilCommute{interpretation}) where {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_interpretation(alg::ImplicitRKMil{CS,AD,F,S,N,T2,Controller,interpretation}) where {CS,AD,F,S,N,T2,Controller,interpretation} = interpretation

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

Expand Down
123 changes: 49 additions & 74 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,164 +111,139 @@ IIF1Mil(;nlsolve=NLSOLVEJL_SETUP()) = IIF1Mil{typeof(nlsolve)}(nlsolve)

# SDIRK

struct ImplicitEM{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct ImplicitEM{CS,AD,F,F2,S,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
nlsolve::F2
diff_type::S
κ::K
tol::T
theta::T2
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
symplectic::Bool
end
ImplicitEM(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
extrapolant=:constant,
theta = 1/2,symplectic=false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ImplicitEM{chunk_size,autodiff,
typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),
typeof(linsolve),typeof(nlsolve),typeof(diff_type),
typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
linsolve,nlsolve,diff_type,
symplectic ? 1/2 : theta,
extrapolant,
min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)
extrapolant,new_jac_conv_bound,symplectic)

struct ImplicitEulerHeun{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct ImplicitEulerHeun{CS,AD,F,S,N,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::S
κ::K
tol::T
nlsolve::N
theta::T2
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
symplectic::Bool
end
ImplicitEulerHeun(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
extrapolant=:constant,
theta = 1/2,symplectic = false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ImplicitEulerHeun{chunk_size,autodiff,
typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),
typeof(nlsolve),
typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
linsolve,diff_type,nlsolve,
symplectic ? 1/2 : theta,
extrapolant,min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)
extrapolant,
new_jac_conv_bound,symplectic)

struct ImplicitRKMil{CS,AD,F,S,K,T,T2,Controller,interpretation} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct ImplicitRKMil{CS,AD,F,S,N,T2,Controller,interpretation} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::S
κ::K
tol::T
nlsolve::N
theta::T2
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
symplectic::Bool
end
ImplicitRKMil(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
extrapolant=:constant,
theta = 1/2,symplectic = false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
new_jac_conv_bound = 1e-3,
controller = :Predictive,interpretation=:Ito) =
ImplicitRKMil{chunk_size,autodiff,
typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),
typeof(nlsolve),typeof(new_jac_conv_bound),
controller,interpretation}(
linsolve,diff_type,κ,tol,
linsolve,diff_type,nlsolve,
symplectic ? 1/2 : theta,
extrapolant,min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)
extrapolant,
new_jac_conv_bound,symplectic)

struct ISSEM{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct ISSEM{CS,AD,F,S,N,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::S
κ::K
tol::T
nlsolve::N
theta::T2
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
symplectic::Bool
end
ISSEM(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
extrapolant=:constant,
theta = 1,symplectic=false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ISSEM{chunk_size,autodiff,
typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),
typeof(nlsolve),
typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
linsolve,diff_type,nlsolve,
symplectic ? 1/2 : theta,
extrapolant,
min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)
new_jac_conv_bound,symplectic)

struct ISSEulerHeun{CS,AD,F,S,K,T,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct ISSEulerHeun{CS,AD,F,S,N,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::S
κ::K
tol::T
nlsolve::N
theta::T2
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
symplectic::Bool
end
ISSEulerHeun(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
extrapolant=:constant,min_newton_iter=1,
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
extrapolant=:constant,
theta = 1,symplectic=false,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
new_jac_conv_bound = 1e-3,
controller = :Predictive) =
ISSEulerHeun{chunk_size,autodiff,
typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,
typeof(nlsolve),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,nlsolve,
symplectic ? 1/2 : theta,
extrapolant,
min_newton_iter,
max_newton_iter,new_jac_conv_bound,symplectic)
new_jac_conv_bound,symplectic)

struct SKenCarp{CS,AD,F,FDT,K,T,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
struct SKenCarp{CS,AD,F,FDT,N,T2,Controller} <: StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,Controller}
linsolve::F
diff_type::FDT
κ::K
tol::T
nlsolve::N
smooth_est::Bool
extrapolant::Symbol
min_newton_iter::Int
max_newton_iter::Int
new_jac_conv_bound::T2
end

SKenCarp(;chunk_size=0,autodiff=true,diff_type=Val{:central},
linsolve=DEFAULT_LINSOLVE,κ=nothing,tol=nothing,
smooth_est=true,extrapolant=:min_correct,min_newton_iter=1,
max_newton_iter=7,new_jac_conv_bound = 1e-3,
controller = :Predictive) =
linsolve=DEFAULT_LINSOLVE,nlsolve=NLNewton(),
smooth_est=true,extrapolant=:min_correct,
new_jac_conv_bound = 1e-3,controller = :Predictive) =
SKenCarp{chunk_size,autodiff,typeof(linsolve),typeof(diff_type),
typeof(κ),typeof(tol),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,κ,tol,smooth_est,extrapolant,min_newton_iter,
max_newton_iter,new_jac_conv_bound)
typeof(nlsolve),typeof(new_jac_conv_bound),controller}(
linsolve,diff_type,nlsolve,smooth_est,extrapolant,new_jac_conv_bound)

################################################################################

Expand Down
Loading

0 comments on commit ad44fc7

Please sign in to comment.