【问题标题】:Mathematica code doesn't work when using version 9使用版本 9 时 Mathematica 代码不起作用
【发布时间】:2014-08-06 19:30:28
【问题描述】:

我编写了以下代码,在 Mathematica 8 中运行良好。但是,当我在 Mathematica 9 中打开同一个笔记本时,出现以下消息:“InterpolatingFunction::dmval:”输入值 {0.000408163} 超出范围插值函数中的数据。将使用外推法。 ",并且没有图表。

代码如下:

Manipulate[
 ParametricPlot[
  Evaluate[{x1[t], a YP[[2]]/YP[[1]] x1[t] + (1 - a) YP[[2]] x3[t]} /.
    Quiet@NDSolve[
      {x1'[t] == x2[t],
       x2'[t] == -1/
         Mass (c x2[t] + 
           a YP[[2]]/YP[[1]] x1[t] + (1 - a) YP[[2]] x3[t] - 
           Fmax Sin[(2 π)/T t]),
       x3'[t] == 
        x2[t]/YP[[
          1]] (1 - Abs[x3[t]]^n (γ Sign[x2[t] x3[t]] + (1 - γ))),
       x1[0] == 0,
       x2[0] == 0,
       x3[0] == 0},
      {x1[t], x2[t], x3[t]},
      {t, 0, tTotal}]],
  {t, 0, tTotal},
  ImageSize -> {450, 450}, PlotRange -> 10, AxesLabel -> {"u", "F"}],
 {{tTotal, 20, "Total time"}, 0.5, 100, Appearance -> "Labeled"},
 {{Mass, 2.86, "m"}, 0.1, 10, 0.01, Appearance -> "Labeled"},
 {{T, 4.0, "T"}, 0.1, 10, 0.01, Appearance -> "Labeled"},
 {{Fmax, 8.0, "Fmax"}, 0.1, 10, 0.01, Appearance -> "Labeled"},
 {{n, 2.0, "n"}, 0.1, 10, 0.01, Appearance -> "Labeled"},
 {{c, 0.0, "c"}, 0.0, 10, 0.01, Appearance -> "Labeled"},
 {{a, 0.05, "a"}, 0.0, 1, 0.01, Appearance -> "Labeled"},
 {{γ, 0.5, "γ"}, 0.01, 1, 0.01, Appearance -> "Labeled"},
 {{YP, {0.111, 2.86}}, {0, 0}, {10, 10}, Locator}]

有什么想法吗?

TIA

【问题讨论】:

  • 回复。有任何想法吗?是的,隔离导致问题的代码。
  • NDSolve 在 Mathematica 8 中没有错误继续进行,而在 Mathematica 9 中失败并显示消息 NDSolve::smpf: Failure to project to the discontinuity surface when computing Filippov continuation at time 0.`.

标签: wolfram-mathematica


【解决方案1】:

总结问题。这适用于版本 7 和 8,但在版本 9 中失败:-

tTotal = 20; Mass = 2.86; T = 4.0;
Fmax = 8.0; n = 2.0; c = 0.0; a = 0.05;
\[Gamma] = 0.5; YP = {0.111, 2.86};

NDSolve[{x1'[t] == x2[t],
  x2'[t] == -1/Mass (c x2[t] + a YP[[2]]/YP[[1]] x1[t] +
      (1 - a) 2.86 x3[t] - Fmax Sin[(2 \[Pi])/4.0 t]),
  x3'[t] == x2[t]/0.111 (1 -
      Abs[x3[t]]^2.0 (\[Gamma] Sign[x2[t] x3[t]] + (1 - \[Gamma]))),
  x1[0] == 0, x2[0] == 0, x3[0] == 0},
 {x1[t], x2[t], x3[t]}, {t, 0, 20}]

在版本 9 中使用更具体的方法。

NDSolve[... , Method -> {"DiscontinuityProcessing" -> False}]

【讨论】:

  • 请注意,DiscontinuityProcessing 在 M7 或 M8 中是未知的,所以我需要有两个版本的文件。
  • 您可以考虑使用的版本,因此只需要一个文件,例如NDSolve[... , Method -> If[ $VersionNumber > 8, {"DiscontinuityProcessing" -> False}, Automatic]]
猜你喜欢
  • 1970-01-01
  • 2023-02-13
  • 2020-05-29
  • 1970-01-01
  • 1970-01-01
  • 2017-07-25
  • 1970-01-01
  • 1970-01-01
  • 2022-01-15
相关资源
最近更新 更多