Mos*_*teM 1 ode julia differentialequations.jl
在 Julia 中,我想解决具有外部强迫的 ODE 系统,g1(t), g2(t)例如
dx1(t) / dt = f1(x1, t) + g1(t)
dx2(t) / dt = f2(x1, x2, t) + g2(t)
Run Code Online (Sandbox Code Playgroud)
与从文件中读入的强制。
我正在使用这项研究来学习 Julia 和微分方程包,但我很难找到正确的方法。
我可以想象使用 acallback可以工作,但这似乎很麻烦。
您知道如何实施这种外部强迫吗?
您可以在积分函数内使用函数。因此,您可以使用Interpolations.jl 之类的东西从文件中的数据构建一个插值多项式,然后执行以下操作:
g1 = interpolate(data1, options...)
g2 = interpolate(data2, options...)
p = (g1,g2) # Localize these as parameters to the model
function f(du,u,p,t)
g1,g2 = p
du[1] = ... + g1[t] # Interpolations.jl interpolates via []
du[2] = ... + g2[t]
end
# Define u0 and tspan
ODEProblem(f,u0,tspan,p)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
167 次 |
| 最近记录: |