3
$\begingroup$
usol = NDSolveValue[{4 Derivative[2, 0][u][x, t] == 
         Derivative[0, 2][u][x, t], u[x, 0] == Cos[x/2], u[0, t] == Cos[t], 
       2 Derivative[1, 0][u][6 Pi, t] == -Derivative[0, 1][u][6 Pi, t], 
       Derivative[0, 1][u][x, 0] == Sin[x/2]}, u, {x, 0, 6 Pi}, {t, 0, 40}]

Animate[Plot[{usol[x, t], Cos[x/2 - t]}, {x, 0, 6 Pi}, 
     PlotRange -> {-1.2, 1.2}], {t, 0, 40}]

NDSolveValue spits out a ibcinc warning and the numerical solution droops towards the end. What should I do to make these results more accurate? Adding

Method -> {"MethodOfLines", 
                   "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 20}} 

does not solve the problem

$\endgroup$
1
  • $\begingroup$ Just a side note: the key point is to use a dense enough spatial grid. For OP's specific problem, one can add e.g. Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> 50, "MinPoints" -> 50, "DifferenceOrder" -> 4}} to NDSolveValue to resolve the issue. $\endgroup$
    – xzczd
    Nov 29, 2016 at 12:39

0