Documentation

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

Parabolic Equation

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,'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')

Parabolic Equation Using Legacy Syntax

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')

Parabolic Problem Using Matrix Coefficients

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,'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

u0 — Initial conditionvector | text expression

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

tlist — Solution timesreal vector

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

model — PDE modelPDEModel object

PDE model, specified as a PDEModel object.

Example: model = createpde(1)

c — PDE coefficientscalar or matrix | character array | coefficient function

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 Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

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

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

a — PDE coefficientscalar or matrix | character array | coefficient function

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 Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

Example: 2*eye(3)

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

f — PDE coefficientscalar or matrix | character array | coefficient function

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 Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

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

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

d — PDE coefficientscalar or matrix | character array | coefficient function

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 Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

Example: 2*eye(3)

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

b — Boundary conditionsboundary matrix | boundary file

Boundary conditions, specified as a boundary matrix or boundary file. Pass a boundary file as a function handle or as a string naming the file.

For more information on boundary conditions, see Forms of Boundary Condition Specification.

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

Data Types: double | char | function_handle

p — Mesh nodesoutput of initmesh | output of meshToPet

Mesh nodes, specified as the output of initmesh or meshToPet. For the structure of a p matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

Data Types: double

e — Mesh edgesoutput of initmesh | output of meshToPet

Mesh edges, specified as the output of initmesh or meshToPet. For the structure of e, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

Data Types: double

t — Mesh elementsoutput of initmesh | output of meshToPet

Mesh elements, specified as the output of initmesh or meshToPet. Mesh elements are the triangles or tetrahedra that form the finite element mesh. For the structure of a t matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

Data Types: double

Kc — Stiffness matrixsparse matrix | full matrix

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

Fc — Load vectorvector

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

B — Dirichlet nullspacesparse matrix

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

ud — Dirichlet vectorvector

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

M — Mass matrixsparse matrix | full matrix

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

rtol — Relative tolerance for ODE solver1e-3 (default) | positive real

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

Example: 2e-4

Data Types: double

atol — Absolute tolerance for ODE solver1e-6 (default) | positive real

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:

'Stats' — Display ODE solver statistics'on' (default) | 'off'

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

u — PDE solutionmatrix

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?