This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Poisson's Equation on a Unit Disk

This example shows how to numerically solve a Poisson's equation using the solvepde function in Partial Differential Equation Toolbox™.

The particular PDE is

on the unit disk with zero-Dirichlet boundary conditions. The exact solution is

For most partial differential equations, the exact solution is not known. In this example, however, we can use the known, exact solution to show how the error decreases as the mesh is refined.

Problem Definition

The following variables will define our problem:

  • g: A specification function that is used by geometryFromEdges. For more information, please see the documentation pages for circleg and the documentation section Create Geometry Using a Geometry Function.

  • c, a, f: The coefficients and inhomogeneous term.

g = @circleg;
c = 1;
a = 0;
f = 1;

PDE Coefficients and Boundary Conditions

Plot the geometry and display the edge labels for use in the boundary condition definition.

axis equal

Create a PDE Model with a single dependent variable.

numberOfPDE = 1;
model = createpde(numberOfPDE);

Create a geometry entity.


Specify PDE coefficients.


The solution is zero at all four outer edges of the circle.


Generate Initial Mesh

The function generateMesh takes a geometry specification function and returns a discretization of that domain. The 'Hmax' option lets the user specify the maximum edge length. In this case, because the domain is a unit disk, a maximum edge length of one creates a coarse discretization.

hmax = 1;
axis equal


We repeatedly refine the mesh until the infinity-norm of the error vector is less than .

For this domain, each refinement halves the 'Hmax' option.

er = Inf;
while er > 0.001
    hmax =hmax/2;
    result = solvepde(model);
    msh = model.Mesh;
    u = result.NodalSolution;
    exact = (1-msh.Nodes(1,:).^2-msh.Nodes(2,:).^2)'/4;
    er = norm(u-exact,'inf');
    fprintf('Error: %e. Number of nodes: %d\n',er,size(msh.Nodes,2));
Error: 7.607008e-04. Number of nodes: 61

Plot Final Mesh

axis equal

Plot FEM Solution


Was this topic helpful?