 numeric error control - Maple Help

pdsolve/numeric/errorcontrol

find a numerical solution of PDE with an error approximation, or within a certain tolerance Calling Sequence pdsolve(PDE, conditions, numeric, meth, options) Parameters

 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=${\mathrm{\theta }}_{v}$ options - (optional) equations of the form keyword = value where keyword is one of 'errorest, 'errortype', 'abstol', mintimestep, and maxtimestep Description

 • 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 $\mathrm{meth}={\mathrm{\theta }}_{v}$) gives the relative time value of the point used for the approximation as a ratio of the total step. The default is $\frac{1}{2}$, 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. Options

 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, $\mathrm{plot3d}$ and value methods of the returned module.
 Quite simply, for a dependent variable $u\left(x,t\right)$, the time error can be specified as $\mathrm{terr}\left(u\left(x,t\right)\right)$, the spatial error can be specified as $\mathrm{serr}\left(u\left(x,t\right)\right)$, and the total error (just the sum of the time and space errors) can be specified as $\mathrm{err}\left(u\left(x,t\right)\right)$.
 The additional shortcuts terr(), $\mathrm{serr}\left(\right)$, 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. Details

 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 $\mathrm{O}\left({h}^{2}\right)$ 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 $\mathrm{O}\left({k}^{2}\right)$ or $\mathrm{O}\left(k\right)$ 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=\mathrm{t1}$ can result in a large change in the solution at a later time $t=\mathrm{t2}$. Examples

Simple one-way wave equation with error estimates. Comparison at two sets of step sizes.

 > $\mathrm{PDE}≔\mathrm{diff}\left(u\left(x,t\right),t\right)=-\mathrm{diff}\left(u\left(x,t\right),x\right)$
 ${\mathrm{PDE}}{≔}\frac{{\partial }}{{\partial }{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right){=}{-}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right)$ (1)
 > $\mathrm{IBC}≔\left\{u\left(0,t\right)=-\mathrm{sin}\left(2\mathrm{\pi }t\right),u\left(x,0\right)=\mathrm{sin}\left(2\mathrm{\pi }x\right)\right\}$
 ${\mathrm{IBC}}{≔}\left\{{u}{}\left({0}{,}{t}\right){=}{-}{\mathrm{sin}}{}\left({2}{}{\mathrm{\pi }}{}{t}\right){,}{u}{}\left({x}{,}{0}\right){=}{\mathrm{sin}}{}\left({2}{}{\mathrm{\pi }}{}{x}\right)\right\}$ (2)
 > $\mathrm{pds}≔\mathrm{pdsolve}\left(\mathrm{PDE},\mathrm{IBC},\mathrm{numeric},\mathrm{time}=t,\mathrm{range}=0..1,\mathrm{errorest}=\mathrm{true},\mathrm{timestep}=\frac{1}{16},\mathrm{spacestep}=\frac{1}{16}\right)$
 ${\mathrm{pds}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{plot}}{,}{\mathrm{plot3d}}{,}{\mathrm{animate}}{,}{\mathrm{value}}{,}{\mathrm{settings}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (3)
 > $\mathrm{pds}:-\mathrm{plot}\left(\left[u\left(x,t\right),\left[u\left(x,t\right)+\mathrm{err}\left(u\left(x,t\right)\right),\mathrm{color}=\mathrm{grey}\right],\left[u\left(x,t\right)-\mathrm{err}\left(u\left(x,t\right)\right),\mathrm{color}=\mathrm{grey}\right]\right],t=5\right)$ > $\mathrm{pds}:-\mathrm{settings}\left(\mathrm{timestep}=\frac{1}{32},\mathrm{spacestep}=\frac{1}{32}\right)$
 > $\mathrm{pds}:-\mathrm{plot}\left(\left[u\left(x,t\right),\left[u\left(x,t\right)+\mathrm{err}\left(u\left(x,t\right)\right),\mathrm{color}=\mathrm{grey}\right],\left[u\left(x,t\right)-\mathrm{err}\left(u\left(x,t\right)\right),\mathrm{color}=\mathrm{grey}\right]\right],t=5\right)$ Comparison of error estimate and true error (for this problem the exact solution is known).

 > $\mathrm{esol}≔\mathrm{sin}\left(2\mathrm{\pi }\left(x-t\right)\right)$
 ${\mathrm{esol}}{≔}{\mathrm{sin}}{}\left({2}{}{\mathrm{\pi }}{}\left({x}{-}{t}\right)\right)$ (4)
 > $\mathrm{pds}:-\mathrm{plot}\left(\left[u\left(x,t\right)-\mathrm{sin}\left(2\mathrm{\pi }\left(x-t\right)\right),\left[\mathrm{err}\left(u\left(x,t\right)\right),\mathrm{color}=\mathrm{grey}\right]\right],t=5\right)$ In this case, the error estimate is somewhat pessimistic.

A nonlinear PDE with a forming shock layer using error control

 > $\mathrm{PDE}≔\mathrm{diff}\left(u\left(x,t\right),t\right)=-\mathrm{diff}\left(u\left(x,t\right),x\right)u\left(x,t\right)$
 ${\mathrm{PDE}}{≔}\frac{{\partial }}{{\partial }{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right){=}{-}\left(\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right)\right){}{u}{}\left({x}{,}{t}\right)$ (5)
 > $\mathrm{IBC}≔\left\{u\left(0,t\right)=\frac{\mathrm{exp}\left(-4\right)}{2}\mathrm{exp}\left(-8\mathrm{exp}\left(-4\right)t\right),u\left(x,0\right)=\frac{\mathrm{exp}\left(-16{\left(x-\frac{1}{2}\right)}^{2}\right)}{2}\right\}$
 ${\mathrm{IBC}}{≔}\left\{{u}{}\left({0}{,}{t}\right){=}\frac{{{ⅇ}}^{{-4}}{}{{ⅇ}}^{{-}{8}{}{{ⅇ}}^{{-4}}{}{t}}}{{2}}{,}{u}{}\left({x}{,}{0}\right){=}\frac{{{ⅇ}}^{{-}{16}{}{\left({x}{-}\frac{{1}}{{2}}\right)}^{{2}}}}{{2}}\right\}$ (6)
 > $\mathrm{pds}≔\mathrm{pdsolve}\left(\mathrm{PDE},\mathrm{IBC},\mathrm{numeric},\mathrm{time}=t,\mathrm{range}=0..2,\mathrm{spacestep}=\frac{1}{128},\mathrm{timestep}=\frac{1}{64},\mathrm{abstol}=0.01\right)$
 ${\mathrm{pds}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{plot}}{,}{\mathrm{plot3d}}{,}{\mathrm{animate}}{,}{\mathrm{value}}{,}{\mathrm{settings}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (7)
 > $\mathrm{pds}:-\mathrm{plot}\left(t=0.5\right)$

You must decrease the space step size. A little experimentation shows that you can get to t=0.5 with:

 > $\mathrm{pds}:-\mathrm{settings}\left(\mathrm{spacestep}=\frac{1}{1024}\right):$$\mathrm{pds}:-\mathrm{plot}\left(t=0.5,\mathrm{numpoints}=256\right)$ And at that time, the spatial error looks like

 > $\mathrm{pds}:-\mathrm{plot}\left(\mathrm{serr}\left(\right),t=0.5,\mathrm{numpoints}=256\right)$ 