achar
achar

Reputation: 41

Mathematica code doesn't work when using version 9

I have written the following code which works ok in Mathematica 8. However, when I open the very same notebook in Mathematica 9, the following message arises: "InterpolatingFunction::dmval: "Input value {0.000408163} lies outside the range of data in the interpolating function. Extrapolation will be used. ", and there is no graph.

Here's the code:

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

Any ideas?

TIA

Upvotes: 1

Views: 377

Answers (1)

Chris Degnen
Chris Degnen

Reputation: 8680

Summarising the problem. This works in version 7 & 8 but fails in version 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}]

Use a more specific method in version 9.

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

Upvotes: 2

Related Questions