pdsolve/numeric/method - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Differential Equations : pdsolve : pdsolve/numeric/education

pdsolve/numeric/method

find a numerical solution of a PDE using a specified method

 

Calling Sequence

Parameters

Description

Options

Examples

Calling Sequence

pdsolve(PDE, conditions, numeric, meth, options)

Parameters

PDE

-

single partial differential equations in two independent variables

conditions

-

set or list initial and boundary conditions

numeric

-

keyword indicating a numerical solution is to be obtained

meth

-

name (symbol or indexed) of the form method=meth; select method to use for solution

options

-

(optional) equations of the form keyword = value

Description

• 

In addition to the default interface to pdsolve/numeric, which uses the default theta methods (the theta family of methods), additional functionality is available for use of numerical pdsolve for educational purposes.

• 

This additional functionality includes the use of 11 standard methods, specification of numerical boundary conditions, specification of startup schemes for two-stage methods, and extensibility for your custom methods.

• 

The use of pdsolve/numeric with these methods is restricted to a single parabolic/hyperbolic PDE that is first order in time.

• 

As with the default method, pdsolve/numeric/method returns a module that can be used to plot solutions, or obtain procedures that provide their values. For information on the plot, animate, plot3d, value, and settings module members, see pdsolve/numeric.

• 

The method argument specifies the method to use for the problem. The available methods are:

ForwardTime1Space[backward/forward]

CenteredTime1Space[backward/forward]

BackwardTime1Space[backward/forward]

Euler/ForwardTimeCenteredSpace

CrankNicholson/CenteredTimeCenteredSpace

BackwardEuler/BackwardTimeCenteredSpace

Box[backward/forward]

LaxFriedrichs

LaxWendroff

Leapfrog

DuFortFrankel

  

For a description of each method, including related problems, and instructions on creating a custom scheme, see pdsolve/numeric/methods.

Options

• 

The options available to pdsolve/numeric/method for these additional methods are as follows.

'time'

=

name

'range'

=

l..r

'spacestep'

=

numeric

'timestep'

=

numeric

'bcpts'

=

integer

'optimize'

=

boolean/symbol

'numericalbcs'

=

set, list or expression

'startup'

=

symbol

'startupsteps'

=

integer

'startupnumbc'

=

set, list or expression

• 

The time=name, range=l..r, spacestep=numeric, timestep=numeric, bcpts=integer, and optimize=boolean/symbol options are the same as for the default method.

  

- The time and range options must be specified for problems that are first order in time and space with a boundary condition that involves only one end point (otherwise the time/space variables and range are detected automatically).

  

- The value of the spacestep option is the size of the spatial step to use for the discrete problem. It defaults to 1/20th the spatial range.

  

- The value of the timestep option is the size of the temporal step to use for the discrete problem. It defaults to the value of spacestep.

  

- The value of the bcpts option is the number of points used in the approximation of derivatives present in the boundary conditions.

  

- The optimize option controls the level of optimization used for generating the solution module. For more information, see pdsolve/numeric.

• 

The numericalbcs=set, list or expression argument describes the numerical boundary conditions. It is required for the use of some methods with some PDEs.

  

For example, the Euler method relates the values of the solution for 3 consecutive points in the spatial domain. This means that boundary conditions must specify solution values at 2 points in the spatial domain. If the PDE is first order in space, only one natural boundary condition can be specified, and the scheme cannot be used directly.

  

Numerical boundary conditions allow specification of additional discrete equations, on the spatial mesh, which allow the method to be used for the PDE problem. These are often derived from an extrapolation, or a discretization of the PDE at or near the boundary that requires the additional condition.

  

The pdsolve command currently accepts two forms of numerical boundary conditions.

  

The first form specifies that the numerical boundary condition be obtained from one of the specified methods (likely more compact) applied to the input PDE near the boundary.

  

The second form allows significantly more control, but requires that numerical boundary condition be provided as a discrete equation that is a relationship amongst the discrete values of the dependent variable at the boundary. This form of numerical boundary condition can depend on the time and space variables of the problem, as well as the time and space step sizes (though the names used for the step sizes must be specified), and must be linear in the discrete dependent variable values.

  

The numericalbcs argument can be specified using the following forms:

`numericalbcs` =

[method, point]

`numericalbcs` =

expression

`numericalbcs` =

{expression, 'timestep'=symbol, 'spacestep'=symbol}

`numericalbcs` =

{[method[1], point[1]], ..., [method[n], point[n]],

 

expression[1], ..., expression[m],

 

'timestep'=symbol, 'spacestep'=symbol}

  

where method describes a method accepted by pdsolve (for example, Euler) or a custom method, point describes the boundary and offset to be used for the scheme generated by the method, timestep,spacestep specify the names used for the time and space step sizes in the numerical boundary condition, and the expression arguments are discrete forms of the numerical boundary conditions.

• 

For the method specified numerical boundary conditions, the value of point indicates the leftmost or rightmost point to be used in the discrete formula obtained by the method. For example, if point is specified as 'n'-1 (where 'n' is some symbol) and the specified method has a width of 2, the condition is applied at the right boundary, and the solution values at the discrete points 'n'-1 and 'n'-2 are used in the discrete formula. As another example, if point is specified as 1 for the same method, the condition is applied at the left boundary, and the solution values at the discrete points 1, 2 are used in the discrete formula.

  

As a more detailed example, consider solution of the PDE ut+0.1ux=0 using the LaxFriedrichs method. Since this problem is first order in space, only one natural boundary condition can be applied (one boundary condition on the left boundary). However, the method has a width of 3, so two conditions are needed, thus requiring the specification of a numerical boundary condition.

  

The additional argument numericalbcs=Box,n specifies the use of the Box method to obtain the required additional relation for the right boundary, and in fact is equivalent to the more complicated specification numericalbcs=spacestep=h,timestep=k,12v1,nv0,n+v1,n1v0,n1k+0.05000000000v1,nv1,n1+v0,nv0,n1h=0 that corresponds to using expression specified numerical boundary conditions.

• 

The expression specified numerical boundary conditions must be provided in a very particular form. The discrete dependent variable values must be given as indexed variables with the time index first, followed by the space index (that is, utimeidx,spaceidx). Values of the time index can range from 1 to 1, where a value of 1 indicates a value at the new time step (Note: The range is from 0 to 1 for single stage method). Values of the space index can range from 1 (left boundary) to 'n' (right boundary) where 'n' is any symbol that is consistent over the numerical boundary condition. If 'n' is present in the space index, it must be of the form ni where i=0,... (for example, u1,12n and u1,2n are not allowed).

  

For example, a numerical boundary condition that forces the value of the solution on the right boundary to be the same as the value of the solution at the first interior point can be specified as numericalbcs=u1,nu1,n1. A similar condition for the left boundary can be specified as numericalbcs=u1,1u1,2.

  

The independent variable values also require some description. The spatial values must be given as the space variable indexed in the same manner as the spatial index described for the dependent variable values (for example, xn1 or x1). The temporal values must be given relative to the 0 time index. For example, for the time for the dependent variable value u1,0, use the time value 'timevar'+'timestep' instead of 'timevar'.

  

As a summary example, consider the use of a backward time backward space discretization of the PDE ut+uxsinxt as a numerical boundary condition for the right boundary. You can obtain the discretizations of the derivatives as ut=u1,nu0,nk, and ux=u1,nu1,n1h. Because the expansion point of the discretization is at t+k,xn, replace the time and space variables in the discrete equation with these values. Hence, the specification of this numerical boundary condition is numericalbcs={u[1,n]u[0,n]k+ux=u[1,n]u[1,n1]hsint+kxn,timestep=k,spacestep=h} 

  

Note: This condition can be specified using the method form as numericalbcs=BackwardTime1Spacebackward,n.

  

Numerical boundary conditions must be provided if needed. Otherwise, Maple returns an error.

• 

The startup=symbol, startupsteps=integer, and startupnumbc=set, list or expression arguments specify how to compute the additional stage required for two stage methods, such as Leapfrog and DuFortFrankel. Methods such as these require the solution values at the current and prior time step to compute the solution at a future time step. This is an issue in the first step of the time integration of the PDE, as only values at one time step are known (that is, the initial condition of the problem).

  

The startup argument can take two forms, a method specified form, or a function specified form. For the method specified form, the argument must be specified as startup=method, where method is any of the one stage methods available for use with numerical pdsolve. For the function specified form, the argument must be specified as startup=expression, where expression is any fully specified function of the time and space variables of the problem. If no startup argument is provided, the method form is used with the default Theta scheme.

  

The startupsteps argument (default value is 1) improves the accuracy of the computed solution if the startup method is of lower accuracy than the two stage method. It specifies one greater than the number of doubling steps used to compute the additional stage required by the main method, and is best described through an example.

  

Consider a PDE where the Leapfrog method is to be used as the primary method, and the Euler method is to be used as the startup method.

  

* If startupsteps=1, then for the current step size k, the Euler method is used to compute the solution value at t0+k, which is then used as the required additional stage.

  

* If startupsteps=2, then the Euler method is used to compute the solution value at t0+12k, and the Leapfrog method is used to compute the solution value at t0+k, which is then used as the required additional stage.

  

* If startupsteps=3, then the Euler method is used to compute the solution value at t0+14k, and the Leapfrog method is used to compute the solution value at t0+12k, then at t0+k.

  

* In general, for startupsteps=n, the Euler method is used to compute the solution value at t0+k2n1, then the Leapfrog scheme is used to compute the solution value n1 times at t0+k2n2,t0+k2n3,...,t0+k2,t0+k. The value at t0+k is used as the required additional stage.

  

This approach allows lower accuracy methods to be used as startup methods with little or no accuracy loss.

  

The startupnumbc argument specifies the numerical boundary conditions to use for the startup scheme. By default, pdsolve first attempts to obtain the startup solution using the startup method and the same numerical boundary conditions as the primary method. If this fails, pdsolve attempts to obtain the startup solution using the startup method with no numerical boundary conditions. This option is provided to cover cases where neither of these approaches are sufficient. For example, if the primary method requires two numerical boundary conditions, and the startup method requires only one, this approach fails, and startupnumbc must be used. Note that the specification of startupnumbc with the incorrect number of conditions, or use of the option if it is not needed, results in an error.

Examples

Basic one-way wave equation with boundary condition on the left using the ForwardTime1Space[backward] method.

PDE1tux,t=1xux,t2

PDE1:=tux,t=12xux,t

(1)

IBC1ux,0=sinπx,u0,t=sinπt2

IBC1:=u0,t=sin12πt,ux,0=sinπx

(2)

smod1pdsolvePDE1,IBC1,numeric,time=t,range=0..1,method=ForwardTime1Spacebackward

smod1:=moduleexportplot,plot3d,animate,value,settings;...end module

(3)

The exact solution to this problem is known. Obtain an error function at t=1.25

esol1sinπxt2

esol1:=sinπx12t

(4)

errfuncsmod1:-valueux,tesol1,t=1.25,output=listprocedure

errfunc:=x=procx...end proc,t=1.25,ux,tsinπx12t=procx...end proc

(5)

errfuncrhserrfunc3

errfunc:=procx...end proc

(6)

Compute the maxnorm error over the interval.

maxerrmaxseqerrfunci100,i=0..100

maxerr:=0.0299077658092643

(7)

Adjust half the step sizes and check that the error halves.

smod1:-settingstimestep=140,spacestep=140;errfunc2smod1:-valueux,tesol1,t=1.25,output=listprocedure

errfunc2:=x=procx...end proc,t=1.25,ux,tsinπx12t=procx...end proc

(8)

errfunc2rhserrfunc23

errfunc2:=procx...end proc

(9)

maxerr2maxseqerrfunc2i100,i=0..100

maxerr2:=0.0156768632175617

(10)

maxerrmaxerr2

1.90776467168258

(11)

Use the CrankNicholson method on an inhomogeneous one-way wave equation. This requires a numerical boundary condition.

PDE2tux,t+1ⅇt10xux,t10=cosπxⅇ1t10πⅇ1t105

PDE2:=tux,t+110ⅇ110txux,t=15cosπxⅇ110tπⅇ110t

(12)

IBC2ux,0=sinπx,u0,t=u2,t

IBC2:=u0,t=u2,t,ux,0=sinπx

(13)

As a numerical boundary condition, choose a Box discretization of the PDE at the right boundary using the first interior point.

discstux,t=u1,nu0,n+u1,n1u0,n12k,xux,t=u1,nu1,n1+u0,nu0,n12h

discs:=tux,t=12u1,nu0,n+u1,n1u0,n1k,xux,t=12u1,nu1,n1+u0,nu0,n1h

(14)

nbcPDE2t=t+k2,x=xnh2|PDE2t=t+k2,x=xnh2,timestep=k,spacestep=h

nbc:=spacestep=h,timestep=k,12u1,nu0,n+u1,n1u0,n1k+120ⅇ110t120ku1,nu1,n1+u0,nu0,n1h=15cosπxn12hⅇ110t120kπⅇ110t120k

(15)

Note: You do not need to specify time and range. They are implicitly defined using the periodic boundary condition.

smod2pdsolvePDE2,IBC2,type=numeric,numericalbcs=nbc,method=CrankNicholson

smod2:=moduleexportplot,plot3d,animate,value,settings;...end module

(16)

Again the exact solution of this problem is known. Examine the error.

esol2sinπxⅇ1t10

esol2:=sinπxⅇ110t

(17)

errfuncrhssmod2:-valueux,tesol2,t=1,output=listprocedure3

errfunc:=procx...end proc

(18)

maxerrmaxseqerrfunci50,i=0..100

maxerr:=0.00486456261189167

(19)

And with half the step size:

smod2:-settingstimestep=140,spacestep=140;errfunc2rhssmod2:-valueux,tesol2,t=1,output=listprocedure3

errfunc2:=procx...end proc

(20)

maxerr2maxseqerrfunc2i50,i=0..100

maxerr2:=0.000305388741516921

(21)

maxerrmaxerr2

15.9290830032846

(22)

The improvement is better than expected.

The Box scheme on the right boundary (without explicitly deriving the scheme) can be specified by using numericalbcs=[Box,n].

smod2bpdsolvePDE2,IBC2,numeric,numericalbcs=Box,n,method=CrankNicholson

smod2b:=moduleexportplot,plot3d,animate,value,settings;...end module

(23)

errfuncrhssmod2b:-valueux,tesol2,t=1,output=listprocedure3

errfunc:=procx...end proc

(24)

maxerrmaxseqerrfunci50,i=0..100

maxerr:=0.00486456261189167

(25)

As an example of a two stage scheme, apply the DuFortFrankel method to a convection/diffusion equation with insulated boundary conditions.

PDE3tux,t=12x2ux,t20+1xux,t2

PDE3:=tux,t=1202x2ux,t+12xux,t

(26)

IBC3ux,0=cosπx2,D[1]u12,t=0,D[1]u12,t=0

IBC3:=ux,0=cosπx2,D1u12,t=0,D1u12,t=0

(27)

smod3pdsolvePDE3,IBC3,type=numeric,method=DuFortFrankel,startup=Euler,timestep=150

smod3:=moduleexportplot,plot3d,animate,value,settings;...end module

(28)

From this solution a series of plots at different times can be generated and displayed in the same plot.

 

p1smod3:-plott=0,color=red:p2smod3:-plott=16,color=maroon:p3smod3:-plott=13,color=blue:p4smod3:-plott=23,color=green:p5smod3:-plott=1,color=yellow:plots[display]p1,p2,p3,p4,p5

See Also

diff

eval

pdsolve

pdsolve/numeric

pdsolve/numeric/methods

plot

plot3d

plots[animate]

plots[display]

seq

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam