hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_pde_1d_parab_coll (d03pd)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_pde_1d_parab_coll (d03pd) integrates a system of linear or nonlinear parabolic partial differential equations (PDEs) in one space variable. The spatial discretization is performed using a Chebyshev C0 collocation method, and the method of lines is employed to reduce the PDEs to a system of ordinary differential equations (ODEs). The resulting system is solved using a backward differentiation formula method.

Syntax

[ts, u, x, rsave, isave, ind, user, cwsav, lwsav, iwsav, rwsav, ifail] = d03pd(m, ts, tout, pdedef, bndary, u, xbkpts, npoly, uinit, acc, rsave, isave, itask, itrace, ind, cwsav, lwsav, iwsav, rwsav, 'npde', npde, 'nbkpts', nbkpts, 'npts', npts, 'user', user)
[ts, u, x, rsave, isave, ind, user, cwsav, lwsav, iwsav, rwsav, ifail] = nag_pde_1d_parab_coll(m, ts, tout, pdedef, bndary, u, xbkpts, npoly, uinit, acc, rsave, isave, itask, itrace, ind, cwsav, lwsav, iwsav, rwsav, 'npde', npde, 'nbkpts', nbkpts, 'npts', npts, 'user', user)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: lrsave and lisave were removed from the interface

Description

nag_pde_1d_parab_coll (d03pd) integrates the system of parabolic equations:
j=1npdePi,j Uj t +Qi=x-m x xmRi,  i=1,2,,npde,  axb,tt0, (1)
where Pi,j, Qi and Ri depend on x, t, U, Ux and the vector U is the set of solution values
U x,t = U 1 x,t ,, U npde x,t T , (2)
and the vector Ux is its partial derivative with respect to x. Note that Pi,j, Qi and Ri must not depend on U t .
The integration in time is from t0 to tout, over the space interval axb, where a=x1 and b=xnbkpts are the leftmost and rightmost of a user-defined set of break-points x1,x2,,xnbkpts. The coordinate system in space is defined by the value of m; m=0 for Cartesian coordinates, m=1 for cylindrical polar coordinates and m=2 for spherical polar coordinates.
The system is defined by the functions Pi,j, Qi and Ri which must be specified in pdedef.
The initial values of the functions Ux,t must be given at t=t0, and must be specified in uinit.
The functions Ri, for i=1,2,,npde, which may be thought of as fluxes, are also used in the definition of the boundary conditions for each equation. The boundary conditions must have the form
βix,tRix,t,U,Ux=γix,t,U,Ux,  i=1,2,,npde, (3)
where x=a or x=b.
The boundary conditions must be specified in bndary. Thus, the problem is subject to the following restrictions:
(i) t0<tout, so that integration is in the forward direction;
(ii) Pi,j, Qi and the flux Ri must not depend on any time derivatives;
(iii) the evaluation of the functions Pi,j, Qi and Ri is done at both the break-points and internally selected points for each element in turn, that is Pi,j, Qi and Ri are evaluated twice at each break-point. Any discontinuities in these functions must therefore be at one or more of the break-points x1,x2,,xnbkpts;
(iv) at least one of the functions Pi,j must be nonzero so that there is a time derivative present in the problem;
(v) if m>0 and x1=0.0, which is the left boundary point, then it must be ensured that the PDE solution is bounded at this point. This can be done by either specifying the solution at x=0.0 or by specifying a zero flux there, that is βi=1.0 and γi=0.0. See also Further Comments.
The parabolic equations are approximated by a system of ODEs in time for the values of Ui at the mesh points. This ODE system is obtained by approximating the PDE solution between each pair of break-points by a Chebyshev polynomial of degree npoly. The interval between each pair of break-points is treated by nag_pde_1d_parab_coll (d03pd) as an element, and on this element, a polynomial and its space and time derivatives are made to satisfy the system of PDEs at npoly-1 spatial points, which are chosen internally by the code and the break-points. In the case of just one element, the break-points are the boundaries. The user-defined break-points and the internally selected points together define the mesh. The smallest value that npoly can take is one, in which case, the solution is approximated by piecewise linear polynomials between consecutive break-points and the method is similar to an ordinary finite element method.
In total there are nbkpts-1×npoly+1 mesh points in the spatial direction, and npde×nbkpts-1×npoly+1 ODEs in the time direction; one ODE at each break-point for each PDE component and (npoly-1) ODEs for each PDE component between each pair of break-points. The system is then integrated forwards in time using a backward differentiation formula method.

References

Berzins M (1990) Developments in the NAG Library software for parabolic equations Scientific Software Systems (eds J C Mason and M G Cox) 59–72 Chapman and Hall
Berzins M and Dew P M (1991) Algorithm 690: Chebyshev polynomial software for elliptic-parabolic systems of PDEs ACM Trans. Math. Software 17 178–206
Zaturska N B, Drazin P G and Banks W H H (1988) On the flow of a viscous fluid driven along a channel by a suction at porous walls Fluid Dynamics Research 4

Parameters

Compulsory Input Parameters

1:     m int64int32nag_int scalar
The coordinate system used:
m=0
Indicates Cartesian coordinates.
m=1
Indicates cylindrical polar coordinates.
m=2
Indicates spherical polar coordinates.
Constraint: m=0, 1 or 2.
2:     ts – double scalar
The initial value of the independent variable t.
Constraint: ts<tout.
3:     tout – double scalar
The final value of t to which the integration is to be carried out.
4:     pdedef – function handle or string containing name of m-file
pdedef must compute the values of the functions Pi,j, Qi and Ri which define the system of PDEs. The functions may depend on x, t, U and Ux and must be evaluated at a set of points.
[p, q, r, ires, user] = pdedef(npde, t, x, nptl, u, ux, ires, user)

Input Parameters

1:     npde int64int32nag_int scalar
The number of PDEs in the system.
2:     t – double scalar
The current value of the independent variable t.
3:     xnptl – double array
Contains a set of mesh points at which Pi,j, Qi and Ri are to be evaluated. x1 and xnptl contain successive user-supplied break-points and the elements of the array will satisfy x1<x2<<xnptl.
4:     nptl int64int32nag_int scalar
The number of points at which evaluations are required (the value of npoly+1).
5:     unpdenptl – double array
uij contains the value of the component Uix,t where x=xj, for i=1,2,,npde and j=1,2,,nptl.
6:     uxnpdenptl – double array
uxij contains the value of the component Uix,t x  where x=xj, for i=1,2,,npde and j=1,2,,nptl.
7:     ires int64int32nag_int scalar
Set to -1​ or ​1.
8:     user – Any MATLAB object
pdedef is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     pnpdenpdenptl – double array
pijk must be set to the value of Pi,jx,t,U,Ux where x=xk, for i=1,2,,npde, j=1,2,,npde and k=1,2,,nptl.
2:     qnpdenptl – double array
qij must be set to the value of Qix,t,U,Ux where x=xj, for i=1,2,,npde and j=1,2,,nptl.
3:     rnpdenptl – double array
rij must be set to the value of Rix,t,U,Ux where x=xj, for i=1,2,,npde and j=1,2,,nptl.
4:     ires int64int32nag_int scalar
Should usually remain unchanged. However, you may set ires to force the integration function to take certain actions as described below:
ires=2
Indicates to the integrator that control should be passed back immediately to the calling (sub)routine with the error indicator set to ifail=6.
ires=3
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set ires=3 when a physically meaningless input or output value has been generated. If you consecutively set ires=3, then nag_pde_1d_parab_coll (d03pd) returns to the calling function with the error indicator set to ifail=4.
5:     user – Any MATLAB object
5:     bndary – function handle or string containing name of m-file
bndary must compute the functions βi and γi which define the boundary conditions as in equation (3).
[beta, gamma, ires, user] = bndary(npde, t, u, ux, ibnd, ires, user)

Input Parameters

1:     npde int64int32nag_int scalar
The number of PDEs in the system.
2:     t – double scalar
The current value of the independent variable t.
3:     unpde – double array
ui contains the value of the component Uix,t at the boundary specified by ibnd, for i=1,2,,npde.
4:     uxnpde – double array
uxi contains the value of the component Uix,t x  at the boundary specified by ibnd, for i=1,2,,npde.
5:     ibnd int64int32nag_int scalar
Specifies which boundary conditions are to be evaluated.
ibnd=0
bndary must set up the coefficients of the left-hand boundary, x=a.
ibnd0
bndary must set up the coefficients of the right-hand boundary, x=b.
6:     ires int64int32nag_int scalar
Set to -1​ or ​1.
7:     user – Any MATLAB object
bndary is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     betanpde – double array
betai must be set to the value of βix,t at the boundary specified by ibnd, for i=1,2,,npde.
2:     gammanpde – double array
gammai must be set to the value of γix,t,U,Ux at the boundary specified by ibnd, for i=1,2,,npde.
3:     ires int64int32nag_int scalar
Should usually remain unchanged. However, you may set ires to force the integration function to take certain actions as described below:
ires=2
Indicates to the integrator that control should be passed back immediately to the calling (sub)routine with the error indicator set to ifail=6.
ires=3
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set ires=3 when a physically meaningless input or output value has been generated. If you consecutively set ires=3, then nag_pde_1d_parab_coll (d03pd) returns to the calling function with the error indicator set to ifail=4.
4:     user – Any MATLAB object
6:     unpdenpts – double array
If ind=1 the value of u must be unchanged from the previous call.
7:     xbkptsnbkpts – double array
The values of the break-points in the space direction. xbkpts1 must specify the left-hand boundary, a, and xbkptsnbkpts must specify the right-hand boundary, b.
Constraint: xbkpts1<xbkpts2<<xbkptsnbkpts.
8:     npoly int64int32nag_int scalar
The degree of the Chebyshev polynomial to be used in approximating the PDE solution between each pair of break-points.
Constraint: 1npoly49.
9:     uinit – function handle or string containing name of m-file
uinit must compute the initial values of the PDE components Uixj,t0, for i=1,2,,npde and j=1,2,,npts.
[u, user] = uinit(npde, npts, x, user)

Input Parameters

1:     npde int64int32nag_int scalar
The number of PDEs in the system.
2:     npts int64int32nag_int scalar
The number of mesh points in the interval a,b.
3:     xnpts – double array
xj, contains the values of the jth mesh point, for j=1,2,,npts.
4:     user – Any MATLAB object
uinit is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     unpdenpts – double array
uij must be set to the initial value Uixj,t0, for i=1,2,,npde and j=1,2,,npts.
2:     user – Any MATLAB object
10:   acc – double scalar
A positive quantity for controlling the local error estimate in the time integration. If Ei,j is the estimated error for Ui at the jth mesh point, the error test is:
Ei,j=acc×1.0+uij.  
Constraint: acc>0.0.
11:   rsavelrsave – double array
lrsave, the dimension of the array, must satisfy the constraint lrsave11×npde×npts+50+nwkres+lenode.
If ind=0, rsave need not be set on entry.
If ind=1, rsave must be unchanged from the previous call to the function because it contains required information about the iteration.
12:   isavelisave int64int32nag_int array
lisave, the dimension of the array, must satisfy the constraint lisavenpde×npts+24.
If ind=0, isave need not be set on entry.
If ind=1, isave must be unchanged from the previous call to the function because it contains required information about the iteration. In particular:
isave1
Contains the number of steps taken in time.
isave2
Contains the number of residual evaluations of the resulting ODE system used. One such evaluation involves computing the PDE functions at all the mesh points, as well as one evaluation of the functions in the boundary conditions.
isave3
Contains the number of Jacobian evaluations performed by the time integrator.
isave4
Contains the order of the last backward differentiation formula method used.
isave5
Contains the number of Newton iterations performed by the time integrator. Each iteration involves an ODE residual evaluation followed by a back-substitution using the LU decomposition of the Jacobian matrix.
13:   itask int64int32nag_int scalar
Specifies the task to be performed by the ODE integrator.
itask=1
Normal computation of output values u at t=tout.
itask=2
One step and return.
itask=3
Stop at first internal integration point at or beyond t=tout.
Constraint: itask=1, 2 or 3.
14:   itrace int64int32nag_int scalar
The level of trace information required from nag_pde_1d_parab_coll (d03pd) and the underlying ODE solver. itrace may take the value -1, 0, 1, 2 or 3.
itrace=-1
No output is generated.
itrace=0
Only warning messages from the PDE solver are printed on the current error message unit (see nag_file_set_unit_error (x04aa)).
itrace>0
Output from the underlying ODE solver is printed on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)). This output contains details of Jacobian entries, the nonlinear iteration and the time integration during the computation of the ODE system.
If itrace<-1, then -1 is assumed and similarly if itrace>3, then 3 is assumed.
The advisory messages are given in greater detail as itrace increases. You are advised to set itrace=0, unless you are experienced with Sub-chapter D02M–N.
15:   ind int64int32nag_int scalar
Indicates whether this is a continuation call or a new integration.
ind=0
Starts or restarts the integration in time.
ind=1
Continues the integration after an earlier exit from the function. In this case, only the arguments tout and ifail should be reset between calls to nag_pde_1d_parab_coll (d03pd).
Constraint: ind=0 or 1.
16:   cwsav10 – cell array of strings
17:   lwsav100 – logical array
18:   iwsav505 int64int32nag_int array
19:   rwsav1100 – double array

Optional Input Parameters

1:     npde int64int32nag_int scalar
Default: the first dimension of the array u.
The number of PDEs in the system to be solved.
Constraint: npde1.
2:     nbkpts int64int32nag_int scalar
Default: the dimension of the array xbkpts.
The number of break-points in the interval a,b.
Constraint: nbkpts2.
3:     npts int64int32nag_int scalar
Default: the second dimension of the array u.
The number of mesh points in the interval a,b.
Constraint: npts=nbkpts-1×npoly+1.
4:     user – Any MATLAB object
user is not used by nag_pde_1d_parab_coll (d03pd), but is passed to pdedef, bndary and uinit. Note that for large objects it may be more efficient to use a global variable which is accessible from the m-files than to use user.

Output Parameters

1:     ts – double scalar
The value of t corresponding to the solution values in u. Normally ts=tout.
2:     unpdenpts – double array
uij will contain the computed solution at t=ts.
3:     xnpts – double array
The mesh points chosen by nag_pde_1d_parab_coll (d03pd) in the spatial direction. The values of x will satisfy x1<x2<<xnpts.
4:     rsavelrsave – double array
If ind=1, rsave must be unchanged from the previous call to the function because it contains required information about the iteration.
5:     isavelisave int64int32nag_int array
If ind=1, isave must be unchanged from the previous call to the function because it contains required information about the iteration. In particular:
isave1
Contains the number of steps taken in time.
isave2
Contains the number of residual evaluations of the resulting ODE system used. One such evaluation involves computing the PDE functions at all the mesh points, as well as one evaluation of the functions in the boundary conditions.
isave3
Contains the number of Jacobian evaluations performed by the time integrator.
isave4
Contains the order of the last backward differentiation formula method used.
isave5
Contains the number of Newton iterations performed by the time integrator. Each iteration involves an ODE residual evaluation followed by a back-substitution using the LU decomposition of the Jacobian matrix.
6:     ind int64int32nag_int scalar
ind=1.
7:     user – Any MATLAB object
8:     cwsav10 – cell array of strings
9:     lwsav100 – logical array
10:   iwsav505 int64int32nag_int array
11:   rwsav1100 – double array
12:   ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,toutts,
ortout-ts is too small,
oritask1, 2 or 3,
orm0, 1 or 2,
orm>0 and xbkpts1<0.0,
ornpde<1,
ornbkpts<2,
ornpoly<1 or npoly>49,
ornptsnbkpts-1×npoly+1,
oracc0.0,
orind0 or 1,
orbreak-points xbkptsi are not ordered,
orlrsave is too small,
orlisave is too small.
W  ifail=2
The underlying ODE solver cannot make any further progress across the integration range from the current point t=ts with the supplied value of acc. The components of u contain the computed values at the current point t=ts.
W  ifail=3
In the underlying ODE solver, there were repeated errors or corrector convergence test failures on an attempted step, before completing the requested task. The problem may have a singularity or acc is too small for the integration to continue. Integration was successful as far as t=ts.
   ifail=4
In setting up the ODE system, the internal initialization function was unable to initialize the derivative of the ODE system. This could be due to the fact that ires was repeatedly set to 3 in at least pdedef or bndary, when the residual in the underlying ODE solver was being evaluated.
   ifail=5
In solving the ODE system, a singular Jacobian has been encountered. You should check your problem formulation.
W  ifail=6
When evaluating the residual in solving the ODE system, ires was set to 2 in at least pdedef or bndary. Integration was successful as far as t=ts.
   ifail=7
The value of acc is so small that the function is unable to start the integration in time.
   ifail=8
In one of pdedef or bndary, ires was set to an invalid value.
   ifail=9 (nag_ode_ivp_stiff_imp_revcom (d02nn))
A serious error has occurred in an internal call to the specified function. Check the problem specification and all arguments and array dimensions. Setting itrace=1 may provide more information. If the problem persists, contact NAG.
W  ifail=10
The required task has been completed, but it is estimated that a small change in acc is unlikely to produce any change in the computed solution. (Only applies when you are not operating in one step mode, that is when itask2.)
   ifail=11
An error occurred during Jacobian formulation of the ODE system (a more detailed error description may be directed to the current error message unit).
   ifail=12
Not applicable.
   ifail=13
Not applicable.
   ifail=14
The flux function Ri was detected as depending on time derivatives, which is not permissible.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

nag_pde_1d_parab_coll (d03pd) controls the accuracy of the integration in the time direction but not the accuracy of the approximation in space. The spatial accuracy depends on the degree of the polynomial approximation npoly, and on both the number of break-points and on their distribution in space. In the time integration only the local error over a single step is controlled and so the accuracy over a number of steps cannot be guaranteed. You should therefore test the effect of varying the accuracy argument, acc.

Further Comments

nag_pde_1d_parab_coll (d03pd) is designed to solve parabolic systems (possibly including elliptic equations) with second-order derivatives in space. The argument specification allows you to include equations with only first-order derivatives in the space direction but there is no guarantee that the method of integration will be satisfactory for such systems. The position and nature of the boundary conditions in particular are critical in defining a stable problem.
The time taken depends on the complexity of the parabolic system and on the accuracy requested.

Example

The problem consists of a fourth-order PDE which can be written as a pair of second-order elliptic-parabolic PDEs for U1x,t and U2x,t,
0= 2U1 x2 -U2 (4)
U2 t = 2U2 x2 +U2 U1 x -U1 U2 x (5)
where -1x1 and t0. The boundary conditions are given by
U1 x =0  and  U1=1  at ​x=-1,   and U1 x =0  and  U1=-1  at ​x=1.  
The initial conditions at t=0 are given by
U1=-sinπx2  and  U2=π24sinπx2.  
The absence of boundary conditions for U2x,t does not pose any difficulties provided that the derivative flux boundary conditions are assigned to the first PDE (4) which has the correct flux, U1 x . The conditions on U1x,t at the boundaries are assigned to the second PDE by setting β2=0.0 in equation (3) and placing the Dirichlet boundary conditions on U1x,t in the function γ2.
function d03pd_example


fprintf('d03pd example results\n\n');

% Solution of an elliptic-parabolic pair of PDEs
% (derived from a fourth-order PDE).

% Set values for problem parameters.
npde = 2;

% Number of points on interpolated mesh, number of break points.
intpts = 6;
nbkpts = 10;

% Order of Chebyshev polynomial.
npoly = int64(3);

npts   = (nbkpts-1)*npoly + 1;
lisave = npde*npts + 24;

% Define some arrays.
rsave   = zeros(4000, 1);
u       = zeros(npde, npts);
isave   = zeros(lisave, 1, 'int64');
lwsav   = false(100, 1);
iwsav   = zeros(505, 1, 'int64');
rwsav   = zeros(1100, 1);
cwsav   = {''; ''; ''; ''; ''; ''; ''; ''; ''; ''};
% Set up the points on the interpolation grid.
xinterp = [-1:0.4:1];


% Number of output points in time.
niter  = 20;

% Prepare to store plotting results.
tsav   = zeros(niter, 1);
usav   = zeros(2, niter, npts);
isav   = 0;

% Set the break points.
hx     = 2/(nbkpts-1);
xbkpts = [-1:hx:1];

% Set initial conditions.
m      = int64(0);
ts     = 0.0;
tout   = 0.1e-4;
acc    = 1.0e-4;
itask  = int64(1);
itrace = int64(0);
ind0   = int64(0);

alpha  = -log(tout)/(niter-1);

% Output algorithmic details and interpolation points.
fprintf('polynomial degree = %4d    no. of elements = %4d\n', npoly, nbkpts-1);
fprintf('accuracy requirement = %10.3e    number of points = %5d', acc, npts);
fprintf('\n\n t / x       ');
fprintf('%8.4f', xinterp);
fprintf('\n\n');

% Loop over exponentially increasing endpoints of integration 0.0001 --> 1. 
% Set itask = 1: normal computation of output values at t = tout.
for iter = 1:niter

  tout = exp(alpha*(iter - niter));

  % (re)start integration in time: ind0=0.
  [ts, u, x, rsave, isave, ind, user, cwsav, lwsav, iwsav, rwsav, ifail] = ...
  d03pd( ...
         m, ts, tout, @pdedef, ...
         @bndary, u, xbkpts, npoly, @uinit, ...
         acc, rsave, isave, itask, itrace, ind0, ...
         cwsav, lwsav, iwsav, rwsav);

  % Interpolation onto coarser grid for display
  itype  = int64(1);
  [uinterp, rsave, ifail] = d03py( ...
                                   u, xbkpts, npoly, xinterp, itype, rsave);

  % Output interpolated results for this time step.
  fprintf('%7.4f  u(1)', ts);
  fprintf('%8.4f', uinterp(1,:,1));
  fprintf('\n         u(2)');
  fprintf('%8.4f', uinterp(2,:,1));
  fprintf('\n\n');

  % Save this timestep for plotting.
  isav = isav+1;
  tsav(isav) = ts;
  usav(1:2,isav,1:npts) = u(1:2,1:npts);
end

% Output some statistics.
fprintf(' Number of integration steps in time = %6d\n', isave(1));
fprintf(' Number of function evaluations      = %6d\n', isave(2));
fprintf(' Number of Jacobian evaluations      = %6d\n', isave(3));
fprintf(' Number of iterations                = %6d\n', isave(5));

% Plot results.
fig1 = figure;
plot_results(x, tsav, squeeze(usav(1,:,:)), 'u_1');
fig2 = figure;
plot_results(x, tsav, squeeze(usav(2,:,:)), 'u_2');


function [p, q, r, ires, user] = pdedef(npde, t, x, nptl, u, ux, ires, user)
  p = zeros(npde, npde, nptl);
  q = zeros(npde, nptl);
  r = zeros(npde, nptl);

  for i = 1:double(nptl)
    q(1,i) = u(2,i);
    q(2,i) = u(1,i)*ux(2,i) - ux(1,i)*u(2,i);
    r(1,i) = ux(1,i);
    r(2,i) = ux(2,i);
    p(2,2,i) = 1;
  end;


function [beta, gamma, ires, user] = bndary(npde, t, u, ux, ibnd, ires, user)
  beta  = zeros(npde, 1);
  gamma = zeros(npde, 1);

  beta(1)  = 1;
  beta(2)  = 0;
  gamma(1) = 0;
  if (ibnd == 0)
    gamma(2) = u(1) - 1;
  else
    gamma(2) = u(1) + 1;
  end


function [u, user] = uinit(npde, npts, x, user)
  u = zeros(npde, npts);

  piby2 = pi/2;
  u(1,:) = -sin(piby2*x);
  u(2,:) = -piby2*piby2*u(1,:);


function plot_results(x, t, u, ident)
  % Plot array as a mesh.
  mesh(x, t, u);
  set(gca, 'YScale', 'log');
  set(gca, 'YTick', [0.00001 0.0001 0.001 0.01 0.1 1]);
  set(gca, 'YMinorGrid', 'off');
  set(gca, 'YMinorTick', 'off');

  % Label the axes, and set the title.
  xlabel('x');
  ylabel('t');
  zlabel([ident,'(x,t)']);
  title({['Solution ',ident,' of elliptic-parabolic pair'], ...
      'using Chebyshev Collocation and BDF'});

  % Set the axes limits tight to the x and y range.
  axis([x(1) x(end) t(1) t(end)]);

  % Set the view to something nice (determined empirically).
  view(-165, 44);
d03pd example results

polynomial degree =    3    no. of elements =    9
accuracy requirement =  1.000e-04    number of points =    28

 t / x        -1.0000 -0.6000 -0.2000  0.2000  0.6000  1.0000

 0.0000  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4690 -1.9961 -0.7624  0.7624  1.9961  2.4690

 0.0000  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4687 -1.9961 -0.7624  0.7624  1.9961  2.4687

 0.0000  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4700 -1.9961 -0.7624  0.7624  1.9961  2.4700

 0.0001  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4724 -1.9960 -0.7624  0.7624  1.9960  2.4724

 0.0001  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4767 -1.9959 -0.7624  0.7624  1.9959  2.4767

 0.0002  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
         u(2) -2.4840 -1.9957 -0.7623  0.7623  1.9957  2.4840

 0.0004  u(1)  1.0000  0.8089  0.3090 -0.3090 -0.8089 -1.0000
         u(2) -2.4960 -1.9953 -0.7621  0.7621  1.9953  2.4960

 0.0007  u(1)  1.0000  0.8089  0.3089 -0.3089 -0.8089 -1.0000
         u(2) -2.5142 -1.9946 -0.7619  0.7619  1.9946  2.5142

 0.0013  u(1)  1.0000  0.8087  0.3089 -0.3089 -0.8087 -1.0000
         u(2) -2.5374 -1.9933 -0.7614  0.7614  1.9933  2.5374

 0.0023  u(1)  1.0000  0.8085  0.3087 -0.3087 -0.8085 -1.0000
         u(2) -2.5611 -1.9910 -0.7605  0.7605  1.9910  2.5611

 0.0043  u(1)  1.0000  0.8081  0.3085 -0.3085 -0.8081 -1.0000
         u(2) -2.5869 -1.9866 -0.7588  0.7588  1.9866  2.5869

 0.0078  u(1)  1.0000  0.8074  0.3081 -0.3081 -0.8074 -1.0000
         u(2) -2.6183 -1.9787 -0.7558  0.7558  1.9787  2.6183

 0.0144  u(1)  1.0000  0.8063  0.3075 -0.3075 -0.8063 -1.0000
         u(2) -2.6604 -1.9643 -0.7503  0.7503  1.9643  2.6604

 0.0264  u(1)  1.0000  0.8045  0.3064 -0.3064 -0.8045 -1.0000
         u(2) -2.7128 -1.9394 -0.7402  0.7402  1.9394  2.7128

 0.0483  u(1)  1.0000  0.8020  0.3046 -0.3046 -0.8020 -1.0000
         u(2) -2.7723 -1.9042 -0.7222  0.7222  1.9042  2.7723

 0.0886  u(1)  1.0000  0.7990  0.3022 -0.3022 -0.7990 -1.0000
         u(2) -2.8331 -1.8684 -0.6915  0.6915  1.8684  2.8331

 0.1624  u(1)  1.0000  0.7962  0.2996 -0.2996 -0.7962 -1.0000
         u(2) -2.8840 -1.8423 -0.6512  0.6512  1.8423  2.8840

 0.2976  u(1)  1.0000  0.7944  0.2978 -0.2978 -0.7944 -1.0000
         u(2) -2.9140 -1.8287 -0.6218  0.6218  1.8287  2.9140

 0.5456  u(1)  1.0000  0.7939  0.2973 -0.2973 -0.7939 -1.0000
         u(2) -2.9225 -1.8250 -0.6129  0.6129  1.8250  2.9225

 1.0000  u(1)  1.0000  0.7939  0.2972 -0.2972 -0.7939 -1.0000
         u(2) -2.9233 -1.8247 -0.6120  0.6120  1.8247  2.9233

 Number of integration steps in time =     38
 Number of function evaluations      =    237
 Number of Jacobian evaluations      =      9
 Number of iterations                =     89
d03pd_fig1.png
d03pd_fig2.png

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015