- 我正在使用
NDSolve
求解非线性偏微分 方程。 - 我希望其中一个变量 (Kvar) 成为一个函数
当前正在解决的时间步长,因此并使用
分段
。 - Mathematica 生成一条错误消息:
SetDelayed::write: Tag Real in 0.05[t_] is Protected. >> NDSolve::deqn: Equation or list of equations expected instead of $Failed in the first argument ....
ReplaceAll::reps: ....
为了便于阅读,我没有包含完整的错误消息。
我的代码如下:
Needs["VectorAnalysis`"]
Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"];
Clear[Eq4, EvapThickFilm, h, S, G, E1, K1, D1, VR, M, R]
Eq4[h_, {S_, G_, E1_, K1_, D1_, VR_, M_, R_}] := \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]h\) +
Div[-h^3 G Grad[h] +
h^3 S Grad[Laplacian[h]] + (VR E1^2 h^3)/(D1 (h + K1)^3)
Grad[h] + M (h/(1 + h))^2 Grad[h]] + E1/(
h + K1) + (R/6) D[D[(h^2/(1 + h)), x] h^3, x] == 0;
SetCoordinates[Cartesian[x, y, z]];
EvapThickFilm[S_, G_, E1_, K1_, D1_, VR_, M_, R_] :=
Eq4[h[x, y, t], {S, G, E1, K1, D1, VR, M, R}];
TraditionalForm[EvapThickFilm[S, G, E1, K1, D1, VR, M, R]];
我尝试在 NDSolve
中实现 Piecewise
的第二个单元格:
L = 318; TMax = 7.0;
Off[NDSolve::mxsst];
(*Ktemp = Array[0.001+0.001#^2&,13]*)
hSol = h /. NDSolve[{
(*S,G,E,K,D,VR,M*)
Kvar[t_] := Piecewise[{{0.01, t <= 4}, {0.05, t > 4}}],
EvapThickFilm[1, 3, 0.1, Kvar[t], 0.01, 0.1, 0, 160],
h[0, y, t] == h[L, y, t],
h[x, 0, t] == h[x, L, t],
(*h[x,y,0] == 1.1+Cos[x] Sin[2y] *)
h[x, y, 0] ==
1 + (-0.25 Cos[2 \[Pi] x/L] - 0.25 Sin[2 \[Pi] x/L]) Cos[
2 \[Pi] y/L]
},
h,
{x, 0, L},
{y, 0, L},
{t, 0, TMax}
][[1]]
hGrid = InterpolatingFunctionGrid[hSol];
PS:很抱歉,第一个单元格 block 在这里显示得不太好。由于没有足够的“声誉”,我无法发布图片。
使用 NDSolve
单元 block 时出现错误消息。
最佳答案
在 NDSolve
中的一组方程之外定义函数 Kvar
,例如
Off[NDSolve::mxsst];
(*Ktemp=Array[0.001+0.001#^2&,13]*)
Kvar[t_] := Piecewise[{{0.01, t <= 4}, {0.05, t > 4}}];
hSol = ...
并将其从 NDSolve
的列表中删除,以便它以 NDSolve[{(*S,G,E,K,D,VR,M*)EvapThickFilm[. ..
,它会起作用。它会发出警告,但这些警告与方程中可能存在的奇点有关。
此外,您的原始错误表明您的 Kvar
被分配了一个值 0.05
。因此,请在第二个单元格中的任何其他内容之前添加 Clear[Kvar]
。
关于wolfram-mathematica - 如何在 Mathematica 中的 NDSolve 中分段 "embed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7504616/