Products & Services Solutions Academia Support User Community Company

Learn more about Partial Differential Equation Toolbox   

Using the pdetool GUI

Introduction

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.

The Menus

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:

The Toolbar

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 GUI Modes

The PDE solving process can be divided into several steps:

  1. Define the geometry (2-D domain).

  2. Define the boundary conditions.

  3. Define the PDE.

  4. Create the triangular mesh.

  5. Solve the PDE.

  6. Plot the solution and other physical properties calculated from the solution (post processing).

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:

The CSG Model and the Set Formula

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:

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.

Creating Rounded Corners

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.

Suggested Modeling Method

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.

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:

The following sequence of actions covers all the steps of a normal pdetool session:

  1. 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.

  2. 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.

  3. 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.

      Note   The set formula can only be edited while you are in the draw mode.

    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.

  4. 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.

  5. 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.

  6. 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.

      Note   This step can be performed at any time prior to solving the PDE since it is independent of the CSG model and the boundaries. If the PDE coefficients are material dependent, they are entered in the PDE mode by double-clicking the different subdomains.

  7. 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.

  8. 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.

Object Selection Methods

Throughout the GUI, similar principles apply for selecting objects such as solid objects, subdomains, and boundaries.

Display Additional Information

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.

Entering Parameter Values as MATLAB Expressions

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.

Using Earlier Version Partial Differential Equation Toolbox Model M-Files

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
  


Recommended Products

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