I want to solve the heat equation in 1-D. When I evaluate the following
NDSolve[
{D[u[t, x], t] == D[u[t, x], {x, 2}],
(D[u[t, x], x] /. x -> 0) == 1,
(D[u[t, x], x] /. x -> Pi) == 1,
u[0, x] == Cos[2 x] + x},
u[t, x], {t, 0, 1}, {x, 0, Pi}][[1]]
I get the error
initial and boundary conditions are inconsistent
but I can't see why. I use version 10.2.0.0
Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 40}}toNDSolvewill resolve your problem. – xzczd Dec 27 '17 at 04:28