Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

 

Product Support

1511 - Technical Support Guide to Using the Partial Differential Equation Toolbox


Introduction

  1. What Is the Purpose of This Technical Support Guide?
  2. What Does the Partial Differential Equation Toolbox Do?
  3. What Problems Can I Solve?
  4. What Types of Boundary Conditions Can I Have?

Using the Graphical User Interface

  1. How do I Define a PDE Problem?
  2. How do I Solve a PDE Problem?
  3. Tutorial on Using the Graphical User Interface
  4. Examples Using the Graphical User Interface

Using Command-Line Functions

  1. Functions for the Draw Mode
  2. Functions for the Boundary Mode
  3. Functions for the Mesh Mode
  4. Functions for the Solve Mode
  5. Functions for the Plot Mode
  6. Examples Using Command-Line Functions

FAQs

  1. Common Solutions Relating to Partial Differential Equation Toolbox
  2. What Should I Do if None of the Troubleshooting Suggestions Resolve My Problem?
  3. Are There any Applications Already Implemented?

Introduction

Section 1: What Is the Purpose of This Technical Support Guide? 

This technical note provides you with information about the Partial Differential Equation Toolbox. The tech note will discuss what the toolbox can do,  and what type of problems it can solve. It will also demonstrate how to use the toolbox to solve PDE problems. There are also a few examples.

Section 2: What Does the Partial Differential Equation Toolbox Do?

The Partial Differential Equation Toolbox provides a powerful and flexible environment for the study and the evaluation of the solution of partial differential equations in two space dimensions and time. The equations are discretized by the Finite Element Method (FEM). The objectives of the Partial Differential Equation Toolbox are to provide you with tools that:

  • Define a PDE problem, e.g., define 2-D regions, boundary conditions, and PDE coefficients
  • Numerically solve the PDE problem, e.g., generate unstructured meshes, discretize the equations, and produce an approximation to the solution
  • Visualize the results

Section 3: What Problems Can I Solve?

The basic equation of the Partial Differential Equation Toolbox is the PDE 

- · (c u) + au = f on Ω

which we refer to as the elliptic equation, regardless of whether its coefficients and boundary conditions make the PDE problem elliptic in the mathematical sense. Ω is a bounded domain in the plane. c, a, f, and the unknown u are scalar, complex valued functions defined on Ω . The coefficient c can be a 2-by-2 matrix function on Ω .

The toolbox can also handle the parabolic PDE:

· (c u) + au = f on Ω

the hyperbolic PDE:

- · (c u) + au = f on Ω

and the eigenvalue problem:

- · (c u) + au =>l·d·u on Ω

where d is a complex valued function on Ω , and λ is an unknown eigenvalue.

For the parabolic and hyperbolic PDE, the coefficients c, a, f, and d can depend on time.

A nonlinear solver is available for the nonlinear elliptic PDE:

- · (c(u) u) + a(u)u = f(u) on Ω

where c, a, and f are functions of the unknown solution u.

All solvers can handle the system case:

- · (c11 u1)
- · (c12 u2)+ a11u1 + a12u2 = f1
- · (c21 u1)- · (c22 u2)+ a21u1 + a22u1 = f2

Note that you can work with systems of arbitrary dimension from the command line. Use an an adaptive mesh refinement algorithm for the elliptic problem . You can also use it in conjunction with the nonlinear solver. In addition, a fast solver for Poisson’s equation on a rectangular grid is available.

For more detailed information on the PDE equations, refer to Chapter 4, "The Finite Element Method," of the Partial Differential Equation Toolbox documentation. 

Section 4: What Types of Boundary Conditions Can I Have?

The following boundary conditions are defined for scalar u:

  • Dirichlet:
    hu = r on the boundary δΩ

  • Generalized Neumann:
    · (c u) + qu = g on δΩ

is the outward unit normal. The coefficients g, q, h, and r are complex valued functions defined on δΩ . (The eigenvalue problem is a homogeneous problem, i.e., g = 0, r = 0.) In the nonlinear case, the coefficients g, q, h, and r can depend on u, and for the hyperbolic and parabolic PDE, the coefficients can depend on time. For the two-dimensional system case, the Dirichlet boundary conditions are

h11 u1+ h12u2  = r1
h21 u1+ h22u2  = r2

the generalized Neumann boundary conditions are

· (c11 u1) + · (c12 u2) + q11u1 + q12u2= g1
· (c21 u1) + · (c22 u2) + q21u1 + q22u2= g2

and the mixed boundary conditions are

h11 u1+ h12u2  = r1
· (c11 u1) + · (c12 u2) + q11u1 + q12u2= g1 + h11μ
· (c21 u1) + · (c22 u2) + q21u1 + q22u2= g2+ h11 μ

where μ is computed such that the Dirichlet boundary condition is satisfied. Dirichlet boundary conditions are also called essential boundary conditions, and Neumann boundary conditions are also called natural boundary conditions.

For more detailed information on the boundary conditions, refer to Chapter 4, "The Finite Element Method," of the Partial Differential Equation Toolbox documentation. 


Using the Graphical User Interface (PDETOOL)

Section 5: How do I Define a PDE Problem?

The simplest way to define a PDE problem is to use the graphical user interface (GUI), implemented in PDETOOL. There are three modes in the PDETOOL that correspond to different stages of defining a PDE problem:

  • In Draw mode, you create the geometry W using the constructive solid geometry (CSG) model paradigm. A set of solid objects (rectangle, circle, ellipse, and polygon) is provided. You can combine these objects using set formulas.
  • In Boundary mode, you specify the boundary conditions. You can have different types of boundary conditions on different boundary segments.
  • In PDE mode, youspecify the type of PDE and the coefficients c, a, f, and d interactively . You can specify the coefficients for each subdomain independently. This may ease the specification of, e.g., various material properties in a PDE model.

Section 6: How do I Solve a PDE Problem?

You can solve most problems using the graphical user interface. There are three modes that help you solve a problem:

  • In Mesh mode, you generate and plot meshes. You can control the parameters of the automated mesh generator.
  • In Solve mode, you can invoke and control the nonlinear and adaptive solvers for elliptic problems. For parabolic and hyperbolic problems, you can specify the initial values, and the times for which the output is 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. After solving a problem, you can return to the Mesh mode to further refine your mesh and then solve again. You can also employ the adaptive mesh refiner and solver. This option tries to find a mesh that fits the solution.

Section 7: Tutorial on Using the Graphical User Interface

Refer to the section entitled "Solving a PDE" in the Partial Differential Equation Toolbox documentation. The tutorial demonstrates how to use the following modes: Draw, Boundary, PDE, Mesh, Solve, and Plot.  

Section 8: Examples Using the Graphical User Interface

Refer to Chapter 2, "Common PDF Problems", of the Partial Differential Equation Toolbox  documentation. The examples demonstrate how to use the Partial Differential Equation Toolbox to solve Elliptic, Parabolic, Hyperbolic, Eigenvalue, and Application Mode problems. 


Using Command-Line Functions

Section 9: Functions for the Draw Mode

PDECIRC Draw circle
PDEELLIP
Draw ellipse
PDEGEOM
Create a Geometry M-file
PDEPOLY
Draw polygon
PDERECT
Draw rectangle

Section 10: Functions for the Boundary Mode

PDEBOUND
Create a Boundary M-file

Section 11: Functions for the Mesh Mode

INITMESH
Create initial triangular mesh
JIGGLEMESH
Jiggle internal points of a triangular mesh
REFINEMESH
Refine a triangular mesh

Section 12: Functions  for the Solve Mode

ADAPTMESH
Performs Adaptive mesh generation and PDE solution
ASSEMPDE
Assemble the stiffness matrix and right-hand side of a PDE problem
HYPERBOLIC
Solve hyperbolic PDE problem
PARABOLIC
Solve parabolic PDE problem
PDEEIG
Solve eigenvalue PDE problem
PDENONLIN
Solve nonlinear PDE problem

Section 13: Functions for the Plot Mode

PDEGPLOT Plot a PDE geometry
PDEMESH
Plot a PDE triangular mesh
PDEPLOT
Generic Partial Differential Equation Toolbox plot function
PDESURF
Shorthand command for surface plot

Section 14: Examples Using Command-Line Functions -
Solve Poisson's Equation and Compare with Exact Solution

- · ( u)  =1 on the unit disk with u=0 on the boundary

  1. Draw mode

    Create a geometry M-file. The function PDEGEOM shows the syntax of a geometry M-file.
    function [x,y]=circleg(bs,s) 
    %CIRCLEG   Gives geometry data for the circleg PDE model 
    % 
    %   NE=CIRCLEG gives the number of boundary segment 
    % 
    %   D=CIRCLEG(BS) gives a matrix with one column for  
    %   each boundary segment specified in BS. 
    %   Row 1 contains the start parameter value. 
    %   Row 2 contains the end parameter value. 
    %   Row 3 contains the number of the left hand region. 
    %   Row 4 contains the number of the right hand region. 
    % 
    %   [X,Y]=CIRCLEG(BS,S) gives coordinates of boundary points. 
    %   BS specifies the boundary segments and S the corresponding 
    %   parameter values. BS may be a scalar.
    
    %There are only 4 boundary segments. ( Four 90 degree arcs):
     nbs=4;
    
    %Returns the number of boundary segments:
    if nargin==0, 
      x=nbs; % number of boundary segments 
      return 
    end
    
    %There are only 4 columns because there are only 4 boundary segments:
    d=[0 0 0 0; % Start parameter value 
       1 1 1 1; % End parameter value 
       1 1 1 1; % Left hand region 
       0 0 0 0 % Right hand region 
       ];
    
    bs1=bs(:)'; 
    
    if find(bs1<1 | bs1>nbs), 
      error('Nonexistent boundary segment number') 
    end
    
    %Returns a matrix with one column for 
    %each boundary segment specified in BS:
    if nargin==1,
      x=d(:,bs1); 
      return 
    end
    
    x=zeros(size(s)); 
    y=zeros(size(s)); 
    [m,n]=size(bs); 
    if m==1 & n==1, 
      bs=bs*ones(size(s)); % expand bs 
    elseif m~=size(s,1) | n~=size(s,2), 
      error('bs must be scalar or of same size as s'); 
    end  
    
    if ~isempty(s), 
    %--------------------------------------------------
    % The next four boundary segmants calculate 
    % the x and y coordinates of each boundary segement:
    
    % boundary segment 1 
    ii=find(bs==1); 
    x(ii)=1*cos((pi/2)*s(ii)-pi); 
    y(ii)=1*sin((pi/2)*s(ii)-pi);
    
    % boundary segment 2 
    ii=find(bs==2); 
    x(ii)=1*cos((pi/2)*s(ii)-(pi/2)); 
    y(ii)=1*sin((pi/2)*s(ii)-(pi/2));
    
    % boundary segment 3 
    ii=find(bs==3); 
    x(ii)=1*cos((pi/2)*s(ii)); 
    y(ii)=1*sin((pi/2)*s(ii));
    
    % boundary segment 4 
    ii=find(bs==4); 
    x(ii)=1*cos((pi/2)*s(ii)-(3*pi/2)); 
    y(ii)=1*sin((pi/2)*s(ii)-(3*pi/2));
    %--------------------------------------------------
    end
  2. Boundary mode

    Create the boundary file. The function PDEBOUND shows the syntax of a boundary M-file.
    function [q,g,h,r]=circleb1(p,e,u,time)
    %CIRCLEB1  Boundary condition data 
    
    % In the matrix below, each column represents the 
    % boundary conditions on the 4 boundary segments 
    % u = 0 ( Dirichlet condition):
    bl=[1 1 1 1; 
    1 1 1 1; 
    1 1 1 1; 
    1 1 1 1; 
    1 1 1 1; 
    1 1 1 1; 
    48 48 48 48; 
    48 48 48 48; 
    49 49 49 49; 
    48 48 48 48 
    ];
    
    % The input arguments "u" and "time" below are used for the
    %  nonlinear solver and time stepping algorithms, respectively:
    if any(size(u)) 
      [q,g,h,r]=pdeexpd(p,e,u,time,bl); 
      
    else 
      % The function PDEEXPD evaluates on edges and returns 
      % the boundary conditions coefficients q , g, h and r:
      [q,g,h,r]=pdeexpd(p,e,time,bl); 
    end 
    
    % Note: In this example, h is a vector of ones, 
    % and r is a vector of zeros. 
    % Also note that q and g are zeros vector because 
    % there are no Neumann conditions.
  3. Mesh mode

    To generate the mesh on which to solve the PDE, create a script file with the following code:
    %The following code defines the problem:
    g='circleg'; % The unit circle 
    b='circleb1'; % 0 on the boundary 
    c=1; 
    a=0; 
    f=1; 
    
    %Generate a coarse initial mesh:
    [p,e,t]=initmesh(g,'hmax',1);
    
    %Refine the mesh 3 times:
    [p,e,t]=refinemesh(g,p,e,t); 
    [p,e,t]=refinemesh(g,p,e,t); 
    [p,e,t]=refinemesh(g,p,e,t);
    
  4. Solve mode
    %Solve the elliptic PDE problem on the mesh described 
    %by "p", "e", and "t", with boundary conditions given 
    %by the function name "b":
    u=assempde(b,p,e,t,c,a,f);
    
    %Calculate the exact solution, "(1 - x^2 - y^2 ) / 4", for comparsion:
    exact=(1-p(1,:).^2-p(2,:).^2)'/4;
    
    er=norm(u-exact,'inf'); 
    fprintf('Error: %e. Number of nodes: %d\n',er,size(p,2));
  5. Plot mode

    % The geometry 
    subplot(2,2,1) 
    pdegplot(g) 
    title('Geometry W') 
     
    %The mesh 
    subplot(2,2,2) 
    pdemesh(p,e,t) 
    title('mesh use to solve') 
     
    subplot(2,2,3) 
    pdemesh(p,e,t,u) 
    zlabel('u') 
     
    %The solution 
    subplot(2,2,4) 
    pdesurf(p,t,u); 
    zlabel('u')

    The above code produces the following figure:

    % Now calculate the absolute error
    pdesurf(p,t,u-exact); 
    title('Calculated u minus the exact solution.')

    The above code produces the following figure:


Section 15: Common Solutions Relating to Partial Differential Equation Toolbox

See the the Partial Differential Equation Toolbox Support-by-Product page for more infromation.


Section 16: What Should I Do if None of the Troubleshooting Suggestions Resolve My Problem?

If you continue to experience problems with Partial Differential Equation Toolbox, contact Technical Support with the following information:

  • The output of typing VER at the MATLAB command prompt
  • A detailed description of the problem
  • A small example (5 - 10 lines of code)
  • Step-by-step instructions so that we can try to reproduce the problem
  • The exact error message(s), if any

Section 17: Are There any Applications Already Implemented?

the Partial Differential Equation Toolbox is easy to use in the most common areas due to the application interfaces. Seven additional application interfaces are available, in addition to the generic scalar and system (vector-valued "u") cases:

  • Structural Mechanics - Plane Stress
  • Structural Mechanics - Plane Strain
  • Electrostatics
  • Magnetostatics
  • AC Power Electromagnetics
  • Conductive Media DC
  • Heat Transfer
Contact support
E-mail this page
Print this page