V 12.1.1 on windows 10
Why the following works
ClearAll[u, x, y];
pde = Laplacian[u[x, y], {x, y}];
bc = {u[0, y] == 1, u[1, y] == 0};
sol = NDSolve[{pde == NeumannValue[0, y == 0] + NeumannValue[0, y == 1], bc},
u, {x, 0, 1}, {y, 0, 1}]
Plot3D[Evaluate[u[x, y] /. sol], {x, 0, 1}, {y, 0, 1}, AxesLabel -> {"x", "y", "u"}]
ps. I know NeumannValue[0, y == 0]
above are not needed in this example, since by default they are zero. So the above could also be written as
sol = NDSolve[{pde == 0, bc}, u, {x, 0, 1}, {y, 0, 1}]
But here is the problem.
Now I just changed NeumannValue[0, y == 0]
to use standard Derivative
instead, and NDSolve
gives now an error
ClearAll[u, x, y];
pde = Laplacian[u[x, y], {x, y}] == 0;
bc = {u[0, y] == 1, u[1, y] == 0, Derivative[0, 1][u][x, 0] == 0,
Derivative[0, 1][u][x, 1] == 0};
sol = NDSolve[{pde, bc}, u, {x, 0, 1}, {y, 0, 1}]
But bc is not nonlinear. I have not even changed it. So why does the error says it is?
To show these boundary conditions are valid, changed NDSolve
to DSolve
and it gave same solution as the first one above using NeumannValue
ClearAll[u,x,y];
pde = Laplacian[u[x,y],{x,y}]==0;
bc = {u[0,y]==1,u[1,y]==0,Derivative[0,1][u][x,0]==0,Derivative[0,1][u][x,1]==0};
sol = DSolve[{pde,bc},u[x,y],{x,y}];
sol = Simplify[Activate[sol]]
Plot3D[u[x,y]/.sol,{x,0,1},{y,0,1}]
Plot3D[u[x, y] /. sol, {x, 0, 1}, {y, 0, 1}]
Can't one use Derivative
now with NDSolve
and have to use NeumannValue
? And why it says dependent variable in the boundary condition is not linear when it is?
ps. I tested this on 12 and 11.3 and they give same error. I do not have earlier versions of Mathematica to test on.
FiniteElement
is used for spatial discretization, one cannot express Neumann and Robin b.c. withDerivative
, and have to useNeumannValue
, at least now. You might remember the discussion here: mathematica.stackexchange.com/questions/172972/… $\endgroup$ – xzczd Jun 27 '20 at 11:28When "FiniteElement" is chosen
. So what what is the bottom line here? One can not useDerivative
at all as BC. withNDSolve
Since when this started? May be if you know, you can make an answer giving the rules of thumb to follow, as I am now confused :) $\endgroup$ – Nasser Jun 27 '20 at 11:39