Question 10.1: DIRICHLET PROBLEM The Dirichlet problem in Figure 10.2 descr...
DIRICHLET PROBLEM
The Dirichlet problem in Figure 10.2 describes the steady-state temperature distribution inside a rectangular plate of length 2 and width 1 . Three of the sides are kept at zero temperature, while the lower edge has a temperature profile of \sin (\pi x / 2). Using a mesh size of h=0.5 construct a grid and find the approximate values of u at the interior mesh points, and calculate the relative errors associated with these approximate values. The exact solution in closed form is given by
u(x, y)=\frac{1}{\sinh (\pi / 2)} \sin \frac{\pi x}{2} \sinh \frac{\pi(1-y)}{2}

Learn more on how do we answer questions.
There are three interior mesh points and eight boundary points on the grid. Therefore, the difference equation, Equation 10.3,
u_{i-1, j}+u_{i+1, j}+u_{i, j-1}+u_{i, j+1}-4 u_{i j}=0 (10.3)
must be applied three times, once at each interior mesh point. As a result, we have
\begin{array}{ll} (i=1, j=1) & u_{01}+u_{10}+u_{21}+u_{12}-4 u_{11}=0 \\ (i=2, j=1) & u_{11}+u_{20}+u_{31}+u_{22}-4 u_{21}=0 \\ (i=3, j=1) & u_{21}+u_{30}+u_{41}+u_{32}-4 u_{31}=0 \end{array}
Included in these equations are the values at the boundary points,
u_{12}=u_{22}=u_{32}=u_{01}=u_{41}=0, \quad u_{10}=0.7071=u_{30}, \quad u_{20}=1
Inserting these into the system of equations, we find
\begin{aligned} -4 u_{11}+u_{21} & =-0.7071 \\ u_{11}-4 u_{21}+u_{31} & =-1 \\ u_{21}-4 u_{31} & =-0.7071 \end{aligned} \quad \stackrel{\text { In matrix form }}{\Rightarrow} \quad\left[\begin{array}{ccc} -4 & 1 & 0 \\ 1 & -4 & 1 \\ 0 & 1 & -4 \end{array}\right]\left\{\begin{array}{l} u_{11} \\ u_{21} \\ u_{31} \end{array}\right\}=\left\{\begin{array}{c} -0.7071 \\ -1 \\ -0.7071 \end{array}\right\}
Solution of this system yields u_{11}=0.2735=u_{31} and u_{21}=0.3867. The exact values at these points are calculated as u_{11}=0.2669=u_{31} and u_{21}=0.3775, recording relative errors of 2.47 \% and 2.44 \%, respectively. The estimates turned out reasonably accurate considering the large mesh size that was used. Switching to a smaller mesh size of h=0.25, for example, generates a grid that includes 21 interior mesh points and 20 boundary points. The ensuing linear system then comprises 21 equations and 21 unknowns, whose solutions are more accurate than those obtained here.
To confirm the numerical results in MATLAB, we execute the user-defined function DirichletPDE.
>> x = 0:0.5:2; y = 0:0.5:1;
>> f = @(x,y)(0); ubottom = @(x)(sin(pi*x/2)); utop = @(x)(0);
>> uleft = @(y)(0); uright = @(y)(0);
>> U = DirichletPDE(x,y,f,uleft,uright,ubottom,utop) % 3D plot suppressed
U =
0 0 0 0 0
0 0.2735 0.3867 0.2735 0
0 0.7071 1.0000 0.7071 0
The three values in the box are the solution estimates at the three interior mesh points, and agree with those obtained earlier. All other values correspond to the boundary points in the grid used. In order to generate a smooth plot, we reduce the mesh size to h=0.1 and reexecute the function. The result is shown in Figure 10.3.
>> x = 0:0.1:2; y = 0:0.1:1;
>> U = DirichletPDE(x,y,f,uleft,uright,ubottom,utop) % Numerical results suppressed
