http://www.indiana.edu/~statmath/math/matlab/pde/index.html
Using the MATLAB PDE TOOLBOX
The MATLAB PDE Toolbox is a tool for solving two-dimensional linear partial differential equations by finite element methods. This document is intended to guide you through the use of the graphical user interface for interactive use. It assumes that the reader is running MATLAB and the PDE toolbox in a graphical environment.At the MATLAB prompt, type pdetool. You should see a window like the one below pop up.
- Draw the region of interest: suppose we want the rectangle (x,y) = [0, 3] X [0, 1].
- In the Options menu, select Grid and Snap; then set the Axes' Limits to [-1 4] and [-1 2]. When finished, click Apply and Close the Axes' Limits window.
- In the Draw menu, select Rectangle/Square (not centered).
- In the drawing region, click and hold with the cursor at the origin, and drag it to the point with coordinates (3,1). The region will be shaded and marked R1.
- Set up the boundary conditions: suppose we want the unknown
solution function u to be -1 on the long horizontal sides, and +1 on the
short vertical sides.
- In the Boundary menu, select Boundary Mode. The window changes to this:
- In the drawing region, double click on the left edge of the rectangle. The boundary condition window pops up. The default Dirichlet condition h*u=r is OK, the default h=1 is OK; change the value of r to +1.
- Do the same thing with the right edge: double-click, set the value. On the top and bottom edges, set r to -1. Be patient and careful. When the boundary conditions are correctly set, you should be able to click on any edge, and see the correct value for r.
- Specify the particular PDE of interest:
- In the PDE menu, select PDE specification. The pde specification window pops up; we are doing the default type of problem, elliptic, of the form -div(c*grad(u)) + a*u = f, where a=0, f=0, and c=1. Change the values as needed, and click on OK.
- Generate the mesh:
- In the Mesh menu, select Initialize Mesh. This time we will use the default mesh.
- Solve the Finite Element problem:
- In the Solve menu, select Solve PDE. The figure in the main drawing area changes.
- Generate other plots:
- In the Plot menu, select Parameters. The plot parameter window pops up; click on the check boxes for color, contour, and height, then on the Plot button.
The contours are pretty jagged, you may wish to get a better result. Go back to the Mesh menu, and select Refine mesh; Solve again; if you wish, repeat the process. You can click and hold with the left mouse button, and then drag to change the viewing angle.
- Go back to Boundary mode.
- Make the boundary conditions on the short vertical sides be 4*sin(pi*y).^2 .
- Then solve and plot, again. This time we have set the plot parameters to color and contour, but not height:
pdeintro.m
. Then you can quit MATLAB, and at some later time restart it and enter pdeintro at the MATLAB command prompt to return to the current state.The PDE Toolbox can be used from the command prompt without using the GUI interface illustrated above, or in batch mode using m-files. For example, several demonstration files are included with the package; at the MATLAB command prompt, type pdedemo1 [alternatively, pdedemos brings up a menu window].
The code may be examined, in the
$MATLAB/toolbox/pde
directory.The MATLAB PDE Toolbox is a product of Computer Solutions Europe AB.
No hay comentarios:
Publicar un comentario