I have a problem when I try to solve this PDE:

(* Parameters of the problem*)

L = 0.1; (* Background Length scale*)
Lb = 1; (* Boundary distance*)
l = 0.005; (* Perturbation Length scale*)
d = L/3; (* Spatial translation of the perturbation *)
tmax = 0.3; (* Maximal time*)

\[Delta]\[Chi]0[x_] = 
 0.5/(1 + ((x - d)/l)^2) + 
  0.5/(1 + ((x + d)/l)^2); (* Initial perturbation profile*)

(* Construct an initial characteristic with the correct asymptotical \
behaviour *)    

f1[x_] = -3x; (* Desired profile close to x=0 to create the caustic *)
f2[x_] = 1; (* Asymptotical profile *)
v[x_] = Piecewise[{{f1[x], -L < x < L}, {f2[x], 
    x < -Lb || 
     x > Lb}, {InterpolatingPolynomial[{{{-Lb/2}, f2[-Lb/2], 
       f2'[-Lb/2], f2''[-Lb/2], f2'''[-Lb/2], f2''''[-Lb/2]}, {{-L}, 
       f1[-L], f1'[-L]}}, x], -Lb/2 < 
     x < -L}, {InterpolatingPolynomial[{{{Lb/2}, f2[Lb/2], 
       f2'[Lb/2]}, {{L}, f1[L], f1'[L]}}, x], L < x < Lb/2}}];

(* Define the initial condition for the field *)

s[x_] = Sqrt[(2 - 2*(v[x])^2)/(3 - (v[x])^2)];
q = NDSolveValue[{qq'[x] == s[x], qq[-Lb] == 0}, 
  qq, {x, -Lb, Lb}]; (* Integrate the spatial derivative*)
\[Chi]0[x_] = q[x] + \[Delta]\[Chi]0[x];      (* IC for the field *)

(* Solve the PDE *)

pde = (1 + 3/2*(D[\[Chi][x, t], t])^2 - 1/2*(D[\[Chi][x, t], x])^2)*
    D[\[Chi][x, t], t, t] - 
   2*D[\[Chi][x, t], t]*D[\[Chi][x, t], x]*
    D[\[Chi][x, t], x, 
     t] + (-1 + 3/2*(D[\[Chi][x, t], x])^2 - 
      1/2*(D[\[Chi][x, t], t])^2)*D[\[Chi][x, t], x, x] == 0;
ic1 = \[Chi][x, 0] == \[Chi]0[x];
ic2 = (D[\[Chi][x, t], t] /. t -> 0) == 0 - v[x]*\[Delta]\[Chi]0'[x] ;
bc1 = \[Chi][-Lb, t] == 0;
bc2 = D[\[Chi][Lb, t], t] == 0 ;
sol = NDSolve[{pde, ic1, ic2, bc1, bc2}, {\[Chi]}, {x, -Lb, Lb}, {t, 
    0, tmax}];

Please note that anything before the comment (* Solve the PDE *) is uniquely useful to define the parameters used for the definition of the initial condition for the PDE. Indeed, I firstly define a piecewise function v[x] that will be used to compute by integration another function q[x] itself used to define the initial profile \[Chi]0[x_].

I think that, somehow, this initial condition creates the freeze because if I replace the initial condition \[Chi]0[x_] by zero, the PDE is solved by Mathematica without any problem.

Please note that I have tried on many computers and this freeze always occurs. This is strange because I have also tried to reduce the domains on which Mathematica has to solve the PDE but again, without success.

Anybody has any idea on what may cause the problem?

Many thanks.

  • 2
    $\begingroup$ 1. Please reduce the example down to a smaller size by removing all the intermediate definitions and including only the necessary ones. For instance, instead of f1[x] = -k x and f[2] = 1, you could use the values directly in your Piecewise function. 2. With your current code, Mathematica doesn't seem to freeze; it's just working on a complex problem, which may very well take a long time to finish. 3. When setting Chi0[x] = 0, NDSolve returns a results but also a warning. Perhaps you could try to make sure that the simpler case can be solved w/o warnings before moving to the complex case. $\endgroup$
    – MarcoB
    May 14, 2018 at 20:55
  • $\begingroup$ @MarcoB I reduced the example as much as possible but if I do more, I'm afraid that the notation will be redundant. $\endgroup$
    – Targamas
    May 14, 2018 at 21:26

1 Answer 1


You can use Monitor to watch the progress of the solution:

Monitor[sol = 
  NDSolve[{pde, ic1, ic2, bc1, bc2}, {\[Chi]}, {x, -Lb, Lb}, {t, 0, 
    tmax}, EvaluationMonitor :> (monitor = 
      Row[{"t = ", CForm[t]}])], monitor]

But, as pointed out in the comments, there is a message and you should try to address that too.

  • $\begingroup$ Are you talking about this message? NDSolve::mxsst: Using maximum number of grid points 10000 allowed by the MaxPoints or MinStepSize options for independent variable x. If so, any idea how it could be fixed? $\endgroup$
    – Targamas
    May 15, 2018 at 10:51
  • $\begingroup$ @Targamas Try to search this forum for mxsst. $\endgroup$
    – user21
    May 15, 2018 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.