When insufficient boundary conditions are given to NDSolve
for solving PDE, usually the warning NDSolve::bcart
pops up:
sol = u /. NDSolve[{D[u[t, x], t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]];
NDSolve::bcart: Warning: An insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution
However, NDSolve
still gives an answer in this case:
Manipulate[Plot[sol[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]
I wonder what boundary has been introduced for this solution?
sol
is changeless no matter how many times you rerun the code, so there exists a certain strategy, which I fail to find in the documentation. The only thing I know is that NDSolve
doesn't use the value of the initial condition at the end point:
sol2 = u /.
NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E,
u[t, 1] == Exp[-1]},
u, {t, 0, 2}, {x, -1, 1}][[1]]
Manipulate[Plot[sol2[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]
or the derivative value of the initial condition at the end point:
sol3 = u /.
NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E,
Derivative[0, 1][u][t, 1] == -2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]]
Manipulate[Plot[sol3[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]
Well, I know the best countermeasure is to add the missing boundary condition, I'm just curious. Anyway, if the output with insufficient boundary condition is completely meaningless, why doesn't NDSolve
simply stop calculating and return the input?
Finally, as mentioned by Bru, the warning bcart
doesn't always pop up, for example:
sol = u /. NDSolve[{D[u[t, x], t, t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
Derivative[1, 0][u][0, x] == 0,
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]];
Update
I've partly found the answer, in short, NDSolve
doesn't intentionally add any boundary condtion in this case, the solution we get is just a outgrowth of one-sided formula. Sadly I still don't know what's the equivalent boundary condition to this outgrowth. I tried to ask it in scicomp.SE, but the result is… not great. Please check the following post for more information:
Why do I still obtain a unique solution with one-sided formula when b.c. isn't enough?
Remark
In the examples above, TensorProductGrid
sub-method has been automatically chosen for spatial discretization, and TensorProductGrid
is the only available method for spatial discretization in and before v9.
Since v10, FiniteElement
method is implemented in NDSolve
. Unlike TensorProductGrid
, the b.c. added by FiniteElement
is documented. As mentioned in the Details of NeumannValue
:
…not specifying a boundary condition at all is equivalent to specifying a Neumann 0 condition.
Notice FiniteElement
method will only be triggered under certain condition. See the following post for more information:
PDEs : automatic method choice : TensorProductGrid or FiniteElement?