2

我正在尝试使用 DifferentialEquations.jl 的新初始化方案选项

https://diffeq.sciml.ai/dev/solvers/dae_solve/#Initialization-Schemes-1

但我不知道如何访问新方法。

using DifferentialEquations
import DifferentialEquations: ShampineCollocationInit
using Sundials
using Plots

function f(out,du,u,p,t)
  out[1] = - 0.04u[1]              + 1e4*u[2]*u[3] - du[1]
  out[2] = + 0.04u[1] - 3e7*u[2]^2 - 1e4*u[2]*u[3] - du[2]
  out[3] = u[1] + u[2] + u[3] - 1.0
end

u₀ = [1.0, 0, 0]
du₀ = [-0.04, 0.04, 0.0]
tspan = (0.0,100000.0)

differential_vars = [true,true,false]
prob = DAEProblem(f,du₀,u₀,tspan,differential_vars=differential_vars)

sol = solve(prob,IDA(initializealg = ShampineCollocationInit))

plot(sol, xscale=:log10, tspan=(1e-6, 1e5), layout=(3,1))

前面的示例返回以下错误:

WARNING: could not import DifferentialEquations.ShampineCollocationInit into Main
LoadError: UndefVarError: ShampineCollocationInit not defined
Stacktrace:
 [1] top-level scope at /home/Documents/test.jl:19
in expression starting at /home/Documents/test.jl:19

我究竟做错了什么?

4

1 回答 1

0

这些初始化方案仅适用于 OrdinaryDiffEq 算法,而 IDA (Sundials.jl) 的初始化在文档的 Sundials.jl 部分中定义,这可能会在不久的将来发生变化(当然有弃用警告),因为它变得越来越并且更加同质化。

于 2021-05-21T12:44:13.947 回答