Solve a Dirichlet Problem for the Laplace Equation
Specify the Laplace equation in 2D.
In[1]:=
leqn = Laplacian[u[x, y], {x, y}] == 0;Prescribe a Dirichlet condition for the equation in a rectangle.
In[2]:=
\[CapitalOmega] = Rectangle[{0, 0}, {1, 2}];In[3]:=

dcond = DirichletCondition[
u[x, y] ==
Piecewise[{{UnitTriangle[2 x - 1], y == 0 || y == 2}}, 0], True];Solve the Dirichlet problem.
In[4]:=
sol = DSolveValue[{leqn, dcond},
u[x, y], {x, y} \[Element] \[CapitalOmega]] // FullSimplifyOut[4]=
Extract the first 300 terms from the Inactive sum.
In[5]:=
asol = sol /. {\[Infinity] -> 300} // Activate;Visualize the solution on the rectangle.
In[6]:=
Plot3D[asol // Evaluate, {x, y} \[Element] \[CapitalOmega],
PlotRange -> All, PlotTheme -> "Business"]Out[6]=
