Documentation |
This example shows how to enter coefficients in the PDE app.
Caution: Do not include spaces in your coefficient strings in the PDE app. The string parser can misinterpret a space as a vector separator, as when a MATLAB vector uses a space to separate elements of a vector.
The PDE is parabolic,
$$d\frac{\partial u}{\partial t}-\nabla \cdot \left(c\nabla u\right)+au=f,$$
with the following coefficients:
d = 5
a = 0
f is a linear ramp up to 10, holds at 10, then ramps back down to 0:
$$f=10*\{\begin{array}{ll}10t\hfill & 0\le t\le 0.1\hfill \\ 1\hfill & 0.1\le t\le 0.9\hfill \\ 10-10t\hfill & 0.9\le t\le 1\hfill \end{array}$$
c = 1 +.x^{2} + y^{2}
These coefficients are the same as in Scalar PDE Functional Form and Calling Syntax.
Write the following file framp.m and save it on your MATLAB^{®} path.
function f = framp(t) if t <= 0.1 f = 10*t; elseif t <= 0.9 f = 1; else f = 10-10*t; end f = 10*f;
Open the PDE app, either by typing pdetool at the command line, or selecting PDE from the Apps menu.
Select PDE > PDE Specification.
Select Parabolic equation. Fill in the coefficients as pictured:
c = 1+x.^2+y.^2
a = 0
f = framp(t)
d = 5
The PDE app interprets all inputs as strings. Therefore, do not include quotes for the c or f coefficients.
Select Options > Grid and Options > Snap.
Select Draw > Draw Mode, then draw a rectangle centered at (0,0) extending to 1 in the x-direction and 0.4 in the y-direction.
Draw a circle centered at (0.5,0) with radius 0.2
Change the set formula to R1-C1.
Select Boundary > Boundary Mode
Click a segment of the outer rectangle, then Shift-click the other three segments so that all four segments of the rectangle are selected.
Double-click one of the selected segments.
Fill in the resulting dialog box as pictured, with Dirichlet boundary conditions h = 1 and r = t*(x-y). Click OK.
Select the four segments of the inner circle using Shift-click, and double-click one of the segments.
Select Neumann boundary conditions, and set g = x.^2+y.^2 and q = 1. Click OK.
Click to initialize the mesh.
Click to refine the mesh. Click again to get an even finer mesh.
Select Mesh > Jiggle Mesh to improve the quality of the mesh.
Set the time interval and initial condition by selecting Solve > Parameters and setting Time = linspace(0,1,50) and u(t0) = 0. Click OK.
Solve and plot the equation by clicking the button.
Match the following figure using Plot > Parameters.
Click the Plot button.