diff --git a/Project.toml b/Project.toml index 1c3c5541f..c166a2053 100644 --- a/Project.toml +++ b/Project.toml @@ -50,7 +50,7 @@ Random = "1.6" RandomNumbers = "1.5.3" RecursiveArrayTools = "2, 3" Reexport = "0.2, 1.0" -SciMLBase = "2.0.6" +SciMLBase = "2.51" SciMLOperators = "0.2.9, 0.3" SparseArrays = "1.6" SparseDiffTools = "2" diff --git a/src/alg_utils.jl b/src/alg_utils.jl index 589f938cb..b7b152565 100644 --- a/src/alg_utils.jl +++ b/src/alg_utils.jl @@ -133,22 +133,22 @@ beta1_default(alg::Union{StochasticDiffEqAlgorithm,StochasticDiffEqRODEAlgorithm isdtchangeable(alg::Union{StochasticDiffEqAlgorithm,StochasticDiffEqRODEAlgorithm}) = true -SciMLBase.alg_interpretation(alg::StochasticDiffEqAlgorithm) = :Ito -SciMLBase.alg_interpretation(alg::EulerHeun) = :Stratonovich -SciMLBase.alg_interpretation(alg::LambaEulerHeun) = :Stratonovich -SciMLBase.alg_interpretation(alg::KomBurSROCK2) = :Stratonovich +SciMLBase.alg_interpretation(alg::StochasticDiffEqAlgorithm) = SciMLBase.AlgorithmInterpretation.Ito +SciMLBase.alg_interpretation(alg::EulerHeun) = SciMLBase.AlgorithmInterpretation.Stratonovich +SciMLBase.alg_interpretation(alg::LambaEulerHeun) = SciMLBase.AlgorithmInterpretation.Stratonovich +SciMLBase.alg_interpretation(alg::KomBurSROCK2) = SciMLBase.AlgorithmInterpretation.Stratonovich SciMLBase.alg_interpretation(alg::RKMil{interpretation}) where {interpretation} = interpretation SciMLBase.alg_interpretation(alg::SROCK1{interpretation,E}) where {interpretation,E} = interpretation SciMLBase.alg_interpretation(alg::RKMilCommute) = alg.interpretation SciMLBase.alg_interpretation(alg::RKMilGeneral) = alg.interpretation SciMLBase.alg_interpretation(alg::ImplicitRKMil{CS,AD,F,P,FDT,ST,CJ,N,T2,Controller,interpretation}) where {CS,AD,F,P,FDT,ST,CJ,N,T2,Controller,interpretation} = interpretation -SciMLBase.alg_interpretation(alg::RS1) = :Stratonovich -SciMLBase.alg_interpretation(alg::RS2) = :Stratonovich +SciMLBase.alg_interpretation(alg::RS1) = SciMLBase.AlgorithmInterpretation.Stratonovich +SciMLBase.alg_interpretation(alg::RS2) = SciMLBase.AlgorithmInterpretation.Stratonovich -SciMLBase.alg_interpretation(alg::NON) = :Stratonovich -SciMLBase.alg_interpretation(alg::COM) = :Stratonovich -SciMLBase.alg_interpretation(alg::NON2) = :Stratonovich +SciMLBase.alg_interpretation(alg::NON) = SciMLBase.AlgorithmInterpretation.Stratonovich +SciMLBase.alg_interpretation(alg::COM) = SciMLBase.AlgorithmInterpretation.Stratonovich +SciMLBase.alg_interpretation(alg::NON2) = SciMLBase.AlgorithmInterpretation.Stratonovich alg_compatible(prob, alg::Union{StochasticDiffEqAlgorithm,StochasticDiffEqRODEAlgorithm}) = true alg_compatible(prob, alg::StochasticDiffEqAlgorithm) = false diff --git a/src/algorithms.jl b/src/algorithms.jl index b38800595..c6f124904 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -77,11 +77,11 @@ Springer. Berlin Heidelberg (2011) RKMil: Nonstiff Method An explicit Runge-Kutta discretization of the strong order 1.0 Milstein method. -Defaults to solving the Ito problem, but RKMil(interpretation=:Stratonovich) makes it solve the Stratonovich problem. +Defaults to solving the Ito problem, but RKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich) makes it solve the Stratonovich problem. Only handles scalar and diagonal noise. """ struct RKMil{interpretation} <: StochasticDiffEqAdaptiveAlgorithm end -RKMil(;interpretation=:Ito) = RKMil{interpretation}() +RKMil(;interpretation=SciMLBase.AlgorithmInterpretation.Ito) = RKMil{interpretation}() """ Kloeden, P.E., Platen, E., Numerical Solution of Stochastic Differential Equations. @@ -89,37 +89,37 @@ Springer. Berlin Heidelberg (2011) RKMilCommute: Nonstiff Method An explicit Runge-Kutta discretization of the strong order 1.0 Milstein method for commutative noise problems. -Defaults to solving the Ito problem, but RKMilCommute(interpretation=:Stratonovich) makes it solve the Stratonovich problem. +Defaults to solving the Ito problem, but RKMilCommute(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich) makes it solve the Stratonovich problem. Uses a 1.5/2.0 error estimate for adaptive time stepping. Default: ii_approx=IICommutative() does not approximate the Levy area. """ struct RKMilCommute{T} <: StochasticDiffEqAdaptiveAlgorithm - interpretation::Symbol + interpretation::SciMLBase.AlgorithmInterpretation.T ii_approx::T end -RKMilCommute(;interpretation=:Ito, ii_approx=IICommutative()) = RKMilCommute(interpretation,ii_approx) +RKMilCommute(;interpretation=SciMLBase.AlgorithmInterpretation.Ito, ii_approx=IICommutative()) = RKMilCommute(interpretation,ii_approx) """ Kloeden, P.E., Platen, E., Numerical Solution of Stochastic Differential Equations. Springer. Berlin Heidelberg (2011) RKMilGeneral: Nonstiff Method -RKMilGeneral(;interpretation=:Ito, ii_approx=IILevyArea() +RKMilGeneral(;interpretation=SciMLBase.AlgorithmInterpretation.Ito, ii_approx=IILevyArea() An explicit Runge-Kutta discretization of the strong order 1.0 Milstein method for general non-commutative noise problems. -Allows for a choice of interpretation between :Ito and :Stratonovich. +Allows for a choice of interpretation between SciMLBase.AlgorithmInterpretation.Ito and SciMLBase.AlgorithmInterpretation.Stratonovich. Allows for a choice of iterated integral approximation. Default: ii_approx=IILevyArea() uses LevyArea.jl to choose optimal algorithm. See Kastner, F. and Rößler, A., arXiv: 2201.08424 Kastner, F. and Rößler, A., LevyArea.jl, 10.5281/ZENODO.5883748, https://github.com/stochastics-uni-luebeck/LevyArea.jl """ struct RKMilGeneral{T, TruncationType} <: StochasticDiffEqAdaptiveAlgorithm - interpretation::Symbol + interpretation::SciMLBase.AlgorithmInterpretation.T ii_approx::T c::Int p::TruncationType end -function RKMilGeneral(;interpretation=:Ito,ii_approx=IILevyArea(), c=1, p=nothing, dt=nothing) +function RKMilGeneral(;interpretation=SciMLBase.AlgorithmInterpretation.Ito,ii_approx=IILevyArea(), c=1, p=nothing, dt=nothing) γ = 1//1 p==true && (p = Int(floor(c*dt^(1//1-2//1*γ)) + 1)) RKMilGeneral{typeof(ii_approx), typeof(p)}(interpretation, ii_approx, c, p) @@ -160,13 +160,13 @@ struct WangLi3SMil_F <: StochasticDiffEqAlgorithm end """ SROCK1: S-ROCK Method Is a fixed step size stabilized explicit method for stiff problems. -Defaults to solving th Ito problem but SROCK1(interpretation=:Stratonovich) can make it solve the Stratonovich problem. +Defaults to solving th Ito problem but SROCK1(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich) can make it solve the Stratonovich problem. Strong order of convergence is 0.5 and weak order 1, but is optimised to get order 1 in case os scalar/diagonal noise. """ struct SROCK1{interpretation,E} <: StochasticDiffEqAlgorithm eigen_est::E end -SROCK1(;interpretation=:Ito,eigen_est=nothing) = SROCK1{interpretation,typeof(eigen_est)}(eigen_est) +SROCK1(;interpretation=SciMLBase.AlgorithmInterpretation.Ito,eigen_est=nothing) = SROCK1{interpretation,typeof(eigen_est)}(eigen_est) # Weak Order 2 for Alg in [:SROCK2, :KomBurSROCK2, :SROCKC2] @@ -701,7 +701,7 @@ ImplicitEulerHeun(;chunk_size=0,autodiff=true,diff_type=Val{:central}, ImplicitRKMil: Stiff Method An order 1.0 drift-implicit method. This is a theta method which defaults to theta=1 or the Trapezoid method on the drift term. -Defaults to solving the Ito problem, but ImplicitRKMil(interpretation=:Stratonovich) makes it solve the Stratonovich problem. +Defaults to solving the Ito problem, but ImplicitRKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich) makes it solve the Stratonovich problem. This method defaults to symplectic=false, but when true and theta=1/2 this is the implicit Midpoint method on the drift term and is symplectic in distribution. Handles diagonal and scalar noise. Uses a 1.5/2.0 heuristic for adaptive time stepping. """ @@ -721,7 +721,7 @@ ImplicitRKMil(;chunk_size=0,autodiff=true,diff_type=Val{:central}, extrapolant=:constant, theta = 1,symplectic = false, new_jac_conv_bound = 1e-3, - controller = :Predictive,interpretation=:Ito) = + controller = :Predictive,interpretation=SciMLBase.AlgorithmInterpretation.Ito) = ImplicitRKMil{chunk_size,autodiff, typeof(linsolve),typeof(precs),diff_type, OrdinaryDiffEq._unwrap_val(standardtag), diff --git a/src/perform_step/SROCK_perform_step.jl b/src/perform_step/SROCK_perform_step.jl index 5e9eba744..9825d8d53 100644 --- a/src/perform_step/SROCK_perform_step.jl +++ b/src/perform_step/SROCK_perform_step.jl @@ -14,7 +14,7 @@ cosh_inv = log(ω₀ + Sqrt_ω) # arcosh(ω₀) ω₁ = (Sqrt_ω*cosh(mdeg*cosh_inv))/(mdeg*sinh(mdeg*cosh_inv)) - if SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich α = cosh(mdeg*cosh_inv)/(2*ω₀*cosh((mdeg-1)*cosh_inv)) γ = 1/(2*α) β = -γ @@ -42,7 +42,7 @@ k = integrator.f(uᵢ₋₁,p,tᵢ₋₁) u = dt*μ*k + ν*uᵢ₋₁ + κ*uᵢ₋₂ - if (i > mdeg - 2) && SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + if (i > mdeg - 2) && SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich if i == mdeg - 1 gₘ₋₂ = integrator.g(uᵢ₋₁,p,tᵢ₋₁) if W.dW isa Number || !is_diagonal_noise(integrator.sol.prob) @@ -58,7 +58,7 @@ u .+= (β .* gₘ₋₂ .+ γ .* gₘ₋₁) .* W.dW end end - elseif (i == mdeg) && SciMLBase.alg_interpretation(integrator.alg) == :Ito + elseif (i == mdeg) && SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if W.dW isa Number gₘ₋₂ = integrator.g(uᵢ₋₁,p,tᵢ₋₁) uᵢ₋₂ = uᵢ₋₁ + sqrt(abs(dt))*gₘ₋₂ @@ -105,7 +105,7 @@ end cosh_inv = log(ω₀ + Sqrt_ω) # arcosh(ω₀) ω₁ = (Sqrt_ω*cosh(mdeg*cosh_inv))/(mdeg*sinh(mdeg*cosh_inv)) - if SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich α = cosh(mdeg*cosh_inv)/(2*ω₀*cosh((mdeg-1)*cosh_inv)) γ = 1/(2*α) β = -γ @@ -132,7 +132,7 @@ end κ = - Tᵢ₋₂/Tᵢ integrator.f(k,uᵢ₋₁,p,tᵢ₋₁) @.. u = dt*μ*k + ν*uᵢ₋₁ + κ*uᵢ₋₂ - if (i > mdeg - 2) && SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + if (i > mdeg - 2) && SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich if i == mdeg - 1 integrator.g(gₘ₋₂,uᵢ₋₁,p,tᵢ₋₁) if W.dW isa Number || is_diagonal_noise(integrator.sol.prob) @@ -152,7 +152,7 @@ end @.. u += γ*k end end - elseif (i == mdeg) && SciMLBase.alg_interpretation(integrator.alg) == :Ito + elseif (i == mdeg) && SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if W.dW isa Number || is_diagonal_noise(integrator.sol.prob) integrator.g(gₘ₋₂,uᵢ₋₁,p,tᵢ₋₁) @.. uᵢ₋₂ = uᵢ₋₁ + sqrt(abs(dt))*gₘ₋₂ diff --git a/src/perform_step/low_order.jl b/src/perform_step/low_order.jl index 054ee5f54..72b06620c 100644 --- a/src/perform_step/low_order.jl +++ b/src/perform_step/low_order.jl @@ -208,16 +208,16 @@ end K = @.. uprev + dt * du1 L = integrator.g(uprev,p,t) mil_correction = zero(u) - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito utilde = K + L*integrator.sqdt ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt) mil_correction = ggprime.*(W.dW.^2 .- abs(dt))./2 - elseif SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + elseif SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich utilde = uprev + L*integrator.sqdt ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt) mil_correction = ggprime.*(W.dW.^2)./2 else - error("Alg interpretation invalid. Use either :Ito or :Stratonovich") + error("Algorithm interpretation invalid. Use either SciMLBase.AlgorithmInterpretation.Ito or SciMLBase.AlgorithmInterpretation.Stratonovich") end u = K+L.*W.dW+mil_correction @@ -241,16 +241,16 @@ end integrator.g(L,uprev,p,t) @.. K = uprev + dt * du1 @.. du2 = zero(eltype(u)) # This makes it safe to re-use the array - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito @.. tmp = K + integrator.sqdt * L integrator.g(du2,tmp,p,t) @.. tmp = (du2-L)/(2integrator.sqdt)*(W.dW.^2 - abs(dt)) - elseif SciMLBase.alg_interpretation(integrator.alg) == :Stratonovich + elseif SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Stratonovich @.. tmp = uprev + integrator.sqdt * L integrator.g(du2,tmp,p,t) @.. tmp = (du2-L)/(2integrator.sqdt)*(W.dW.^2) else - error("Alg interpretation invalid. Use either :Ito or :Stratonovich") + error("Algorithm interpretation invalid. Use either SciMLBase.AlgorithmInterpretation.Ito or SciMLBase.AlgorithmInterpretation.Stratonovich") end @.. u = K+L*W.dW + tmp if integrator.opts.adaptive @@ -275,7 +275,7 @@ end J = get_iterated_I(dt, dW, W.dZ, Jalg) mil_correction = zero(u) - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if dW isa Number || is_diagonal_noise(integrator.sol.prob) J = J .- 1//2 .* abs(dt) else @@ -289,7 +289,7 @@ end K = uprev + dt*du1 if is_diagonal_noise(integrator.sol.prob) - tmp = (SciMLBase.alg_interpretation(integrator.alg) == :Ito ? K : uprev) .+ integrator.sqdt .* L + tmp = (SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito ? K : uprev) .+ integrator.sqdt .* L gtmp = integrator.g(tmp,p,t) Dgj = (gtmp - L)/sqdt ggprime_norm = integrator.opts.internalnorm(Dgj,t) @@ -343,7 +343,7 @@ end J = Jalg.J @.. mil_correction = zero(u) - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if dW isa Number || is_diagonal_noise(integrator.sol.prob) @.. J -= 1 // 2 * abs(dt) else @@ -357,7 +357,7 @@ end @.. K = uprev + dt*du1 if is_diagonal_noise(integrator.sol.prob) - tmp .= (SciMLBase.alg_interpretation(integrator.alg) == :Ito ? K : uprev) .+ integrator.sqdt .* L + tmp .= (SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito ? K : uprev) .+ integrator.sqdt .* L integrator.g(gtmp,tmp,p,t) @.. Dgj = (gtmp - L)/sqdt ggprime_norm = integrator.opts.internalnorm(Dgj,t) @@ -397,7 +397,7 @@ end J = get_iterated_I(dt, dW, W.dZ, Jalg, integrator.alg.p, integrator.alg.c, alg_order(integrator.alg)) - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if dW isa Number || is_diagonal_noise(integrator.sol.prob) J = J .- 1//2 .* abs(dt) else @@ -413,7 +413,7 @@ end if dW isa Number || is_diagonal_noise(integrator.sol.prob) K = @.. uprev + dt*du₁ - utilde = (SciMLBase.alg_interpretation(integrator.alg) == :Ito ? K : uprev) + L*integrator.sqdt + utilde = (SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito ? K : uprev) + L*integrator.sqdt ggprime = (integrator.g(utilde,p,t) .- L) ./ (integrator.sqdt) mil_correction = ggprime .* J u = K + L .* dW + mil_correction @@ -467,7 +467,7 @@ end @.. mil_correction = zero(eltype(u)) ggprime_norm = zero(eltype(ggprime)) - if SciMLBase.alg_interpretation(integrator.alg) == :Ito + if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito if dW isa Number || is_diagonal_noise(integrator.sol.prob) @.. J -= 1 // 2 * abs(dt) else @@ -478,7 +478,7 @@ end if dW isa Number || is_diagonal_noise(integrator.sol.prob) @.. K = uprev + dt*du₁ @.. du₂ = zero(eltype(u)) - tmp .= (SciMLBase.alg_interpretation(integrator.alg) == :Ito ? K : uprev) .+ integrator.sqdt .* L + tmp .= (SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito ? K : uprev) .+ integrator.sqdt .* L integrator.g(du₂,tmp,p,t) @.. ggprime = (du₂ - L)/sqdt ggprime_norm = integrator.opts.internalnorm(ggprime,t) diff --git a/src/perform_step/sdirk.jl b/src/perform_step/sdirk.jl index 7a3255688..d475a0096 100644 --- a/src/perform_step/sdirk.jl +++ b/src/perform_step/sdirk.jl @@ -24,21 +24,21 @@ end if cache isa ImplicitRKMilConstantCache || integrator.opts.adaptive == true - if SciMLBase.alg_interpretation(alg) == :Ito || + if SciMLBase.alg_interpretation(alg) == SciMLBase.AlgorithmInterpretation.Ito || cache isa ImplicitEMConstantCache K = @.. uprev + dt * ftmp utilde = K + L*integrator.sqdt ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt) mil_correction = ggprime .* (integrator.W.dW.^2 .- abs(dt))./2 gtmp += mil_correction - elseif SciMLBase.alg_interpretation(alg) == :Stratonovich || + elseif SciMLBase.alg_interpretation(alg) == SciMLBase.AlgorithmInterpretation.Stratonovich || cache isa ImplicitEulerHeunConstantCache utilde = uprev + L*integrator.sqdt ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt) mil_correction = ggprime.*(integrator.W.dW.^2)./2 gtmp += mil_correction else - error("Alg interpretation invalid. Use either :Ito or :Stratonovich") + error("Algorithm interpretation invalid. Use either SciMLBase.AlgorithmInterpretation.Ito or SciMLBase.AlgorithmInterpretation.Stratonovich") end end @@ -154,18 +154,18 @@ end if cache isa ImplicitRKMilCache gtmp3 = cache.gtmp3 - if SciMLBase.alg_interpretation(alg) == :Ito + if SciMLBase.alg_interpretation(alg) == SciMLBase.AlgorithmInterpretation.Ito @.. z = uprev + dt * tmp + integrator.sqdt * gtmp integrator.g(gtmp3,z,p,t) @.. gtmp3 = (gtmp3-gtmp)/(integrator.sqdt) # ggprime approximation @.. gtmp2 += gtmp3*(dW.^2 - abs(dt))/2 - elseif SciMLBase.alg_interpretation(alg) == :Stratonovich + elseif SciMLBase.alg_interpretation(alg) == SciMLBase.AlgorithmInterpretation.Stratonovich @.. z = uprev + integrator.sqdt * gtmp integrator.g(gtmp3,z,p,t) @.. gtmp3 = (gtmp3-gtmp)/(integrator.sqdt) # ggprime approximation @.. gtmp2 += gtmp3*(dW.^2)/2 else - error("Alg interpretation invalid. Use either :Ito or :Stratonovich") + error("Algorithm interpretation invalid. Use either SciMLBase.AlgorithmInterpretation.Ito or SciMLBase.AlgorithmInterpretation.Stratonovich") end end diff --git a/test/adaptive/sde_complex_adaptive_mean_test.jl b/test/adaptive/sde_complex_adaptive_mean_test.jl index 542fb6699..a427961c8 100644 --- a/test/adaptive/sde_complex_adaptive_mean_test.jl +++ b/test/adaptive/sde_complex_adaptive_mean_test.jl @@ -1,4 +1,5 @@ using StochasticDiffEq, DiffEqCallbacks, DiffEqNoiseProcess, Test, Random +import SciMLBase Random.seed!(100) # Definitions according to vector/matrix representations of operators from QuantumOptics @@ -44,20 +45,20 @@ let out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob1, RKMil{:Stratonovich}(), dt=1e-4, callback=scb1, seed = i, adaptive = false) + solve(prob1, RKMil{SciMLBase.AlgorithmInterpretation.Stratonovich}(), dt=1e-4, callback=scb1, seed = i, adaptive = false) avg1 .+= out1.saveval ./ Ntraj out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob1, RKMil{:Stratonovich}(), tstops = T, callback=scb1, + solve(prob1, RKMil{SciMLBase.AlgorithmInterpretation.Stratonovich}(), tstops = T, callback=scb1, save_everystep=false, save_start=false) avg2 .+= out1.saveval ./ Ntraj out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob2, RKMil{:Stratonovich}(), tstops = T, callback=scb1, + solve(prob2, RKMil{SciMLBase.AlgorithmInterpretation.Stratonovich}(), tstops = T, callback=scb1, save_everystep=false, save_start=false) avg3 .+= out1.saveval ./ Ntraj end @@ -88,20 +89,20 @@ let out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob1, RKMilGeneral(interpretation = :Stratonovich), dt=1e-4, callback=scb1, seed = i, adaptive = false) + solve(prob1, RKMilGeneral(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich), dt=1e-4, callback=scb1, seed = i, adaptive = false) avg1 .+= out1.saveval ./ Ntraj out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob1, RKMilGeneral(interpretation = :Stratonovich), tstops = T, callback=scb1, + solve(prob1, RKMilGeneral(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich), tstops = T, callback=scb1, save_everystep=false, save_start=false) avg2 .+= out1.saveval ./ Ntraj out1 = SavedValues(Float64,ComplexF64) scb1 = SavingCallback(fout, out1, saveat=T, save_everystep=false, save_start=false) - solve(prob2, RKMilGeneral(interpretation = :Stratonovich), tstops = T, callback=scb1, + solve(prob2, RKMilGeneral(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich), tstops = T, callback=scb1, save_everystep=false, save_start=false) avg3 .+= out1.saveval ./ Ntraj end diff --git a/test/reversal_tests.jl b/test/reversal_tests.jl index 06116faf0..9164d99d0 100644 --- a/test/reversal_tests.jl +++ b/test/reversal_tests.jl @@ -3,6 +3,7 @@ using Random using SDEProblemLibrary # automatically construct SDE transformation for Ito reversal using ModelingToolkit +import SciMLBase # tested solvers additive_noise_solver = [ @@ -19,14 +20,14 @@ Stratonovich_solver = [ # non-stiff methods EulerHeun(), LambaEulerHeun(), - RKMil(interpretation=:Stratonovich), - RKMilCommute(interpretation=:Stratonovich), - RKMilGeneral(interpretation=:Stratonovich), + RKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), + RKMilCommute(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), + RKMilGeneral(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), # S-Rock methods - SROCK1(interpretation=:Stratonovich), + SROCK1(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), # stiff methods ImplicitEulerHeun(), - ImplicitRKMil(interpretation=:Stratonovich), + ImplicitRKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), ISSEulerHeun(), ] diff --git a/test/stratonovich_convergence_tests.jl b/test/stratonovich_convergence_tests.jl index 4b8c14e35..2e457dfb3 100644 --- a/test/stratonovich_convergence_tests.jl +++ b/test/stratonovich_convergence_tests.jl @@ -1,5 +1,7 @@ using StochasticDiffEq, Test, Random, DiffEqDevTools using SDEProblemLibrary: prob_sde_linear_stratonovich, prob_sde_2Dlinear_stratonovich +import SciMLBase + Random.seed!(100) dts = 1 ./2 .^(10:-1:2) #14->7 good plot @@ -22,16 +24,16 @@ sim = test_convergence(dts,prob,ImplicitEulerHeun(theta=1),trajectories=Int(5e2 sim = test_convergence(dts,prob,ImplicitEulerHeun(symplectic=true),trajectories=Int(5e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 -sim = test_convergence(dts,prob,RKMil(interpretation=:Stratonovich),trajectories=Int(5e2)) +sim = test_convergence(dts,prob,RKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(5e2)) @test abs(sim.𝒪est[:l2]-1) < 0.2 -sim = test_convergence(dts,prob,RKMilGeneral(interpretation=:Stratonovich),trajectories=Int(5e2)) +sim = test_convergence(dts,prob,RKMilGeneral(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(5e2)) @test abs(sim.𝒪est[:l2]-1) < 0.2 -sim = test_convergence(dts,prob,ImplicitRKMil(interpretation=:Stratonovich),trajectories=Int(5e2)) +sim = test_convergence(dts,prob,ImplicitRKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(5e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 -sim = test_convergence(dts,prob,SROCK1(interpretation=:Stratonovich),trajectories=Int(2e2)) +sim = test_convergence(dts,prob,SROCK1(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(2e2)) @test abs(sim.𝒪est[:l2]-1) < 0.15 sim = test_convergence(dts,prob,KomBurSROCK2(),trajectories=Int(2e2)) @@ -61,25 +63,25 @@ sim = test_convergence(dts,prob,ImplicitEulerHeun(symplectic=true),trajectories println("RKMils") -sim = test_convergence(dts,prob,RKMil(interpretation=:Stratonovich),trajectories=Int(1e2)) +sim = test_convergence(dts,prob,RKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.2 -sim = test_convergence(dts,prob,RKMilGeneral(interpretation=:Stratonovich),trajectories=Int(1e2)) +sim = test_convergence(dts,prob,RKMilGeneral(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.2 -sim = test_convergence(dts,prob,ImplicitRKMil(interpretation=:Stratonovich), +sim = test_convergence(dts,prob,ImplicitRKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 -sim = test_convergence(dts,prob,ImplicitRKMil(theta=1,interpretation=:Stratonovich), +sim = test_convergence(dts,prob,ImplicitRKMil(theta=1,interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 -sim = test_convergence(dts,prob,ImplicitRKMil(symplectic=true,interpretation=:Stratonovich), +sim = test_convergence(dts,prob,ImplicitRKMil(symplectic=true,interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich), trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 -sim = test_convergence(dts,prob,SROCK1(interpretation=:Stratonovich),trajectories=Int(1e2)) +sim = test_convergence(dts,prob,SROCK1(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich),trajectories=Int(1e2)) @test abs(sim.𝒪est[:l2]-1) < 0.1 sim = test_convergence(dts,prob,KomBurSROCK2(),trajectories=Int(2e2)) diff --git a/test/zerod_noise_test.jl b/test/zerod_noise_test.jl index 9a51d7f96..652716787 100644 --- a/test/zerod_noise_test.jl +++ b/test/zerod_noise_test.jl @@ -1,4 +1,5 @@ using StochasticDiffEq, Test +import SciMLBase function f(du, u, p, t) du[1] = u[1] @@ -10,16 +11,16 @@ end u0 = [1.0] prob = SDEProblem{true}(f, g, u0, (0.0, 0.1)) -sol_ito = solve(prob, RKMil{:Ito}()) +sol_ito = solve(prob, RKMil{SciMLBase.AlgorithmInterpretation.Ito}()) @test length(sol_ito) < 100 -sol_strato = solve(prob, RKMil{:Stratonovich}(); dt=1e-2) +sol_strato = solve(prob, RKMil{SciMLBase.AlgorithmInterpretation.Stratonovich}(); dt=1e-2) @test length(sol_strato) < 100 sol_ito = solve(prob, RKMil()) @test length(sol_ito) < 100 -sol_strato = solve(prob, RKMil(interpretation=:Stratonovich); dt=1e-2) +sol_strato = solve(prob, RKMil(interpretation=SciMLBase.AlgorithmInterpretation.Stratonovich); dt=1e-2) @test length(sol_strato) < 100 sol_leh = solve(prob, LambaEulerHeun())