| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Partial Differential Equation Toolbox |
| Contents | Index |
| Learn more about Partial Differential Equation Toolbox |
| On this page… |
|---|
The CSG Model and the Set Formula Display Additional Information Entering Parameter Values as MATLAB Expressions Using Earlier Version Partial Differential Equation Toolbox Model M-Files |
Partial Differential Equation Toolbox software includes a complete graphical user interface (GUI), which covers all aspects of the PDE solution process. You start it by typing
pdetool
at the MATLAB command line. It may take a while the first time you launch pdetool during a MATLAB session. The following figure shows the pdetool GUI as it looks when you start it.

At the top, the GUI has a pull-down menu bar that you use to control the modeling. It conforms to common pull-down menu standards. Menu items followed by a right arrow lead to a submenu. Menu items followed by an ellipsis lead to a dialog box. Stand-alone menu items lead to direct action. Below the menu bar, a toolbar with icon buttons provide quick and easy access to some of the most important functions.
To the right of the toolbar is a pop-up menu that indicates the current application mode. You can also use it to change the application mode. The upper right part of the GUI also provides the x- and y-coordinates of the current cursor position. It is updated when you move the cursor inside the main axes area in the middle of the GUI. The edit box for the set formula contains the active set formula. In the main axes you draw the 2-D geometry, display the mesh, plot the solution, etc. At the bottom of the GUI, an information line provides information about the current activity. It can also display help information about the toolbar buttons.
There are 11 different pull-down menus in the GUI. See Graphical User Interface for a more detailed description of the menus and the dialog boxes:
File menu. From the File menu you can Open and Save model M-files that contain a command sequence that reproduces your modeling session. You can also print the current graphics and exit the GUI.
Edit menu. From the Edit menu you can cut, clear, copy, and paste the solid objects. There is also a Select All option.
Options menu. The Options menu contains options such as toggling the axis grid, a "snap-to-grid" feature, and zoom. You can also adjust the axis limits and the grid spacing, select the application mode, and refresh the GUI.
Draw menu. From the Draw menu you can select the basic solid objects such as circles and polygons. You can then draw objects of the selected type using the mouse. From the Draw menu you can also rotate the solid objects and export the geometry to the MATLAB main workspace.
Boundary menu. From the Boundary menu you access a dialog box where you define the boundary conditions. Additionally, you can label edges and subdomains, remove borders between subdomains, and export the decomposed geometry and the boundary conditions to the workspace.
PDE menu. The PDE menu provides a dialog box for specifying the PDE, and there are menu options for labeling subdomains and exporting PDE coefficients to the workspace.
Mesh menu. From the Mesh menu you create and modify the triangular mesh. You can initialize, refine, and jiggle the mesh, undo previous mesh changes, label nodes and triangles, display the mesh quality, and export the mesh to the workspace.
Solve menu. From the Solve menu you solve the PDE. You can also open a dialog box where you can adjust the solve parameters, and you can export the solution to the workspace.
Plot menu. From the Plot menu you can plot a solution property. A dialog box lets you select which property to plot, which plot style to use and several other plot parameters. If you have recorded a movie (animation) of the solution, you can export it to the workspace.
Window menu. The Window menu lets you select any currently open MATLAB figure window. The selected window is brought to the front.
Help menu. The Help menu provides a brief help window.
The toolbar underneath the main menu at the top of the GUI contains icon buttons that provide quick and easy access to some of the most important functions.
![]()
The five leftmost buttons are draw mode buttons and they represent, from left to right:
| Draw a rectangle/square starting at a corner. |
| Draw a rectangle/square starting at the center. |
| Draw an ellipse/circle starting at the perimeter. |
| Draw an ellipse/circle starting at the center. |
| Draw a polygon. Click-and-drag to create polygon sides. You can close the polygon by clicking the right mouse button. Clicking at the starting vertex also closes the polygon. |
The draw mode buttons can only be activated one at the time and they all work the same way: single-clicking a button allows you to draw one solid object of the selected type. Double-clicking a button makes it "stick," and you can then continue to draw solid objects of the selected type until you single-click the button to "release" it. Using the right mouse button or Ctrl+click, the drawing is constrained to a square or a circle.
The second group of six buttons includes the following analysis buttons.
| Enters the boundary mode. |
| Opens the PDE Specification dialog box. |
| Initializes the triangular mesh. |
| Refines the triangular mesh. |
| Solves the PDE. |
| 3-D solution opens the Plot Selection dialog box. |
The
button toggles the zoom function
on/off.
The PDE solving process can be divided into several steps:
The pdetool GUI is designed in a similar way. You work in six different modes, each corresponding to one of the steps in the PDE solving process:
In draw mode, you can create the 2-D geometry using the constructive solid geometry (CSG) model paradigm. A set of solid objects (rectangle, circle, ellipse, and polygon) is provided. These objects can be combined using set formulas in a flexible way.
In boundary mode, you can specify the boundary conditions. You can have different types of boundary conditions on different boundaries. In this mode, the original shapes of the solid objects constitute borders between subdomains of the model. Such borders can be eliminated in this mode.
In PDE mode, you can interactively specify the type of PDE problem, and the PDE coefficients. You can specify the coefficients for each subdomain independently. This makes it easy to specify, e.g., various material properties in a PDE model.
In mesh mode, you can control the automated mesh generation and plot the mesh.
In solve mode, you can invoke and control the nonlinear and adaptive solver for elliptic problems. For parabolic and hyperbolic PDE problems, you can specify the initial values, and the times for which the output should be generated. For the eigenvalue solver, you can specify the interval in which to search for eigenvalues.
In plot mode, there is a wide range of visualization possibilities. You can visualize both in the pdetool GUI and in a separate figure window. You can visualize three different solution properties at the same time, using color, height, and vector field plots. There are surface, mesh, contour, and arrow (quiver) plots available. For parabolic and hyperbolic equations, you can animate the solution as it changes with time.
Partial Differential Equation Toolbox functions use the Constructive Solid Geometry (CSG) model paradigm for modeling. You can draw solid objects that can overlap. There are four types of solid objects:
Circle object — Represents the set of points inside and on a circle.
Polygon object — Represents the set of points inside and on a polygon given by a set of line segments.
Rectangle object — Represents the set of points inside and on a rectangle.
Ellipse object — Represents the set of points inside and on an ellipse. The ellipse can be rotated.
Each solid object is automatically given a unique name by the GUI. The default names are C1, C2, C3, etc., for circles; P1, P2, P3, etc. for polygons; R1, R2, R3, etc., for rectangles; E1, E2, E3, etc., for ellipses. Squares, although a special case of rectangles, are named SQ1, SQ2, SQ3, etc. The name is displayed on the solid object itself. You can use any unique name, as long as it contains no blanks. In draw mode, you can alter the names and the geometries of the objects by double-clicking them, which opens a dialog box. The following figure shows an object dialog box for a circle.

You can use the name of the object to refer to the corresponding set of points in a set formula. The operators +, *, and - are used to form the set of points Ω in the plane over which the differential equation is solved. The operators +, the set union operator, and *, the set intersection operator, have the same precedence. The operator -, the set difference operator, has higher precedence. The precedence can be controlled by using parentheses. The resulting geometrical model, Ω, is the set of points for which the set formula evaluates to true. By default, it is the union of all solid objects. We often refer to the area Ω as the decomposed geometry.
As an example of how to use the set formula, let us model a plate with rounded corners (fillets).
Start the GUI and turn on the grid and the "snap-to-grid" feature using the Options menu. Also, change the grid spacing to -1.5:0.1:1.5 for the x-axis and -1:0.1:1 for the y-axis.
Select Rectangle/square from the Draw menu or click the button with the rectangle icon. Then draw a rectangle with a width of 2 and a height of 1 using the mouse, starting at (-1,0.5). To get the round corners, add circles, one in each corner. The circles should have a radius of 0.2 and centers at a distance that is 0.2 units from the left/right and lower/upper rectangle boundaries ((-0.8,-0.3), (-0.8,0.3), (0.8,-0.3), and (0.8,0.3)). To draw several circles, double-click the button for drawing ellipses/circles (centered). Then draw the circles using the right mouse button or Ctrl+click starting at the circle centers. Finally, at each of the rectangle corners, draw four small squares with a side of 0.1.
The following figure shows the complete drawing.

Now you have to edit the set formula. To get the rounded corners, subtract the small squares from the rectangle and then add the circles. As a set formula, this is expressed as
R1-(SQ1+SQ2+SQ3+SQ4)+C1+C2+C3+C4
Enter the set formula into the edit box at the top of the GUI.
Then enter the Boundary mode by clicking the
button or by selecting the Boundary
Mode option from the Boundary menu.
The CSG model is now decomposed using the set formula, and you get
a rectangle with rounded corners, as shown in the following figure.

Because of the intersection of the solid objects used in the initial CSG model, a number of subdomain borders remain. They are drawn using gray lines. If this is a model of, e.g., a homogeneous plate, you can remove them. Select the Remove All Subdomain Borders option from the Boundary menu. The subdomain borders are removed and the model of the plate is now complete.
Although Partial Differential Equation Toolbox software offers you a great deal of flexibility in the ways that you can approach the problems and interact with the toolbox functions, there is a suggested method of choice for modeling and solving your PDE problems using the pdetool GUI. There are also a number of shortcuts that you can use in certain situations.
Note There are platform-dependent keyboard accelerators available for many of the most common pdetool GUI activities. Learning to use the accelerator keys may improve the efficiency of your pdetool sessions. |
The basic flow of actions is indicated by the way the graphical buttons and the menus are ordered from left to right. You work your way from left to right in the process of modeling, defining, and solving your PDE problem using the pdetool GUI:
When you start, pdetool is in draw mode, where you can use the four basic solid objects to draw your Constructive Solid Geometry (CSG) model. You can also edit the set formula. The solid objects are selected using the five leftmost buttons (or from the Draw menu).
To the right of the draw mode buttons you find buttons through which you can access all the functions that you need to define and solve the PDE problem: define boundary conditions, design the triangular mesh, solve the PDE, and plot the solution.
The following sequence of actions covers all the steps of a normal pdetool session:
Use pdetool as a drawing tool to make a drawing of the 2-D geometry on which you want to solve your PDE. Make use of the four basic solid objects and the grid and the "snap-to-grid" feature. The GUI starts in the draw mode, and you can select the type of object that you want to use by clicking the corresponding button or by using the Draw menu. Combine the solid objects and the set algebra to build the desired CSG model.
Save the geometry to a model file. The model file is an M-file, so if you want to continue working using the same geometry at your next Partial Differential Equation Toolbox session, simply type the name of the model file at the MATLAB prompt. The pdetool GUI then starts with the model file's solid geometry loaded. If you save the PDE problem at a later stage of the solution process, the model file also contains commands to recreate the boundary conditions, the PDE coefficients, and the mesh.
Move to the next step in the PDE solving
process by clicking the
button.
The outer boundaries of the decomposed geometry are displayed with
the default boundary condition indicated. If the outer boundaries
do not match the geometry of your problem, reenter the draw mode.
You can then correct your CSG model by adding, removing or altering
any of the solid objects, or change the set formula used to evaluate
the CSG model.
If the drawing process resulted in any unwanted subdomain borders, remove them by using the Remove Subdomain Border or Remove All Subdomain Borders option from the Boundary menu.
You can now define your problem's boundary conditions by selecting the boundary to change and open a dialog box by double-clicking the boundary or by using the Specify Boundary Conditions option from the Boundary menu.
Initialize the triangular mesh. Click the Δ button or use the corresponding Mesh menu option Initialize Mesh. Normally, the mesh algorithm's default parameters generate a good mesh. If necessary, they can be accessed using the Parameters menu item.
If you need a finer mesh, the mesh can be refined by clicking the Refine button. Clicking the button several times causes a successive refinement of the mesh. The cost of a very fine mesh is a significant increase in the number of points where the PDE is solved and, consequently, a significant increase in the time required to compute the solution. Do not refine unless it is required to achieve the desired accuracy. For each refinement, the number of triangles increases by a factor of four. A better way to increase the accuracy of the solution to elliptic PDE problems is to use the adaptive solver, which refines the mesh in the areas where the estimated error of the solution is largest. See the adaptmesh reference page for an example of how the adaptive solver can solve a Laplace equation with an accuracy that requires more than 10 times as many triangles when regular refinement is used.
Specify the PDE from the PDE Specification dialog box. You can access that dialog box using the PDE button or the PDE Specification menu item from the PDE menu.
Solve the PDE by clicking the = button or by selecting Solve PDE from the Solve menu. If you do not want an automatic plot of the solution, or if you want to change the way the solution is presented, you can do that from the Plot Selection dialog box prior to solving the PDE. You open the Plot Selection dialog box by clicking the button with the 3-D solution plot icon or by selecting the Parameters menu item from the Plot menu.
Now, from here you can choose one of several alternatives:
Export the solution and/or the mesh to the MATLAB main workspace for further analysis.
Visualize other properties of the solution.
Change the PDE and recompute the solution.
Change the mesh and recompute the solution. If you select Initialize Mesh, the mesh is initialized; if you select Refine Mesh, the current mesh is refined. From the Mesh menu, you can also jiggle the mesh and undo previous mesh changes.
Change the boundary conditions. To return to the mode
where you can select boundaries, use the
button or the Boundary Mode option
from the Boundary menu.
Change the CSG model. You can reenter the draw mode by selecting Draw Mode from the Draw menu or by clicking one of the Draw Mode icons to add another solid object. Back in the draw mode, you are able to add, change, or delete solid objects and also to alter the set formula.
In addition to the recommended path of actions, there are a number of shortcuts, which allow you to skip over one or more steps. In general, the pdetool GUI adds the necessary steps automatically.
If you have not yet defined a CSG model, and leave the draw mode with an empty model, pdetool creates an L-shaped geometry with the default boundary condition and then proceeds to the action called for, performing all the steps necessary.
If you are in draw mode and click the Δ button to initialize the mesh, pdetool first decomposes the geometry using the current set formula and assigns the default boundary condition to the outer boundaries. After that, an initial mesh is created.
If you click the refine button to refine the mesh before the mesh has been initialized, pdetool first initializes the mesh (and decomposes the geometry, if you were still in the draw mode).
If you click the = button to solve the PDE and you have not yet created a mesh, pdetool initializes a mesh before solving the PDE.
If you select a plot type and choose to plot the solution, pdetool checks to see if there is a solution to the current PDE available. If not, pdetool first solves the current PDE. The solution is then displayed using the selected plot options.
If you have not defined your PDE, pdetool solves the default PDE, which is Poisson's equation:
![]()
(This corresponds to the generic elliptic PDE with c = 1, a = 0, and f = 10.) For the different application modes, different default PDE settings apply.
Throughout the GUI, similar principles apply for selecting objects such as solid objects, subdomains, and boundaries.
To select a single object, click it using the left mouse button.
To select several objects and to deselect objects, Shift+click (or click using the middle mouse button) on the desired objects.
Clicking in the intersection of several objects selects all the intersecting objects.
To open an associated dialog box, double-click an object. If the object is not selected, it is selected before opening the dialog box.
In draw mode and PDE mode, clicking outside of objects deselects all objects.
To select all objects, use the Select All option from the Edit menu.
When defining boundary conditions and the PDE via the menu items from the Boundary and PDE menus, and no boundaries or subdomains are selected, the entered values applies to all boundaries and subdomains by default.
In mesh mode, you can use the mouse to display the node number and the triangle number at the position where you click. Press the left mouse button to display the node number on the information line. Press the middle mouse button (or use the left mouse button and the Shift key) to display the triangle number on the information line.
In plot mode, you can use the mouse to display the numerical value of the plotted property at the position where you click. Press the left mouse button to display the triangle number and the value of the plotted property on the information line.
The information remains on the information line until you release the mouse button.
When entering parameter values, e.g., as a function of x and y, the entered string must be a MATLAB expression to be evaluated for x and y defined on the current mesh, i.e., x and y are MATLAB row vectors. For example, the function 4 x y should be entered as 4*x.*y and not as 4*x*y, which normally is not a valid MATLAB expression.
You can convert Model M-files created using an earlier version of Partial Differential Equation Toolbox software for use with the current versions of MATLAB and Partial Differential Equation Toolbox software. The old Model M-files cannot be used directly in the current version of Partial Differential Equation Toolbox software.
To convert your old Model M-files, use the conversion utility pdemdlcv. For example, to convert a Model M-file called model42.m to a compatible Model M-file called model5.m, type the following at the MATLAB command line:
pdemdlcv model42 model5
![]() | Basics of the Finite Element Method | Using Command-Line Functions | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |