# Solving a 2D convection and diffusion PDE with DSolve

Hello I have the following PDE, $$Pe\left(\frac{\partial z}{\partial x}+\frac{\partial z}{\partial y}\right)=\frac{\partial^2 z}{\partial x^2}+\frac{\partial^2 z}{\partial y^2}$$ and I am trying to solve it in Mathematica. In my case $Pe=2$.

Here is a snippet of the notepad I am using.

pde = 2 D[z[x, y], x] + 2 D[z[x, y], y] ==  D[D[z[x, y], x], x] + D[D[z[x, y], y], y]
bc1 = z[0, y] == 0
bc2 = z[1, y] == 1
bc3 = D[z[x, y], y] == 0 /. y -> 0
bc4 = D[z[x, y], y] == 0 /. y -> 1
DSolve[{pde, bc1, bc2, bc3, bc4}, z[x, y], {x, y}]


Mathematica is not giving me a solution so I must be messing something up. I'm only interested in getting a symbolic solution to the PDE if possible. Thanks in advance.

• You are not messing anything up - DSolve does not know the solution. Feb 8, 2017 at 7:54

When all else fails, try FEM

pde = 2 D[z[x, y], x] +2 D[z[x, y], y] -D[D[z[x, y], x], x]+D[D[z[x, y], y], y];
bc1 = DirichletCondition[z[x, y] == 0, x == 0];
bc2 = DirichletCondition[z[x, y] == 1, x == 1];
bc3 = NeumannValue[0, y == 0];
bc4 = NeumannValue[0, y == 1];
sol = NDSolveValue[{pde == bc3 + bc4, bc1, bc2}, z, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement",
"MeshOptions" -> {"BoundaryMeshGenerator" -> "Continuation"}}];

Plot3D[sol[x, y], {x, 0, 1}, {y, 0, 1}, Mesh -> All,
AxesLabel -> {"x", "y", "z[x,y]"}, BaseStyle -> 14, ImageSize -> 400]


• Thanks! Under Method, is it possible to use other options besides FEM? And is there any way to get an expression from Mathematica? Feb 8, 2017 at 11:18
• @NWernerC456, no FEM is the only option for stationary (elliptic) PDEs. The interpolating function is an expression; though I suspect you are looking for an analytical solution, which NDSolve does not give. As a side note, the NeumannValues are not necessary. Neumann zero is the default. Feb 8, 2017 at 13:27
• @user21, Ok well if I can't use anything but FEM that should be fine but can I still get the data points at each node in a NxN mesh to plot in MATLAB? I'm trying to compare my numerical results to this analytic result. Feb 8, 2017 at 14:18
• @NWernerC456, NDSolve does not generate a analytic result. Just evaluate the interpolating function at the nodes. Feb 8, 2017 at 15:02
• @user21, OK but how do I get the interpolating function? Feb 8, 2017 at 15:11