10
$\begingroup$

I would like to solve the following nonlinear PDE:

$$ \frac{\partial^2 \phi}{\partial x^2} - \frac{\partial^2 \phi}{\partial t^2} = \lambda |\phi|^2 \phi $$

I was trying:

NDSolve[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3, f[x, 0] == Sin[2*Pi*x], f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1}]

but, I am consistenly getting NDSolve::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve.

Is there any solver for non-linear PDEs?

$\endgroup$
14
$\begingroup$

The error message is misleading. NDSolve fails, because not enough boundary conditions in t have been supplied. If, for instance, (D[f[x, t], t] /. t -> 0) == 0 is added, then

sol = First@NDSolve[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3, 
    f[x, 0] == Sin[2*Pi*x], (D[f[x, t], t] /. t -> 0) == 0, 
    f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1}];

yields

Plot3D[f[x, t] /. sol, {x, 0, 1}, {t, 0, 1}, AxesLabel -> {x, t, f}, 
 LabelStyle -> Directive[Black, Bold, 12]]

enter image description here

| improve this answer | |
$\endgroup$
4
$\begingroup$

In version 12.0 you can also solve this with the FEM:

NDSolveValue[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3, 
  f[x, 0] == Sin[2*Pi*x], (D[f[x, t], t] /. t -> 0) == 0, 
  f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1}, 
 Method -> {"MethodOfLines", 
   "SpatialDiscretization" -> {"FiniteElement"}}]

Plot the difference between the solutions:

Plot3D[(f[x, t] /. sol) - solFEM[x, t], {x, 0, 1}, {t, 0, 1}]

enter image description here

| improve this answer | |
$\endgroup$

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