# How to specify the Dirichlet boundary condition in mathematica DSolveValue [closed]

I want to specify the following Dirichlet condition for obtaining an analytic solution for the Laplace equation in mathemaitca: $$u(x, 0) = 0, u(x, 1) = 10, u(0, y) = 0, u(1, y) = 10$$ How to write it?

• Did you look on DirichletCondition? – Rom38 May 18 at 6:14
• yes, but I don't understand how to input these conditions. I have tried it but it doesn't work, something's wrong with the format! – devanshu shekhar May 18 at 9:39
• – Nasser May 18 at 13:54

One way could be

bc = {u[x, 0] == 0, u[x, 1] == 10, u[0, y] == 0, u[1, y] == 10};
pde = Laplacian[u[x, y], {x, y}] == 0
sol = DSolveValue[{pde, bc}, u[x, y], {x, y}];
sol /. K -> n To plot it

sol0 = Activate[sol /. Infinity -> 40]; (*more terms->more accurate*)
Plot3D[Evaluate[sol0], {x, 0, 1}, {y, 0, 1}] Numerically

bc = {u[x, 0] == 0, u[x, 1] == 10, u[0, y] == 0, u[1, y] == 10};
pde = Laplacian[u[x, y], {x, y}] == 0
sol = NDSolveValue[{pde, bc}, u, {x, 0, 1}, {y, 0, 1}];
Plot3D[sol[x, y], {x, 0, 1}, {y, 0, 1}] Looking onto the example from the MMA help system:

s=NDSolveValue[{D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == 0,
DirichletCondition[u[x, y] == 0, x <= -0.3],
DirichletCondition[u[x, y] == 1, x >= 0.35]}, u, {x, y} \[Element]
Disk[{0, 0}, 1]]

Plot3D[s[x, y], {x, y} \[Element] Disk[]] There are two DirichletCondition objects that define u at bottom and top arcs of the boundary (the circle defining used Disk)