使用版本9时,Mathematica代码不起作用

时间:2014-08-06 19:30:28

标签: wolfram-mathematica

我编写了以下代码,在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

1 个答案:

答案 0 :(得分:2)

总结问题。这适用于版本7和版本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}]