ODE 求解的问题

Ser*_*gei 6 julia

根据他们页面上的指南,我正在尝试解决 DifferentialEquation 包中的典型示例。

这是示例:

using DifferentialEquations
using Plots

function lorenz(t,u, du)
    du[1] = 10.0(u[2]-u[1])
    du[2] = u[1]*(28.0-u[3]) - u[2]
    du[3] = u[1]*u[2] - (8/3)*u[3]
end
   
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz,u0,tspan)
sol = solve(prob)
plot(sol,vars=(1,2,3))
Run Code Online (Sandbox Code Playgroud)

然后我得到:

错误:LoadError:参数已编入索引,但参数为nothing。您可能忘记将参数传递给 DEProblem!

这里有什么问题?提前致谢!

Ser*_*nes 2

您可以尝试遵循此示例,该示例建立在您所做的基础上:

using DifferentialEquations
using Plots

function lorenz(du,u,p,t)
 du[1] = p[1]*(u[2]-u[1])
 du[2] = u[1]*(p[2]-u[3]) - u[2]
 du[3] = u[1]*u[2] - p[3]*u[3]
end

u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
p = (10.0,28.0,8/3)
prob = ODEProblem(lorenz, u0, tspan,p)
sol = solve(prob)
xyzt = plot(sol, plotdensity=10000,lw=1.5)
xy = plot(sol, plotdensity=10000, vars=(1,2))
xz = plot(sol, plotdensity=10000, vars=(1,3))
yz = plot(sol, plotdensity=10000, vars=(2,3))
xyz = plot(sol, plotdensity=10000, vars=(1,2,3))
plot(plot(xyzt,xyz),plot(xy, xz, yz, layout=(1,3),w=1), layout=(2,1))
Run Code Online (Sandbox Code Playgroud)