By the advise of Jagra, I removed the first set of the code and leave the actual problem. I got a working script, but the plot is empty. I tried to run it in chrome and firefox, but to no difference.
What is the reason when plots are "empty" and no error is given?
(* Define parameters *)
L = 10; (* Length of the domain *)
T = 15; (* Total time *)
dx = 0.08; (* Spatial step size *)
dt = 0.001; (* Time step size *)
xValues = Range[-L/2, L/2, dx]; (* Spatial grid *)
mMax = Round[T/dt]; (* Maximum time index *)
(* Ma-soliton initial condition *)
A = 1; (* Amplitude *)
c = 0.5; (* Velocity *)
k = 1; (* Wave number *)
\[Psi]0[x_, t_] := A Sech[x - c t] Exp[I (k x - (c^2 + k^2) t)];
(* Initialize wave function *)
\[Psi] = Table[\[Psi]0[x, 0], {x, xValues}];
(* Time evolution function *)
timeEvolution[\[Psi]_, m_] := Module[{\[Psi]New, nonlinearTerm},
\[Psi]New = \[Psi]; (* Start with the current wave function *)
(* Update wave function using FDM *)
For[i = 2, i < Length[\[Psi]] - 1, i++,
nonlinearTerm = Abs[\[Psi][[i]]]^2 \[Psi][[i]];
\[Psi]New[[i]] = \[Psi][[i]] - (dt/(2 I)) ((\[Psi][[i + 1]] - 2 \[Psi][[i]] + \[Psi][[i - 1]])/(dx^2)) - dt nonlinearTerm;
];
\[Psi]New
];
(* Store results for animation *)
results = {};
(* Time-stepping loop *)
For[m = 1, m <= mMax, m++,
\[Psi] = timeEvolution[\[Psi], m];
If[Mod[m, Round[mMax/5]] == 0, AppendTo[results, \[Psi]]]; (* Store every 5th wave function *)
];
(* Create the animation *)
ListAnimate[Table[
ListLinePlot[results[[m]], PlotRange -> All,
PlotLabel -> "Ma-Soliton Evolution",
AxesLabel -> {"x", "\[Psi](x,t)"},
PlotStyle -> {Thick, Blue},
ImageSize -> Large,
PlotLegends -> {"t = " <> ToString[m dt]}],
{m, 1, Length[results]}
]]



For[]loops with a more functional construct. $\endgroup$HyperbolicSech[]$\endgroup$