Solve a Dirichlet Problem for the Helmholtz Equation
Specify a Helmholtz equation in 2D.
In[1]:=
heqn = {Laplacian[u[x, y], {x, y}] + 5 u[x, y] == 0};
Prescribe Dirichlet conditions for the equation in a rectangle.
In[2]:=
bc = {u[x, 0] == UnitTriangle[x - 2]/2, u[x, 2] == 0, u[0, y] == 0,
u[4, y] == 0};
Solve the Dirichlet problem using DSolveValue.
In[3]:=
(sol = DSolveValue[{heqn, bc}, u[x, y], {x, y}]) // TraditionalForm
Out[3]//TraditionalForm=
Extract the first 30 terms from the Inactive sum.
In[4]:=
fsol = sol /. \[Infinity] -> 30 // Activate;
Visualize the approximate solution.
In[5]:=
Plot3D[fsol // Evaluate, {x, 0, 4}, {y, 0, 2}, PlotRange -> All,
PlotTheme -> "Scientific"]
Out[5]=