pdsolve/numeric/errorcontrol
find a numerical solution of PDE with an error approximation, or within a certain tolerance
Calling Sequence
Parameters
Description
Options
Details
Examples
pdsolve(PDE, conditions, numeric, meth, options)
PDE
-
single or set or list of time-dependent partial differential equations in two independent variables
conditions
set or list of initial and boundary conditions
numeric
keyword indicating a numerical solution is to be obtained
meth
(optional) method description of the form method=theta or method=θv
options
(optional) equations of the form keyword = value where keyword is one of 'errorest, 'errortype', 'abstol', mintimestep, and maxtimestep
This page describes options and capabilities specific to use of error estimation and error control with numeric PDE solution.
Solution of PDE with error estimation is restricted to the theta family of schemes, where the index of the theta (the v in meth=θv) gives the relative time value of the point used for the approximation as a ratio of the total step. The default is 12, which gives second order accuracy and fair stability. The value 0 represents an explicit method, while the value 1 is a fully implicit method with the best stability (in general).
There are two main operating modes for PDE solution with error estimation. The first simply provides viewable information on the approximate errors of the solution, while the second provides an automatic control mechanism, whereby the time step is adjusted to keep the error per unit step within a specified bound.
Information on the error estimation process is provided in Details below.
The relevant options are as follows.
'errorest'= boolean
Specifies whether error estimates are to be computed. If error control is in use (that is, 'abstol' was specified), then this is true automatically.
'errortype'= keyword
Specifies the form of the error estimates to be viewed.
- The option 'accumulated' (the default) provides an error estimate at any given time as the sum of the error estimates for all prior time steps from the start of the problem. This option is most useful in obtaining solutions with approximate error bounds.
- The option 'singlestep' provides a local error estimate for the current step. This option is most useful in determining where the local error in a solution is most problematic.
'abstol'=numeric
In addition to providing an upper bound on the local estimate of the time and spatial errors per unit step, use of this option indicates that time adaptation should be used.
Note: This upper bound is used independently on the two error estimators, meaning that it is used to control errors due to the spatial discretization and errors due to the time discretization separately. If an overall total error bound is required, then 'abstol' should be specified as half the desired value.
Another consideration here is that only the time step can be adjusted to reduce the error (the spatial mesh is fixed), so if the spatial error estimate exceeds the tolerance, then the integration halts with an appropriate error message.
'mintimestep'=numeric
This option provides an absolute minimum value for the time step taken to compute a requested solution. By default, the value is 1/1000th the initial time step (either the default, or specified by the timestep value).
'maxtimestep'=numeric
This option provides an absolute maximum value for the time step taken to compute a requested solution. By default, the value is 100 times the initial time step (either the default, or specified by the timestep value).
Error estimates can be used in the dependent variable specification of the plot, animate, plot3d and value methods of the returned module.
Quite simply, for a dependent variable u⁡x,t, the time error can be specified as terr⁡u⁡x,t, the spatial error can be specified as serr⁡u⁡x,t, and the total error (just the sum of the time and space errors) can be specified as err⁡u⁡x,t.
The additional shortcuts terr(), serr⁡, and err() are provided to display the maximum time, space, or total error for all solution components. This is only useful if the input PDE is higher than first order, or the input PDE is a system.
The error estimators used, in both the visual error estimates and the error control, are simply local truncation error estimates for the PDE or PDE system. Essentially, what is done is to compute the solution on a different mesh, and use the difference between solutions to estimate the error.
The spatial error estimate is obtained by comparing the solution to another computed on a coarser spatial mesh, but for the same time step. This gives an estimate of the O⁡h2 local truncation error (where h is the mesh spacing for the spatial variable).
The time error estimate is obtained by comparing the solution to another computed with a larger time step, but the same spatial mesh. This gives an estimate of the O⁡k2 or O⁡k local truncation error (where k is the time step).
It is important to note that these estimates are local, so they do not account for situations where a small perturbation in the solution at a time t=t1 can result in a large change in the solution at a later time t=t2.
Simple one-way wave equation with error estimates. Comparison at two sets of step sizes.
PDE≔diff⁡u⁡x,t,t=−diff⁡u⁡x,t,x
PDE≔∂∂tu⁡x,t=−∂∂xu⁡x,t
IBC≔u⁡0,t=−sin⁡2⁢π⁢t,u⁡x,0=sin⁡2⁢π⁢x
pds≔pdsolve⁡PDE,IBC,numeric,time=t,range=0..1,errorest=true,timestep=116,spacestep=116
pds ≔ moduleexportplot,plot3d,animate,value,settings;...end module
pds:-plot⁡u⁡x,t,u⁡x,t+err⁡u⁡x,t,color=grey,u⁡x,t−err⁡u⁡x,t,color=grey,t=5
pds:-settings⁡timestep=132,spacestep=132
Comparison of error estimate and true error (for this problem the exact solution is known).
esol≔sin⁡2⁢π⁢x−t
pds:-plot⁡u⁡x,t−sin⁡2⁢π⁢x−t,err⁡u⁡x,t,color=grey,t=5
In this case, the error estimate is somewhat pessimistic.
A nonlinear PDE with a forming shock layer using error control
PDE≔diff⁡u⁡x,t,t=−diff⁡u⁡x,t,x⁢u⁡x,t
PDE≔∂∂tu⁡x,t=−∂∂xu⁡x,t⁢u⁡x,t
IBC≔u⁡0,t=exp⁡−42⁢exp⁡−8⁢exp⁡−4⁢t,u⁡x,0=exp⁡−16⁢x−1222
IBC≔u⁡0,t=ⅇ−4⁢ⅇ−8⁢ⅇ−4⁢t2,u⁡x,0=ⅇ−16⁢x−1222
pds≔pdsolve⁡PDE,IBC,numeric,time=t,range=0..2,spacestep=1128,timestep=164,abstol=0.01
pds:-plot⁡t=0.5
Error, (in `pdsolve/numeric/plot`) unable to compute solution for t>.383973957308842: spatial error estimate exceeds tolerance. consider decreasing 'spacestep'
You must decrease the space step size. A little experimentation shows that you can get to t=0.5 with:
pds:-settings⁡spacestep=11024:pds:-plot⁡t=0.5,numpoints=256
And at that time, the spatial error looks like
pds:-plot⁡serr⁡,t=0.5,numpoints=256
See Also
pdsolve
pdsolve/numeric
plot
plot3d
plots[animate]
Download Help Document