在 Mathematica 中求解非线性 PDE
Nonlinear PDE solving in Mathematica
我正在尝试使用 NDsolve.I 求解以下与 ginzburg landau 相关的非线性耦合 PDE 方程,我是 Mathematica 的新手。我得到以下信息 error.What 是我做错了吗?
pde = {D[u[t, x, y], t] ==
D[u[t, x, y], {x, x}] +
D[u[t, x, y], {y,
y}] - (1/u[t, x, y])^3*(D[v[t, x, y], y]^2 +
D[v[t, x, y], x]^2) - u[t, x, y] + u[t, x, y]^3,
D[v[t, x, y], t] ==
D[v[t, x, y], {x, x}] + D[v[t, x, y], {y, y}] -
v[t, x, y]*u[t, x, y] +
(2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] -
D[u[t, x, y], y]*D[v[t, x, y], y])};bc = {u[0, x, y] == 0, v[0, x, y]== 0, u[t, 5, y] == 1, u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0};
NDSolve[{pde, bc}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
'Error: NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{(u^(1,0,0))[t,x,y]==-u[t,x,y]+u[t,x,y]^3+(u^(0,0,y))[t,x,y]-((<<1>>^(<<3>>))[<<3>>]^2+(<<1>>^(<<3>>))[<<3>>]^2)/u[t,x,y]^3+(u^(0,x,0))[t,x,y],(v^(1,0,0))[t,x,y]==-u[t,x,y] v[t,x,y]+(v^(0,0,y))[t,x,y]+(2 (-(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]+(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]))/u[t,x,y]+(v^(0,x,0))[t,x,y]},{u[0,x,y]==0,v[0,x,y]==0,u[t,5,y]==1,u[t,x,5]==1,True,True}}.
NDSolve[{{Derivative[1, 0, 0][u][t, x, y] == -u[t, x, y] +
u[t, x, y]^3 + Derivative[0, 0, y][u][t, x, y] -
(Derivative[0, 0, 1][v][t, x, y]^2 +
Derivative[0, 1, 0][v][t, x, y]^2)/u[t, x, y]^3 +
Derivative[0, x, 0][u][t, x, y],
Derivative[1, 0, 0][v][t, x, y] == (-u[t, x, y])*v[t, x, y] +
Derivative[0, 0, y][v][t, x, y] +
(2*((-Derivative[0, 0, 1][u][t, x, y])*
Derivative[0, 0, 1][v][t, x, y] +
Derivative[0, 1, 0][u][t, x, y]*
Derivative[0, 1, 0][v][t, x, y]))/u[t, x, y] +
Derivative[0, x, 0][v][t, x, y]}, {u[0, x, y] == 0,
v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True,
True}}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
如果您查看 bc
的值,您会看到
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1,
u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0}
给你
{u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True, True}
这就是您关于 True
的错误消息的来源。
你所做的是关于 x 对表达式求微分,但表达式中没有 x,因此结果为零。而 0==0 总是 True。同样与 y。因此,让我们改变您尝试告诉它边界条件的方式。
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
Derivative[0, 1, 0][v][t, 0, y] == 0, Derivative[0, 0, 1][v][t, x, 0] == 0}
或
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
D[v[t, x, y], x] == 0/.x->0, D[v[t, x, y], y] == 0/.y->0}
我认为两者都应该能满足您的需求。
一旦你解决了这些问题,你就会得到一个关于微分顺序和非负整数的不同错误。
我相信您可以通过将 pde
从 {x,x}
和 {y,y}
更改为 {x,2}
和 {y,2}
来解决这个问题
pde = {D[u[t, x, y], t] == D[u[t, x, y], {x, 2}] + D[u[t, x, y], {y, 2}] -
(1/u[t, x, y])^3*(D[v[t, x, y], y]^2 + D[v[t, x, y], x]^2) - u[t, x, y] +
u[t, x, y]^3,
D[v[t, x, y], t] == D[v[t, x, y], {x, 2}] + D[v[t, x, y], {y, 2}] - v[t, x, y]*
u[t, x, y] + (2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] - D[u[t, x, y], y]*
D[v[t, x, y], y])};
这样错误就消失了。
一旦你解决了这个问题并尝试你的 NDSolve
然后你的分母中的零开始咬你。
修复这些看起来不仅仅是理解 MMA 语法。这可能需要了解您的问题并查看是否可以消除那些零分母。
我正在尝试使用 NDsolve.I 求解以下与 ginzburg landau 相关的非线性耦合 PDE 方程,我是 Mathematica 的新手。我得到以下信息 error.What 是我做错了吗?
pde = {D[u[t, x, y], t] ==
D[u[t, x, y], {x, x}] +
D[u[t, x, y], {y,
y}] - (1/u[t, x, y])^3*(D[v[t, x, y], y]^2 +
D[v[t, x, y], x]^2) - u[t, x, y] + u[t, x, y]^3,
D[v[t, x, y], t] ==
D[v[t, x, y], {x, x}] + D[v[t, x, y], {y, y}] -
v[t, x, y]*u[t, x, y] +
(2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] -
D[u[t, x, y], y]*D[v[t, x, y], y])};bc = {u[0, x, y] == 0, v[0, x, y]== 0, u[t, 5, y] == 1, u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0};
NDSolve[{pde, bc}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
'Error: NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{(u^(1,0,0))[t,x,y]==-u[t,x,y]+u[t,x,y]^3+(u^(0,0,y))[t,x,y]-((<<1>>^(<<3>>))[<<3>>]^2+(<<1>>^(<<3>>))[<<3>>]^2)/u[t,x,y]^3+(u^(0,x,0))[t,x,y],(v^(1,0,0))[t,x,y]==-u[t,x,y] v[t,x,y]+(v^(0,0,y))[t,x,y]+(2 (-(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]+(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]))/u[t,x,y]+(v^(0,x,0))[t,x,y]},{u[0,x,y]==0,v[0,x,y]==0,u[t,5,y]==1,u[t,x,5]==1,True,True}}.
NDSolve[{{Derivative[1, 0, 0][u][t, x, y] == -u[t, x, y] +
u[t, x, y]^3 + Derivative[0, 0, y][u][t, x, y] -
(Derivative[0, 0, 1][v][t, x, y]^2 +
Derivative[0, 1, 0][v][t, x, y]^2)/u[t, x, y]^3 +
Derivative[0, x, 0][u][t, x, y],
Derivative[1, 0, 0][v][t, x, y] == (-u[t, x, y])*v[t, x, y] +
Derivative[0, 0, y][v][t, x, y] +
(2*((-Derivative[0, 0, 1][u][t, x, y])*
Derivative[0, 0, 1][v][t, x, y] +
Derivative[0, 1, 0][u][t, x, y]*
Derivative[0, 1, 0][v][t, x, y]))/u[t, x, y] +
Derivative[0, x, 0][v][t, x, y]}, {u[0, x, y] == 0,
v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True,
True}}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
如果您查看 bc
的值,您会看到
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1,
u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0}
给你
{u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True, True}
这就是您关于 True
的错误消息的来源。
你所做的是关于 x 对表达式求微分,但表达式中没有 x,因此结果为零。而 0==0 总是 True。同样与 y。因此,让我们改变您尝试告诉它边界条件的方式。
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
Derivative[0, 1, 0][v][t, 0, y] == 0, Derivative[0, 0, 1][v][t, x, 0] == 0}
或
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
D[v[t, x, y], x] == 0/.x->0, D[v[t, x, y], y] == 0/.y->0}
我认为两者都应该能满足您的需求。
一旦你解决了这些问题,你就会得到一个关于微分顺序和非负整数的不同错误。
我相信您可以通过将 pde
从 {x,x}
和 {y,y}
更改为 {x,2}
和 {y,2}
来解决这个问题
pde = {D[u[t, x, y], t] == D[u[t, x, y], {x, 2}] + D[u[t, x, y], {y, 2}] -
(1/u[t, x, y])^3*(D[v[t, x, y], y]^2 + D[v[t, x, y], x]^2) - u[t, x, y] +
u[t, x, y]^3,
D[v[t, x, y], t] == D[v[t, x, y], {x, 2}] + D[v[t, x, y], {y, 2}] - v[t, x, y]*
u[t, x, y] + (2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] - D[u[t, x, y], y]*
D[v[t, x, y], y])};
这样错误就消失了。
一旦你解决了这个问题并尝试你的 NDSolve
然后你的分母中的零开始咬你。
修复这些看起来不仅仅是理解 MMA 语法。这可能需要了解您的问题并查看是否可以消除那些零分母。