【问题标题】:Memory exhaustion while running NDSolve运行 NDSolve 时内存耗尽
【发布时间】:2011-11-25 09:32:23
【问题描述】:

我在 Mathematica 中遇到“没有更多可用内存”错误消息。我知道“Parallelize []”(显然)不会帮助我。 “ClearSystemCache[]”也没有。

什么给了?我只需要更多内存吗?

我的代码

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]];

L = 318; TMax = 10;
Off[NDSolve::mxsst];
Clear[Kvar];
Kvar[t_] :=  Piecewise[{{1, t <= 1}, {2, t > 1}}]
(*Ktemp = Array[0.001+0.001#^2&,13]*)
hSol = h /. NDSolve[{
     (*S,G,E,K,D,VR,M*)

     EvapThickFilm[1, 3, 0.1, 7, 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},
    MaxStepSize -> 0.1
    ][[1]]

hGrid = InterpolatingFunctionGrid[hSol];

错误信息

No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.

我的操作系统规格

Intel Core 2 Duo,4.00 GB 内存,64 位操作系统 (Windows 7)

【问题讨论】:

  • 这可能并不重要,但如果您收到此消息,首先要做的就是设置 $HistoryLength=0。大型程序的许多错误消息都是由此引起的。其次,隔离导致内存问题的实际代码行。如果可能,以一种可以监控内存使用情况的方式运行它。
  • @Searke 这是一个非常有用的建议。如果我可能会问,我应该如何隔离导致问题的代码部分?我是 Mathematica 的新手,我对函数一无所知。
  • @DNA 查看相关answer on memory usage control
  • 相关问题:“Profiling memory usage in Mathematica”。
  • 你已经发布了这个 pde 3 次,这是我遇到过的最糟糕的微分方程。您是否尝试过任何简化?例如,使用您提供的系数,您最终会得到 Div[h^3 Grad[G h + S Laplacian[h]]] 加上 4 个其他项。其中两个项乘以 0.1,乍一看有点小而且可以忽略不计。我会先尝试以这种方式解决它,可能会利用周期性边界条件。

标签: windows memory wolfram-mathematica


【解决方案1】:

您可以在这里体验一下正在发生的事情:

替换

MaxStepSize -> 0.1

通过

MaxStepFraction -> 1/30

然后运行你的代码。

然后:

p = Join[#,Reverse@#]&@ 
     Table[Plot3D[hSol[x, y, i], {x, 0, L}, {y, 0, L},
                  PlotRange -> {All, All, {0, 4}}], 
     {i, 7, 8, .1}]

Export["c:\\plot.gif", p]  

因此,Mma 试图在这些峰值处优化解决方案,但无济于事。

【讨论】:

    猜你喜欢
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-23
    • 2012-11-10
    • 2012-08-19
    • 2011-02-09
    • 2015-10-01
    相关资源
    最近更新 更多