【问题标题】:Mathematica: Solving a PDE that contains Conjugate of a function or Abs of a functionMathematica:求解包含函数共轭或函数 Abs 的 PDE
【发布时间】:2012-12-27 04:43:42
【问题描述】:

我正在尝试使用 NDSolve 对 PDE 进行数值求解。我不断收到以下错误:

"NDSolve::ndnum: "Encountered non-numerical value for a derivative at t == 0.."

似乎我只是因为Abs[D[f[x,y,t],x]]Conjugate[D[f[x,y,t],x]] 的存在而收到此错误。我创建了一个非常简单的函数来演示这个问题。

这将起作用:

noAbs = D[f[x, t], t] == f[x, t] f[x, t] D[f[x, t], x, x]
xrange = \[Pi]; trange = 5;
forSolve = {noAbs, f[x, 0] == Exp[I x], f[-xrange, t] == f[xrange, t]}
frul = NDSolve[forSolve, f, {x, -xrange, xrange}, {t, 0, trange}, 
   MaxStepSize -> 0.007, Method -> "MethodOfLines" ];

这行不通(请注意,唯一的区别是我们没有 Abs)。

withAbs = D[f[x, t], t] == f[x, t] f[x, t] Abs[D[f[x, t], x, x]];
forSolve = {withAbs, f[x, 0] == Exp[I x], 
  f[-xrange, t] == f[xrange, t]}
frul = NDSolve[forSolve, {f}, {x, -xrange, xrange}, {t, 0, trange}, 
   MaxStepSize -> 0.007, Method -> "MethodOfLines" ];
Plot3D[Re[f[x, t]] /. frul, {x, -xrange, xrange}, {t, 0, trange}]

现在我猜 Mathematica 试图对我的表达式求导,发现它不知道如何导出 Abs 函数。我的假设是否正确,如何解决这个问题?

【问题讨论】:

    标签: wolfram-mathematica pde nonlinear-functions


    【解决方案1】:

    耐心一点,并根据函数的实部和虚部编写所有内容。 设置f=fRe + I fIm

    equation =  ComplexExpand[
     (Derivative[0, 1][fRe][x, t] + I Derivative[0, 1][fIm][x, t]) == 
     (fRe[x, t] + I fIm[x, t])^2  Abs[Derivative[2, 0][fRe][x, t] + I Derivative[2, 0][fIm][x, t]], 
       TargetFunctions -> {Re, Im}] ;
    

    初始条件:

    Plot[Evaluate@solAbs[x, 0], {x, -xrange, xrange}]
    

    边界条件:

    Plot[Evaluate@(solAbs[-xrange, t] - solAbs[xrange, t]), {t, 0, trange}, PlotRange -> All]
    

    【讨论】:

    • 非常感谢您的回复。如果没有明确区分实部和虚部,您知道为什么 Mathematica 会失败吗?而且,以防其他人稍后读到:由于我的真实表达式显然比这长得多,因此“手动”更改等式以包含明确的实部和虚部并不是那么有吸引力。对任何复杂函数 f 执行这种“显式复杂化”的通用方法是:f -> Function[{x,t} fre[x,t] + I fim[x,t]]
    • 另外,为了收集实数和虚数等式,我要添加:ComplexExpand [Thread[Im[equation], Equal]] ComplexExpand [Thread[Re[equation], Equal]]'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    相关资源
    最近更新 更多