0
$\begingroup$

I'm trying to plot u as a function of t by NDSolving a set ODE's

The problem is like:

Parameters:

time = 100;m = 2;rE = 1000;rE2 = 100;sr = 5;d = 5;a = 0.001;k = 2;Ta = 15000;n = 0.2;\[Tau] = 1/(\[Pi]^2 + k^2);

The system of the differential equations:

soln = NDSolve[{Derivative[1][u][t] == 
 k^2 \[Tau] Ta v[t] + u[t]/(n - 1) + 
  16/(3 \[Pi]) Ta k^2 \[Tau] v[t] s[t], 
Derivative[1][v][t] == \[Pi] u[t] w[t] + u[t] - v[t]/(n \[Tau]), 
Derivative[1][w][
  t] == -((3 m^2 n rE)/( (2 - 3 n + n^2) \[Pi] rE2)) + \[Pi]/
   2 u[t] v[t] + (4 \[Pi]^2)/n w[t], 
Derivative[1][s][t] == -((4 k n )/(rE2 (1 - n) \[Pi])) f[t] + (
  4 m n rE (m Sqrt[2 - n] + (-2 + n) Tanh[m/Sqrt[2 - n]]))/((2 - 
     n)^(3/2) (-1 + n) rE2 \[Pi]) - \[Pi]^2/n  s[t]  , 
Derivative[1][f][t] == (
  n (4 + a (d (k^2 + \[Pi]^2) + \[Pi]^2 sr)) f[t])/( 
  a (-1 + n) ) +  rE/ 2 g[t] + ( 16*rE)/( 6 \[Pi]) g[t] s[t], 
Derivative[1][g][t] == (n (4 + a d (k^2 + \[Pi]^2)) g[t])/(
  a (-1 + n) ) +  rE/ 2 g[t] + ( 16*rE)/( 6 \[Pi]) g[t] s[t], 
Derivative[1][h][t] == 
 1/2 ((2 n (4 + a (d (k^2 + \[Pi]^2) + k^2 sr)) h[t])/(
    a (-1 + n)) - (
    m (2 + m Sqrt[2 - n] - n + 
       E^((2 m)/Sqrt[2 - n]) (-2 + m Sqrt[2 - n] + n)) rE u[
      t])/((1 + E^((2 m)/Sqrt[2 - n])) (2 - n)^(3/2))), 
u[0] == 0.0001`, v[0] == 0.0001`, w[0] == 0.0001`, 
s[0] == 0.0001`, f[0] == 0.0001`, g[0] == 0.0001`, 
h[0] == 0.0001`}, {u, v, w, s, f, g, h}, {t, 0, time}, 
 MaxSteps -> \[Infinity]];

Plotting:

q1 = Plot[ u[t] /. soln, {t, 0, time}, 
PlotLabel -> Style[  "(a)       U", 20], Frame -> True, 
LabelStyle -> 12, PlotRange -> All]

But I get some kind of error, and I don't know what its mean.

Error

ReplaceAll::reps: {soln} is neither a list of replacement rules nor a  valid dispatch table, and so cannot be used for replacing.

I will appreciate your help and comments

$\endgroup$
  • $\begingroup$ running your code hanged my PC. Mathematica 11.1.1 kept eating more and more RAM and the PC hanged. I was lucky to catch it in time and be able to kill the kernel. Warning to others before running the code. Which version of M did you run the above on and how long did it take to finish? I have 16GB ram. $\endgroup$ – Nasser Aug 22 '17 at 21:15
  • $\begingroup$ If you look at help,. you see the examples show the command as Plot[Evaluate[u[t]/.soln],......]. You are missing the Evaluate part? I can't try it, since your code hangs on my PC. $\endgroup$ – Nasser Aug 22 '17 at 21:21
  • $\begingroup$ In V 10.1 Removing the MaxSteps -> \[Infinity] takes a while and complains about NDSolve::mxst: Maximum number of 22073017 steps reached at the point t == 0.18082486559386235 but finally finishes and changing your plot interval to {t, 0, .180} and don't use an 'Evaluate' shows me the plot. I'm guessing that your kernel died and there is no value in soln which you might try to verify. Try evaluating 'soln` after the error and see if it displays nothing but soln. If so that would explain the error but not why your kernel died. $\endgroup$ – Bill Aug 22 '17 at 21:22
  • 2
    $\begingroup$ In V 10.1, replacing all decimals with exact fractions, using Simplify on your system before giving it to NDSolve, removing MaxSteps->\[Infinity] and adding 'WorkingPrecision->32 makes NDSolve bail after 7 seconds because it reaches 10000 steps at t==.080. Graphing each your functions without Evaluate or PlotRange shows several of your functions appear to be blowing up. $\endgroup$ – Bill Aug 22 '17 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.