0
$\begingroup$

The code is not running. However instead of i^2 in the second term if I use i then it is working. But with i^2 fails.

    Xmax = 500; Tmax = 1; eqn = 
 Table[Subscript[u, i]'[
    t] == (2*(Subscript[u, i + 1][t] - 2 Subscript[u, i][t] + 
         Subscript[u, i - 1][t]) + (i i - 
         Sum[i i Subscript[u, i][t], {i, -Xmax, Xmax}]) Subscript[u, 
         i][t])/Sum[Subscript[u, i][t], {i, -Xmax, Xmax}], {i, 
   1 - Xmax, Xmax - 1}]

bcs = {Subscript[u, -Xmax][t] == 0, Subscript[u, Xmax][t] == 0}; iv = 
 Table[If[(i >= -10) && (i <= 10), Subscript[u, i][0] == 1/21, 
   Subscript[u, i][0] == 0], {i, -Xmax, Xmax}]; s = 
 NDSolveValue[{eqn, iv, bcs}, 
  Table[Subscript[u, i][t], {i, -Xmax + 1, Xmax - 1}], {t, 0, 
   Tmax}]; {Plot[s, {t, 0, Tmax}, AxesLabel -> {"t", u}], 
 ListLinePlot[Table[s, {t, 0, Tmax}], AxesLabel -> {x, u}, 
  PlotRange -> All]}
$\endgroup$
  • $\begingroup$ This works, for example, for Xmax = 15 $\endgroup$ – Alex Trounev Jul 26 '18 at 12:03
  • 1
    $\begingroup$ What do you mean by "not running"? Does it return an error, or is it just not returning an answer promptly? If you're trying to solve a system of 999 coupled non-linear ODEs, you shouldn't expect an instantaneous result. $\endgroup$ – Michael Seifert Jul 26 '18 at 13:46
  • $\begingroup$ No I understand but it is showing error namely "At t == 0.019485983068404454`, step size is effectively zero; singularity or stiff system suspected". $\endgroup$ – Sachin Kaushik Jul 26 '18 at 16:58
  • $\begingroup$ and i cant set Xmax small because then it will give junk answer. $\endgroup$ – Sachin Kaushik Jul 26 '18 at 17:17

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.