0
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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[1] -> n

Mathematica graphics

To plot it

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

Mathematica graphics

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}]

Mathematica graphics

| improve this answer | |
$\endgroup$
1
$\begingroup$

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[]]

enter image description here

There are two DirichletCondition objects that define u at bottom and top arcs of the boundary (the circle defining used Disk)

| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.