Page 451 - Applied Numerical Methods Using MATLAB
P. 451
440 PARTIAL DIFFERENTIAL EQUATIONS
According to your selection, you will see a movie-like dynamic picture or
the (final) solution graph like Fig. 9.14d, which is the steady-state solution
for Eq. (E9.8.1) with ∂u(x,y,t)/∂t = 0, virtually the same as the elliptic PDE
(E9.7.1) whose solution is depicted in Fig. 9.13d.
Before closing this example, let us have an experience of exporting the values
of some parameters. For example, we extract the mesh data {p, e, t} by clicking
‘Export Mesh’ in the Mesh pull-down menu and then clicking the OK button
in the Export dialog box. Among the mesh data, the matrix p contains the x
and y coordinates in the first and second rows, respectively. We also extract
the solution u by clicking ‘Export Solution’ in the Solve pull-down menu and
then clicking the OK button in the Export dialog box. Now, we can estimate
how far the graphical/numerical solution deviates from the true steady-state solu-
x
y
tion u(x, y) = e cos x − e cos y by typing the following statements into the
MATLAB command window.
>>x = p(1.:)’; y = p(2.: )’; %x.y coordinates of nodes in column vector
>>err = exp(y).*cos(x) - exp(x).*cos(y) - u(:.end); %deviation from true sol
>>err_max = max(abs(err)) %maximum absolute error
Note that the dimension of the solution matrix u is 177 × 51 and the solution
at the final stage is stored in its last column u(:,end), where 177 is the number
of nodes in the triangular mesh and 51 = 5000/100 + 1 is the number of frames
or time stages.
Example 9.9. A Hyperbolic PDE: Two-Dimensional Wave (Vibration) Over a
Square Membrane. Consider a two-dimensional hyperbolic PDE
2
2
2
1 ∂ u(x, y, t) ∂ u(x, y, t) ∂u (x, y, t)
+ =
4 ∂x 2 ∂y 2 ∂t 2
for 0 ≤ x ≤ 2, 0 ≤ y ≤ 2, and 0 ≤ t ≤ 2 (E9.9.1)
with the zero boundary conditions and the initial conditions
u(0,y,t) = 0, u(2,y,t) = 0, u(x, 0,t) = 0, u(x, 2,t) = 0 (E9.9.2)
u(x, y, 0) = 0.1sin(πx) sin(πy/2), ∂u/∂t(x, y, 0) = 0for t = 0 (E9.9.3)
The procedure for using the PDEtool to solve this problem is as follows:
0–2. Do the same things as steps 0–2 for the case of elliptic PDE in Example 9.7,
except for the following.
ž Set the ranges of the x axis-and the y-axis to [0 3] and [0 3].
ž Set the Left/Bottom/Width/Height to 0/0/2/2 in the Object dialog box
opened by double-clicking the rectangle.
ž Set the boundary condition to zero as specified by Eqs. (E9.9.2) in
the boundary condition dialog box opened by clicking the ∂ button
in the tool-bar, shift-clicking the four boundary segments and double-
clicking one of the boundary segments.

