Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

parabolic

Solve parabolic PDE problem

Parabolic equation solver

Solves PDE problems of the type

dut(cu)+au=f

on a 2-D or 3-D region Ω, or the system PDE problem

dut(cu)+au=f

The variables c, a, f, and d can depend on position, time, and the solution u and its gradient.

parabolic is not recommended. Use solvepde instead.

Syntax

  • u = parabolic(u0,tlist,model,c,a,f,d)
    example
  • u = parabolic(u0,tlist,b,p,e,t,c,a,f,d)
    example
  • u = parabolic(u0,tlist,Kc,Fc,B,ud,M)
    example
  • u = parabolic(___,rtol)
  • u = parabolic(___,rtol,atol)
  • u = parabolic(___,'Stats','off')

Description

example

u = parabolic(u0,tlist,model,c,a,f,d) produces the solution to the FEM formulation of the scalar PDE problem

dut(cu)+au=f

on a 2-D or 3-D region Ω, or the system PDE problem

dut(cu)+au=f

with geometry, mesh, and boundary conditions specified in model, and with initial value u0. The variables c, a, f, and d in the equation correspond to the function coefficients c, a, f, and d respectively.

example

u = parabolic(u0,tlist,b,p,e,t,c,a,f,d) solves the problem using boundary conditions b and finite element mesh specified in [p,e,t].

example

u = parabolic(u0,tlist,Kc,Fc,B,ud,M) solves the problem based on finite element matrices that encode the equation, mesh, and boundary conditions.

u = parabolic(___,rtol) and u = parabolic(___,rtol,atol), for any of the previous input arguments, modify the solution process by passing to the ODE solver a relative tolerance rtol, and optionally an absolute tolerance atol.

u = parabolic(___,'Stats','off'), for any of the previous input arguments, turns off the display of internal ODE solver statistics during the solution process.

Examples

collapse all

Solve the parabolic equation

$$\frac{\partial u}{\partial t} = \Delta u$$

on the square domain specified by squareg.

Create a PDE model and import the geometry.

model = createpde;
geometryFromEdges(model,@squareg);
pdegplot(model,'EdgeLabels','on')
ylim([-1.1,1.1])
axis equal

Set Dirichlet boundary conditions $u = 0$ on all edges.

applyBoundaryCondition(model,'dirichlet','Edge',1:model.Geometry.NumEdges,'u',0);

Generate a relatively fine mesh.

generateMesh(model,'Hmax',0.02);

Set the initial condition to have $u(0) = 1$ on the disk $x^2 + y^2 \le 0.4^2$ and $u(0) = 0$ elsewhere.

p = model.Mesh.Nodes;
u0 = zeros(size(p,2),1);
ix = find(sqrt(p(1,:).^2 + p(2,:).^2) <= 0.4);
u0(ix) = ones(size(ix));

Set solution times to be from 0 to 0.1 with step size 0.005.

tlist = linspace(0,0.1,21);

Create the PDE coefficients.

c = 1;
a = 0;
f = 0;
d = 1;

Solve the PDE.

u = parabolic(u0,tlist,model,c,a,f,d);
147 successful steps
0 failed attempts
296 function evaluations
1 partial derivatives
28 LU decompositions
295 solutions of linear systems

Plot the initial condition, the solution at the final time, and two intermediate solutions.

figure
subplot(2,2,1)
pdeplot(model,'XYData',u(:,1));
axis equal
title('t = 0')
subplot(2,2,2)
pdeplot(model,'XYData',u(:,5))
axis equal
title('t = 0.02')
subplot(2,2,3)
pdeplot(model,'XYData',u(:,11))
axis equal
title('t = 0.05')
subplot(2,2,4)
pdeplot(model,'XYData',u(:,end))
axis equal
title('t = 0.1')

Solve the parabolic equation

$$\frac{\partial u}{\partial t} = \Delta u$$

on the square domain specified by squareg, using a geometry function to specify the geometry, a boundary function to specify the boundary conditions, and using initmesh to create the finite element mesh.

Specify the geometry as @squareg and plot the geometry.

g = @squareg;
pdegplot(g,'EdgeLabels','on')
ylim([-1.1,1.1])
axis equal

Set Dirichlet boundary conditions $u = 0$ on all edges. The squareb1 function specifies these boundary conditions.

b = @squareb1;

Generate a relatively fine mesh.

[p,e,t] = initmesh(g,'Hmax',0.02);

Set the initial condition to have $u(0) = 1$ on the disk $x^2 + y^2 \le 0.4^2$ and $u(0) = 0$ elsewhere.

u0 = zeros(size(p,2),1);
ix = find(sqrt(p(1,:).^2 + p(2,:).^2) <= 0.4);
u0(ix) = ones(size(ix));

Set solution times to be from 0 to 0.1 with step size 0.005.

tlist = linspace(0,0.1,21);

Create the PDE coefficients.

c = 1;
a = 0;
f = 0;
d = 1;

Solve the PDE.

u = parabolic(u0,tlist,b,p,e,t,c,a,f,d);
147 successful steps
0 failed attempts
296 function evaluations
1 partial derivatives
28 LU decompositions
295 solutions of linear systems

Plot the initial condition, the solution at the final time, and two intermediate solutions.

figure
subplot(2,2,1)
pdeplot(p,e,t,'XYData',u(:,1));
axis equal
title('t = 0')
subplot(2,2,2)
pdeplot(p,e,t,'XYData',u(:,5))
axis equal
title('t = 0.02')
subplot(2,2,3)
pdeplot(p,e,t,'XYData',u(:,11))
axis equal
title('t = 0.05')
subplot(2,2,4)
pdeplot(p,e,t,'XYData',u(:,end))
axis equal
title('t = 0.1')

Create finite element matrices that encode a parabolic problem, and solve the problem.

The problem is the evolution of temperature in a conducting block. The block is a rectangular slab.

model = createpde(1);
importGeometry(model,'Block.stl');
handl = pdegplot(model,'FaceLabels','on');
view(-42,24)
handl(1).FaceAlpha = 0.5;

Faces 1, 4, and 6 of the slab are kept at 0 degrees. The other faces are insulated. Include the boundary condition on faces 1, 4, and 6. You do not need to include the boundary condition on the other faces because the default condition is insulated.

applyBoundaryCondition(model,'dirichlet','Face',[1,4,6],'u',0);

The initial temperature distribution in the block has the form

$$u_0 = 10^{-3}xyz.$$

generateMesh(model);
p = model.Mesh.Nodes;
x = p(1,:);
y = p(2,:);
z = p(3,:);
u0 = x.*y.*z*1e-3;

The parabolic equation in toolbox syntax is

$$d\frac{\partial u}{\partial t} - \nabla\cdot(c\nabla u) + au = f.$$

Suppose the thermal conductivity of the block leads to a $c$ coefficient value of 1. The values of the other coefficients in this problem are $d = 1$, $a = 0$, and $f = 0$.

d = 1;
c = 1;
a = 0;
f = 0;

Create the finite element matrices that encode the problem.

[Kc,Fc,B,ud] = assempde(model,c,a,f);
[~,M,~] = assema(model,0,d,f);

Solve the problem at time steps of 1 for times ranging from 0 to 40.

tlist = linspace(0,40,41);
u = parabolic(u0,tlist,Kc,Fc,B,ud,M);
38 successful steps
0 failed attempts
78 function evaluations
1 partial derivatives
10 LU decompositions
77 solutions of linear systems

Plot the solution on the outside of the block at times 0, 10, 25, and 40. Ensure that the coloring is the same for all plots.

umin = min(min(u));
umax = max(max(u));
subplot(2,2,1)
pdeplot3D(model,'ColorMapData',u(:,1))
colorbar off
view(125,22)
title 't = 0'
caxis([umin umax]);
subplot(2,2,2)
pdeplot3D(model,'ColorMapData',u(:,11))
colorbar off
view(125,22)
title 't = 10'
caxis([umin umax]);
subplot(2,2,3)
pdeplot3D(model,'ColorMapData',u(:,26))
colorbar off
view(125,22)
title 't = 25'
caxis([umin umax]);
subplot(2,2,4)
pdeplot3D(model,'ColorMapData',u(:,41))
colorbar off
view(125,22)
title 't = 40'
caxis([umin umax]);

Input Arguments

collapse all

Initial condition, specified as a scalar, vector of nodal values, or text expression. The initial condition is the value of the solution u at the initial time, specified as a column vector of values at the nodes. The nodes are either p in the [p,e,t] data structure, or are model.Mesh.Nodes. For details, see Solve PDEs with Initial Conditions.

  • If the initial condition is a constant scalar v, specify u0 as v.

  • If there are Np nodes in the mesh, and N equations in the system of PDEs, specify u0 as a column vector of Np*N elements, where the first Np elements correspond to the first component of the solution u, the second Np elements correspond to the second component of the solution u, etc.

  • Give a text expression of a function, such as 'x.^2 + 5*cos(x.*y)'. If you have a system of N > 1 equations, give a text array such as

    char('x.^2 + 5*cos(x.*y)',...
        'tanh(x.*y)./(1+z.^2)')

Example: x.^2+5*cos(y.*x)

Data Types: double | char
Complex Number Support: Yes

Solution times, specified as a real vector. The solver returns the solution to the PDE at the solution times.

Example: 0:0.2:4

Data Types: double

PDE model, specified as a PDEModel object.

Example: model = createpde(1)

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. c represents the c coefficient in the scalar PDE

dut(cu)+au=f

or in the system of PDEs

dut(cu)+au=f

You can specifyc in various ways, detailed in c Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

Example: 'cosh(x+y.^2)'

Data Types: double | char | function_handle
Complex Number Support: Yes

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. a represents the a coefficient in the scalar PDE

dut(cu)+au=f

or in the system of PDEs

dut(cu)+au=f

You can specifya in various ways, detailed in a or d Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

Example: 2*eye(3)

Data Types: double | char | function_handle
Complex Number Support: Yes

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. f represents the f coefficient in the scalar PDE

dut(cu)+au=f

or in the system of PDEs

dut(cu)+au=f

You can specifyf in various ways, detailed in f Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

Example: char('sin(x)';'cos(y)';'tan(z)')

Data Types: double | char | function_handle
Complex Number Support: Yes

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. d represents the d coefficient in the scalar PDE

dut(cu)+au=f

or in the system of PDEs

dut(cu)+au=f

You can specifyd in various ways, detailed in a or d Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

Example: 2*eye(3)

Data Types: double | char | function_handle
Complex Number Support: Yes

Boundary conditions, specified as a boundary matrix or boundary file. Pass a boundary file as a function handle or as a file name.

Example: b = 'circleb1' or equivalently b = @circleb1

Data Types: double | char | function_handle

Mesh points, specified as a 2-by-Np matrix of points, where Np is the number of points in the mesh. For a description of the (p,e,t) matrices, see Mesh Data.

Typically, you use the p, e, and t data exported from the PDE app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Mesh edges, specified as a 7-by-Ne matrix of edges, where Ne is the number of edges in the mesh. For a description of the (p,e,t) matrices, see Mesh Data.

Typically, you use the p, e, and t data exported from the PDE app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Mesh triangles, specified as a 4-by-Nt matrix of triangles, where Nt is the number of triangles in the mesh. For a description of the (p,e,t) matrices, see Mesh Data.

Typically, you use the p, e, and t data exported from the PDE app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Stiffness matrix, specified as a sparse matrix or as a full matrix. See Elliptic Equations. Typically, Kc is the output of assempde.

Load vector, specified as a vector. See Elliptic Equations. Typically, Fc is the output of assempde.

Dirichlet nullspace, returned as a sparse matrix. See Algorithms. Typically, B is the output of assempde.

Dirichlet vector, returned as a vector. See Algorithms. Typically, ud is the output of assempde.

Mass matrix. specified as a sparse matrix or a full matrix. See Elliptic Equations.

To obtain the input matrices for pdeeig, hyperbolic or parabolic, run both assema and assempde:

[Kc,Fc,B,ud] = assempde(model,c,a,f);
[~,M,~] = assema(model,0,d,f);

    Note:   Create the M matrix using assema with d, not a, as the argument before f.

Data Types: double
Complex Number Support: Yes

Relative tolerance for ODE solver, specified as a positive real.

Example: 2e-4

Data Types: double

Absolute tolerance for ODE solver, specified as a positive real.

Example: 2e-7

Data Types: double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example:

collapse all

Display ODE solver statistics, specified as 'on' or 'off'. Suppress the display by setting Stats to 'off'.

Example: x = parabolic(u0,tlist,model,c,a,f,d,'Stats','off')

Data Types: char

Output Arguments

collapse all

PDE solution, returned as a matrix. The matrix is Np*N-by-T, where Np is the number of nodes in the mesh, N is the number of equations in the PDE (N = 1 for a scalar PDE), and T is the number of solution times, meaning the length of tlist. The solution matrix has the following structure.

  • The first Np elements of each column in u represent the solution of equation 1, then next Np elements represent the solution of equation 2, etc. The solution u is the value at the corresponding node in the mesh.

  • Column i of u represents the solution at time tlist(i).

To obtain the solution at an arbitrary point in the geometry, use pdeInterpolant.

To plot the solution, use pdeplot for 2-D geometry, or see Plot 3-D Solutions and Their Gradients.

More About

collapse all

Algorithms

parabolic internally calls assema, assemb, and assempde to create finite element matrices corresponding to the problem. It calls ode15s to solve the resulting system of ordinary differential equations. For details, see Parabolic Equations.

See Also

Introduced before R2006a

Was this topic helpful?