Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
27
Добавлен:
09.02.2015
Размер:
406.02 Кб
Скачать

1D Partial differential equation solver

<pdepe> - Solve initial-boundary value problems for parabolic-elliptic PDEs.

PDEPE Solve initial-boundary value problems for parabolic-elliptic PDEs in 1-D.

SOL = PDEPE(M,PDEFUN,ICFUN,BCFUN,XMESH,TSPAN) solves initial-boundary

value problems for small systems of parabolic and elliptic PDEs in one

space variable x and time t to modest accuracy. There are npde unknown

solution components that satisfy a system of npde equations of the form

c(x,t,u,Du/Dx) * Du/Dt = x^(-m) * D(x^m * f(x,t,u,Du/Dx))/Dx + s(x,t,u,Du/Dx)

Here f(x,t,u,Du/Dx) is a flux and s(x,t,u,Du/Dx) is a source term. m must

be 0, 1, or 2, corresponding to slab, cylindrical, or spherical symmetry,

respectively. The coupling of the partial derivatives with respect to

time is restricted to multiplication by a diagonal matrix c(x,t,u,Du/Dx).

The diagonal elements of c are either identically zero or positive.

An entry that is identically zero corresponds to an elliptic equation and

otherwise to a parabolic equation. There must be at least one parabolic

equation. An entry of c corresponding to a parabolic equation is permitted

to vanish at isolated values of x provided they are included in the mesh

XMESH, and in particular, is always allowed to vanish at the ends of the

interval. The PDEs hold for t0 <= t <= tf and a <= x <= b. The interval

[a,b] must be finite. If m > 0, it is required that 0 <= a. The solution

components are to have known values at the initial time t = t0, the

initial conditions. The solution components are to satisfy boundary

conditions at x=a and x=b for all t of the form

p(x,t,u) + q(x,t) * f(x,t,u,Du/Dx) = 0

q(x,t) is a diagonal matrix. The diagonal elements of q must be either

identically zero or never zero. Note that the boundary conditions are

expressed in terms of the flux rather than Du/Dx. Also, of the two

coefficients, only p can depend on u.

The input argument M defines the symmetry of the problem. PDEFUN, ICFUN,

and BCFUN are function handles.

[C,F,S] = PDEFUN(X,T,U,DUDX) evaluates the quantities defining the

differential equation. The input arguments are scalars X and T and

vectors U and DUDX that approximate the solution and its partial

derivative with respect to x, respectively. PDEFUN returns column

vectors: C (containing the diagonal of the matrix c(x,t,u,Dx/Du)),

F, and S (representing the flux and source term, respectively).

U = ICFUN(X) evaluates the initial conditions. For a scalar X, ICFUN

must return a column vector, corresponding to the initial values of

the solution components at X.

[PL,QL,PR,QR] = BCFUN(XL,UL,XR,UR,T) evaluates the components of the

boundary conditions at time T. XL and XR are scalars representing the

left and right boundary points. UL and UR are column vectors with the

solution at the left and right boundary, respectively. PL and QL are

column vectors corresponding to p and the diagonal of q, evaluated at

the left boundary, similarly PR and QR correspond to the right boundary.

When m > 0 and a = 0, boundedness of the solution near x = 0 requires

that the flux f vanish at a = 0. PDEPE imposes this boundary condition

automatically.

PDEPE returns values of the solution on a mesh provided as the input

array XMESH. The entries of XMESH must satisfy

a = XMESH(1) < XMESH(2) < ... < XMESH(NX) = b

for some NX >= 3. Discontinuities in c and/or s due to material

interfaces are permitted if the problem requires the flux f to be

continuous at the interfaces and a mesh point is placed at each

interface. The ODEs resulting from discretization in space are integrated

to obtain approximate solutions at times specified in the input array

TSPAN. The entries of TSPAN must satisfy

t0 = TSPAN(1) < TSPAN(2) < ... < TSPAN(NT) = tf

for some NT >= 3. The arrays XMESH and TSPAN do not play the same roles

in PDEPE: The time integration is done with an ODE solver that selects

both the time step and formula dynamically. The cost depends weakly on

the length of TSPAN. Second order approximations to the solution are made

on the mesh specified in XMESH. Generally it is best to use closely

spaced points where the solution changes rapidly. PDEPE does not select

the mesh in x automatically like it does in t; you must choose an

appropriate fixed mesh yourself. The discretization takes into account

the coordinate singularity at x = 0 when m > 0, so it is not necessary to

use a fine mesh near x = 0 for this reason. The cost depends strongly on

the length of XMESH.

The solution is returned as a multidimensional array SOL. UI = SOL(:,:,i)

is an approximation to component i of the solution vector u for

i = 1:npde. The entry UI(j,k) = SOL(j,k,i) approximates UI at

(t,x) = (TSPAN(j),XMESH(k)).

SOL = PDEPE(M,PDEFUN,ICFUN,BCFUN,XMESH,TSPAN,OPTIONS) solves as above

with default integration parameters replaced by values in OPTIONS, an

argument created with the ODESET function. Only some of the options of

the underlying ODE solver are available in PDEPE - RelTol, AbsTol,

NormControl, InitialStep, and MaxStep. See ODESET for details.

[SOL,TSOL,SOLE,TE,IE] = PDEPE(M,PDEFUN,ICFUN,BCFUN,XMESH,TSPAN,OPTIONS)

with the 'Events' property in OPTIONS set to a function handle EVENTS,

solves as above while also finding where event functions g(t,u(x,t))

are zero. For each function you specify whether the integration is to

terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(M,T,XMESH,UMESH).

XMESH contains the spatial mesh and UMESH is the solution at the mesh

points. Use PDEVAL to evaluate the solution between mesh points.

For the I-th event function: VALUE(I) is the value of the function,

ISTERMINAL(I) = 1 if the integration is to terminate at a zero of this

event function and 0 otherwise. DIRECTION(I) = 0 if all zeros are to be

computed (the default), +1 if only zeros where the event function is

increasing, and -1 if only zeros where the event function is decreasing.

Output TSOL is a column vector of times specified in TSPAN, prior to

first terminal event. SOL(j,:,:) is the solution at T(j). TE is a vector

of times at which events occur. SOLE(j,:,:) is the solution at TE(j) and

indices in vector IE specify which event occurred.

If UI = SOL(j,:,i) approximates component i of the solution at time TSPAN(j)

and mesh points XMESH, PDEVAL evaluates the approximation and its partial

derivative Dui/Dx at the array of points XOUT and returns them in UOUT

and DUOUTDX: [UOUT,DUOUTDX] = PDEVAL(M,XMESH,UI,XOUT)

NOTE that the partial derivative Dui/Dx is evaluated here rather than the

flux. The flux is continuous, but at a material interface the partial

derivative may have a jump.

Example

x = linspace(0,1,20);

t = [0 0.5 1 1.5 2];

sol = pdepe(0,@pdex1pde,@pdex1ic,@pdex1bc,x,t);

solve the problem defined by the function pdex1pde with the initial and

boundary conditions provided by the functions pdex1ic and pdex1bc,

respectively. The solution is obtained on a spatial mesh of 20 equally

spaced points in [0 1] and it is returned at times t = [0 0.5 1 1.5 2].

Often a good way to study a solution is plot it as a surface and use

Rotate 3D. The first unknown, u1, is extracted from sol and plotted with

u1 = sol(:,:,1);

surf(x,t,u1);

PDEX1 shows how this problem can be coded using subfunctions. For more

examples see PDEX2, PDEX3, PDEX4, PDEX5. The examples can be read

separately, but read in order they form a mini-tutorial on using PDEPE.

See also pdeval, ode15s, odeset, odeget, function_handle.

Reference page in Help browser

doc pdepe

Option handling

<odeset> - Create/alter ODE OPTIONS structure.

ODESET Create/alter ODE OPTIONS structure.

OPTIONS = ODESET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an integrator

options structure OPTIONS in which the named properties have the

specified values. Any unspecified properties have default values. It is

sufficient to type only the leading characters that uniquely identify the

property. Case is ignored for property names.

OPTIONS = ODESET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options

structure OLDOPTS.

OPTIONS = ODESET(OLDOPTS,NEWOPTS) combines an existing options structure

OLDOPTS with a new options structure NEWOPTS. Any new properties

overwrite corresponding old properties.

ODESET with no input arguments displays all property names and their

possible values.

ODESET PROPERTIES

RelTol - Relative error tolerance [ positive scalar {1e-3} ]

This scalar applies to all components of the solution vector, and

defaults to 1e-3 (0.1% accuracy) in all solvers. The estimated error in

each integration step satisfies e(i) <= max(RelTol*abs(y(i)),AbsTol(i)).

AbsTol - Absolute error tolerance [ positive scalar or vector {1e-6} ]

A scalar tolerance applies to all components of the solution vector.

Elements of a vector of tolerances apply to corresponding components of

the solution vector. AbsTol defaults to 1e-6 in all solvers. See RelTol.

NormControl - Control error relative to norm of solution [ on | {off} ]

Set this property 'on' to request that the solvers control the error in

each integration step with norm(e) <= max(RelTol*norm(y),AbsTol). By

default the solvers use a more stringent component-wise error control.

Refine - Output refinement factor [ positive integer ]

This property increases the number of output points by the specified

factor producing smoother output. Refine defaults to 1 in all solvers

except ODE45, where it is 4. Refine does not apply if length(TSPAN) > 2

or the ODE solver returns the solution as a structure.

OutputFcn - Installable output function [ function_handle ]

This output function is called by the solver after each time step. When

a solver is called with no output arguments, OutputFcn defaults to

@odeplot. Otherwise, OutputFcn defaults to [].

OutputSel - Output selection indices [ vector of integers ]

This vector of indices specifies which components of the solution vector

are passed to the OutputFcn. OutputSel defaults to all components.

Stats - Display computational cost statistics [ on | {off} ]

Jacobian - Jacobian function [ function_handle | constant matrix ]

Set this property to @FJac if FJac(t,y) returns dF/dy, or to

the constant value of dF/dy.

For ODE15I solving F(t,y,y') = 0, set this property to @FJac if

[dFdy, dFdyp] = FJac(t,y,yp), or to a cell array of constant

values {dF/dy,dF/dyp}.

JPattern - Jacobian sparsity pattern [ sparse matrix ]

Set this property to a sparse matrix S with S(i,j) = 1 if component i of

F(t,y) depends on component j of y, and 0 otherwise.

For ODE15I solving F(t,y,y') = 0, set this property to

{dFdyPattern,dFdypPattern}, the sparsity patterns of dF/dy and

dF/dy', respectively.

Vectorized - Vectorized ODE function [ on | {off} ]

Set this property 'on' if the ODE function F is coded so that

F(t,[y1 y2 ...]) returns [F(t,y1) F(t,y2) ...].

For ODE15I solving F(t,y,y') = 0, set this property to

{yVect,ypVect}. Setting yVect 'on' indicates that

F(t,[y1 y2 ...],yp) returns [F(t,y1,yp) F(t,y2,yp) ...].

Setting ypVect 'on' indicates that F(t,y,[yp1 yp2 ...])

returns [F(t,y,yp1) F(t,y,yp2) ...].

Events - Locate events [ function_handle ]

To detect events, set this property to the event function.

Mass - Mass matrix [ constant matrix | function_handle ]

For problems M*y' = f(t,y) set this property to the value of the constant

mass matrix. For problems with time- or state-dependent mass matrices,

set this property to a function that evaluates the mass matrix.

MStateDependence - Dependence of the mass matrix on y [ none | {weak} | strong ]

Set this property to 'none' for problems M(t)*y' = F(t,y). Both 'weak' and

'strong' indicate M(t,y), but 'weak' will result in implicit solvers

using approximations when solving algebraic equations.

MassSingular - Mass matrix is singular [ yes | no | {maybe} ]

Set this property to 'no' if the mass matrix is not singular.

MvPattern - dMv/dy sparsity pattern [ sparse matrix ]

Set this property to a sparse matrix S with S(i,j) = 1 if for any k, the

(i,k) component of M(t,y) depends on component j of y, and 0 otherwise.

InitialSlope - Consistent initial slope yp0 [ vector ]

yp0 satisfies M(t0,y0)*yp0 = F(t0,y0).

InitialStep - Suggested initial step size [ positive scalar ]

The solver will try this first. By default the solvers determine an

initial step size automatically.

MaxStep - Upper bound on step size [ positive scalar ]

MaxStep defaults to one-tenth of the tspan interval in all solvers.

NonNegative - Non-negative solution components [ vector of integers ]

This vector of indices specifies which components of the

solution vector must be non-negative. NonNegative defaults to [].

This property is not available in ODE23S, ODE15I. In ODE15S,

ODE23T, and ODE23TB, the property is not available for problems

where there is a mass matrix.

BDF - Use Backward Differentiation Formulas in ODE15S [ on | {off} ]

This property specifies whether the Backward Differentiation Formulas

(Gear's methods) are to be used in ODE15S instead of the default

Numerical Differentiation Formulas.

MaxOrder - Maximum order of ODE15S and ODE15I [ 1 | 2 | 3 | 4 | {5} ]

See also odeget, ode45, ode23, ode113, ode15i, ode15s, ode23s, ode23t, ode23tb,

function_handle.

NOTE:

Some of the properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 properties when used with the v5 syntax

of the ODE solvers, any new functionality will be available only with the

new syntax. To see the properties available in v5, type in the command line

more on, type odeset, more off

Reference page in Help browser

doc odeset

<odeget> - Get ODE OPTIONS parameters.

ODEGET Get ODE OPTIONS parameters.

VAL = ODEGET(OPTIONS,'NAME') extracts the value of the named property

from integrator options structure OPTIONS, returning an empty matrix if

the property value is not specified in OPTIONS. It is sufficient to type

only the leading characters that uniquely identify the property. Case is

ignored for property names. [] is a valid OPTIONS argument.

VAL = ODEGET(OPTIONS,'NAME',DEFAULT) extracts the named property as

above, but returns VAL = DEFAULT if the named property is not specified

in OPTIONS. For example

val = odeget(opts,'RelTol',1e-4);

returns val = 1e-4 if the RelTol property is not specified in opts.

See also odeset, ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb.

Reference page in Help browser

doc odeget

<ddeset> - Create/alter DDE OPTIONS structure.

DDESET Create/alter DDE OPTIONS structure.

OPTIONS = DDESET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an integrator

options structure OPTIONS in which the named properties have the

specified values. Any unspecified properties have default values. It is

sufficient to type only the leading characters that uniquely identify the

property. Case is ignored for property names.

OPTIONS = DDESET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options

structure OLDOPTS.

OPTIONS = DDESET(OLDOPTS,NEWOPTS) combines an existing options structure

OLDOPTS with a new options structure NEWOPTS. Any new properties

overwrite corresponding old properties.

DDESET with no input arguments displays all property names and their

possible values.

DDESET PROPERTIES

RelTol - Relative error tolerance [ positive scalar {1e-3} ]

This scalar applies to all components of the solution vector, and

defaults to 1e-3 (0.1% accuracy). The estimated error in each

integration step satisfies e(i) <= max(RelTol*abs(y(i)),AbsTol(i)).

AbsTol - Absolute error tolerance [ positive scalar or vector {1e-6} ]

A scalar tolerance applies to all components of the solution vector.

Elements of a vector of tolerances apply to corresponding components of

the solution vector. AbsTol defaults to 1e-6.

NormControl - Control error relative to norm of solution [ on | {off} ]

Set this property 'on' to request that the solver controls the error in

each integration step with norm(e) <= max(RelTol*norm(y),AbsTol). By

default the solver uses a more stringent component-wise error control.

Events - Locate events [ function_handle ]

To detect events, set this property to the event function.

InitialStep - Suggested initial step size [ positive scalar ]

The solver will try this first. By default the solver determines an

initial step size automatically.

MaxStep - Upper bound on step size [ positive scalar ]

MaxStep defaults to one-tenth of the tspan interval.

OutputFcn - Installable output function [ function_handle ]

This output function is called by the solver after each time step. When

the solver is called with no output arguments, OutputFcn defaults to

@odeplot. Otherwise, OutputFcn defaults to [].

OutputSel - Output selection indices [ vector of integers ]

This vector of indices specifies which components of the solution vector

are passed to the OutputFcn. OutputSel defaults to all components.

Refine - Output refinement factor [ positive integer {1} ]

This property increases the number of points passed to the OutputFcn

after each integration step, resulting in a smoother output. Refine

does not apply if length(TSPAN) > 2.

Stats - Display computational cost statistics [ on | {off} ]

InitialY - Initial value of solution [ vector ]

By default the initial value of the solution is the value returned by

HISTORY at the initial point. A different initial value can be supplied

as the value of the InitialY property.

Jumps - Discontinuities in solution [ vector ]

Points t where the history or solution may have a jump discontinuity

in a low order derivative. This property is not available in DDESD.

See also ddeget, dde23, ddesd, function_handle.

Reference page in Help browser

doc ddeset

<ddeget> - Get DDE OPTIONS parameters.

DDEGET Get DDE OPTIONS parameters.

VAL = DDEGET(OPTIONS,'NAME') extracts the value of the named property

from integrator options structure OPTIONS, returning an empty matrix if

the property value is not specified in OPTIONS. It is sufficient to type

only the leading characters that uniquely identify the property. Case is

ignored for property names. [] is a valid OPTIONS argument.

VAL = DDEGET(OPTIONS,'NAME',DEFAULT) extracts the named property as

above, but returns VAL = DEFAULT if the named property is not specified

in OPTIONS. For example

val = ddeget(opts,'RelTol',1e-4);

returns val = 1e-4 if the RelTol property is not specified in opts.

See also ddeset, dde23, ddesd.

Reference page in Help browser

doc ddeget

<bvpset> - Create/alter BVP OPTIONS structure.

BVPSET Create/alter BVP OPTIONS structure.

OPTIONS = BVPSET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an integrator

options structure OPTIONS in which the named properties have the

specified values. Any unspecified properties have default values. It is

sufficient to type only the leading characters that uniquely identify the

property. Case is ignored for property names.

OPTIONS = BVPSET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options

structure OLDOPTS.

OPTIONS = BVPSET(OLDOPTS,NEWOPTS) combines an existing options structure

OLDOPTS with a new options structure NEWOPTS. Any new properties overwrite

corresponding old properties.

BVPSET with no input arguments displays all property names and their

possible values.

BVPSET PROPERTIES

RelTol - Relative tolerance for the residual [ positive scalar {1e-3} ]

This scalar applies to all components of the residual vector, and

defaults to 1e-3 (0.1% accuracy). The computed solution S(x) is the exact

solution of S'(x) = F(x,S(x)) + res(x). In BVP4C, on each subinterval

of the mesh, component i of the residual satisfies

norm( res(i) / max( [abs(F(i)) , AbsTol(i)/RelTol] ) ) <= RelTol.

In BVP5C, the residual satisfies

norm( h(j)*res(i) / max( [abs(y(i)) , AbsTol(i)/RelTol] ) ) <= RelTol,

where h(j) is the length of subinterval j. Generally component i of the

error e(x) = y(x) - S(x) then satisfies

norm( e(i) / max( [abs(y(i)) , AbsTol(i)/RelTol] ) ) <= RelTol.

AbsTol - Absolute tolerance for the residual [ positive scalar or vector {1e-6} ]

A scalar tolerance applies to all components of the residual vector.

Elements of a vector of tolerances apply to corresponding components of

the residual vector. AbsTol defaults to 1e-6. See RelTol.

SingularTerm - Singular term of singular BVPs [ matrix ]

Set to the constant matrix S for equations of the form y' = S*y/x + f(x,y,p).

FJacobian - Analytical partial derivatives of ODEFUN

[ function_handle | matrix | cell array ]

For example, when solving y' = f(x,y), set this property to @FJAC if

DFDY = FJAC(X,Y) evaluates the Jacobian of f with respect to y.

If the problem involves unknown parameters, [DFDY,DFDP] = FJAC(X,Y,P)

must also return the partial derivative of f with respect to p.

For problems with constant partial derivatives, set this property to

the value of DFDY or to a cell array {DFDY,DFDP}.

BCJacobian - Analytical partial derivatives of BCFUN

[ function_handle | cell array ]

For example, for boundary conditions bc(ya,yb) = 0, set this property to

@BCJAC if [DBCDYA,DBCDYB] = BCJAC(YA,YB) evaluates the partial

derivatives of bc with respect to ya and to yb. If the problem involves

unknown parameters, [DBCDYA,DBCDYB,DBCDP] = BCJAC(YA,YB,P) must also

return the partial derivative of bc with respect to p.

For problems with constant partial derivatives, set this

property to a cell array {DBCDYA,DBCDYB} or {DBCDYA,DBCDYB,DBCDP}.

Nmax - Maximum number of mesh points allowed [positive integer {floor(10000/n)}]

Stats - Display computational cost statistics [ on | {off} ]

Vectorized - Vectorized ODE function [ on | {off} ]

Set this property 'on' if the derivative function

ODEFUN([x1 x2 ...],[y1 y2 ...]) returns [ODEFUN(x1,y1) ODEFUN(x2,y2) ...].

When parameters are present, the derivative function

ODEFUN([x1 x2 ...],[y1 y2 ...],p) should return

[ODEFUN(x1,y1,p) ODEFUN(x2,y2,p) ...].

See also bvpget, bvpinit, bvp4c, bvp5c, deval, function_handle.

Reference page in Help browser

doc bvpset

<bvpget> - Get BVP OPTIONS parameters.

BVPGET Get BVP OPTIONS parameters.

VAL = BVPGET(OPTIONS,'NAME') extracts the value of the named property

from integrator options structure OPTIONS, returning an empty matrix if

the property value is not specified in OPTIONS. It is sufficient to type

only the leading characters that uniquely identify the property. Case is

ignored for property names. [] is a valid OPTIONS argument.

VAL = BVPGET(OPTIONS,'NAME',DEFAULT) extracts the named property as

above, but returns VAL = DEFAULT if the named property is not specified

in OPTIONS. For example

val = bvpget(opts,'RelTol',1e-4);

returns val = 1e-4 if the RelTol property is not specified in opts.

See also bvpset, bvpinit, bvp4c, bvp5c, deval.

Reference page in Help browser

doc bvpget

Соседние файлы в папке Библиотеки Matlab