如何求解 space 中的四阶微分方程和 Julia 中的时间变量
How to solve a 4th order differential equation in space and time variables in Julia
我对在 Julia 中求解微分方程比较陌生,因此无法弄清楚如何求解 2 个自变量(space 和时间)中的高阶方程,因此请求帮助。
我正在尝试使用 Julia 绘制悬挂在天花板上的流体膜的 h(流体膜高度)与 x(长度跨度)之间的曲线,由于 Rayleigh–泰勒
不稳定性。 有 2 个关键微分方程控制这种现象。
The two odes are listed here
这里h代表液膜高度,B0=0.134,其余为h和q对时间(t)和space(x)的导数。符号Dxxxh表示3rd h 对 x 的阶导数。 space跨度可以认为是L=24。 The boundary conditions are defined here.
可以使用这个找到 h 在 t=0 时的初始值 expression where epsilon=0.0009.The expected plot is as shown here. 情节随着时间的推移而滑动。
NeuralPDE.jl is a physics-informed neural network based PDE solver. It can handle this kind of equation when given symbolically. Here is an example 求解 Kuramoto–Sivashinsky 方程,也是一个四阶 PDE。
using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, Optim, DiffEqFlux
import ModelingToolkit: Interval, infimum, supremum
@parameters x, t
@variables u(..)
Dt = Differential(t)
Dx = Differential(x)
Dx2 = Differential(x)^2
Dx3 = Differential(x)^3
Dx4 = Differential(x)^4
α = 1
β = 4
γ = 1
eq = Dt(u(x,t)) + u(x,t)*Dx(u(x,t)) + α*Dx2(u(x,t)) + β*Dx3(u(x,t)) + γ*Dx4(u(x,t)) ~ 0
u_analytic(x,t;z = -x/2+t) = 11 + 15*tanh(z) -15*tanh(z)^2 - 15*tanh(z)^3
du(x,t;z = -x/2+t) = 15/2*(tanh(z) + 1)*(3*tanh(z) - 1)*sech(z)^2
bcs = [u(x,0) ~ u_analytic(x,0),
u(-10,t) ~ u_analytic(-10,t),
u(10,t) ~ u_analytic(10,t),
Dx(u(-10,t)) ~ du(-10,t),
Dx(u(10,t)) ~ du(10,t)]
# Space and time domains
domains = [x ∈ Interval(-10.0,10.0),
t ∈ Interval(0.0,1.0)]
# Discretization
dx = 0.4; dt = 0.2
# Neural network
chain = FastChain(FastDense(2,12,Flux.σ),FastDense(12,12,Flux.σ),FastDense(12,1))
discretization = PhysicsInformedNN(chain, GridTraining([dx,dt]))
@named pde_system = PDESystem(eq,bcs,domains,[x,t],[u(x, t)])
prob = discretize(pde_system,discretization)
cb = function (p,l)
println("Current loss is: $l")
return false
end
opt = Optim.BFGS()
res = GalacticOptim.solve(prob,opt; cb = cb, maxiters=2000)
phi = discretization.phi
我对在 Julia 中求解微分方程比较陌生,因此无法弄清楚如何求解 2 个自变量(space 和时间)中的高阶方程,因此请求帮助。
我正在尝试使用 Julia 绘制悬挂在天花板上的流体膜的 h(流体膜高度)与 x(长度跨度)之间的曲线,由于 Rayleigh–泰勒 不稳定性。 有 2 个关键微分方程控制这种现象。 The two odes are listed here
这里h代表液膜高度,B0=0.134,其余为h和q对时间(t)和space(x)的导数。符号Dxxxh表示3rd h 对 x 的阶导数。 space跨度可以认为是L=24。 The boundary conditions are defined here.
可以使用这个找到 h 在 t=0 时的初始值 expression where epsilon=0.0009.The expected plot is as shown here. 情节随着时间的推移而滑动。
NeuralPDE.jl is a physics-informed neural network based PDE solver. It can handle this kind of equation when given symbolically. Here is an example 求解 Kuramoto–Sivashinsky 方程,也是一个四阶 PDE。
using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, Optim, DiffEqFlux
import ModelingToolkit: Interval, infimum, supremum
@parameters x, t
@variables u(..)
Dt = Differential(t)
Dx = Differential(x)
Dx2 = Differential(x)^2
Dx3 = Differential(x)^3
Dx4 = Differential(x)^4
α = 1
β = 4
γ = 1
eq = Dt(u(x,t)) + u(x,t)*Dx(u(x,t)) + α*Dx2(u(x,t)) + β*Dx3(u(x,t)) + γ*Dx4(u(x,t)) ~ 0
u_analytic(x,t;z = -x/2+t) = 11 + 15*tanh(z) -15*tanh(z)^2 - 15*tanh(z)^3
du(x,t;z = -x/2+t) = 15/2*(tanh(z) + 1)*(3*tanh(z) - 1)*sech(z)^2
bcs = [u(x,0) ~ u_analytic(x,0),
u(-10,t) ~ u_analytic(-10,t),
u(10,t) ~ u_analytic(10,t),
Dx(u(-10,t)) ~ du(-10,t),
Dx(u(10,t)) ~ du(10,t)]
# Space and time domains
domains = [x ∈ Interval(-10.0,10.0),
t ∈ Interval(0.0,1.0)]
# Discretization
dx = 0.4; dt = 0.2
# Neural network
chain = FastChain(FastDense(2,12,Flux.σ),FastDense(12,12,Flux.σ),FastDense(12,1))
discretization = PhysicsInformedNN(chain, GridTraining([dx,dt]))
@named pde_system = PDESystem(eq,bcs,domains,[x,t],[u(x, t)])
prob = discretize(pde_system,discretization)
cb = function (p,l)
println("Current loss is: $l")
return false
end
opt = Optim.BFGS()
res = GalacticOptim.solve(prob,opt; cb = cb, maxiters=2000)
phi = discretization.phi