naginterfaces.library.pde.dim2_​ellip_​discret

naginterfaces.library.pde.dim2_ellip_discret(xmin, xmax, ymin, ymax, pdef, bndy, ngx, ngy, scheme, data=None)[source]

dim2_ellip_discret discretizes a second-order elliptic partial differential equation (PDE) on a rectangular region.

For full information please refer to the NAG Library document for d03ee

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/d03/d03eef.html

Parameters
xminfloat

The lower and upper coordinates of the rectangular region respectively, and .

xmaxfloat

The lower and upper coordinates of the rectangular region respectively, and .

yminfloat

The lower and upper coordinates of the rectangular region respectively, and .

ymaxfloat

The lower and upper coordinates of the rectangular region respectively, and .

pdefcallable (alpha, beta, gamma, delta, epslon, phi, psi) = pdef(x, y, data=None)

must evaluate the functions , , , , , and which define the equation at a general point .

Parameters
xfloat

The and coordinates of the point at which the coefficients of the partial differential equation are to be evaluated.

yfloat

The and coordinates of the point at which the coefficients of the partial differential equation are to be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
alphafloat

must be set to the value of at the point specified by and .

betafloat

must be set to the value of at the point specified by and .

gammafloat

must be set to the value of at the point specified by and .

deltafloat

must be set to the value of at the point specified by and .

epslonfloat

must be set to the value of at the point specified by and .

phifloat

must be set to the value of at the point specified by and .

psifloat

must be set to the value of at the point specified by and .

bndycallable (a, b, c) = bndy(x, y, ibnd, data=None)

must evaluate the functions , , and involved in the boundary conditions.

Parameters
xfloat

The and coordinates of the point at which the boundary conditions are to be evaluated.

yfloat

The and coordinates of the point at which the boundary conditions are to be evaluated.

ibndint

Specifies on which boundary the point lies. , , or according as the point lies on the bottom, right, top or left boundary.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
afloat

, and must be set to the values of the functions appearing in the boundary conditions.

bfloat

, and must be set to the values of the functions appearing in the boundary conditions.

cfloat

, and must be set to the values of the functions appearing in the boundary conditions.

ngxint

The number of interior grid points in the - and -directions respectively, and . If the seven-diagonal equations are to be solved by dim2_ellip_mgrid(), and should preferably be divisible by as high a power of as possible.

ngyint

The number of interior grid points in the - and -directions respectively, and . If the seven-diagonal equations are to be solved by dim2_ellip_mgrid(), and should preferably be divisible by as high a power of as possible.

schemestr, length 1

The type of approximation to be used for the first derivatives which occur in the partial differential equation.

Central differences are used.

Upwind differences are used.

dataarbitrary, optional

User-communication data for callback functions.

Returns
afloat, ndarray, shape

, for , for , contains the seven-diagonal linear equations produced by the discretization described above. If , the remaining elements are not referenced by the function, but if then the array can be passed directly to dim2_ellip_mgrid(), where these elements are used as workspace.

rhsfloat, ndarray, shape

The first elements contain the right-hand sides of the seven-diagonal linear equations produced by the discretization described above. If , the remaining elements are not referenced by the function, but if then the array can be passed directly to dim2_ellip_mgrid(), where these elements are used as workspace.

Raises
NagValueError
(errno )

On entry, .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: must be at least .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

Mixed derivative in equation and derivative in boundary condition at top left boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at top right boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at bottom left boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at bottom right boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at right boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at left boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at top boundary. .

(errno )

Mixed derivative in equation and derivative in boundary condition at bottom boundary. .

(errno )

Null boundary condition at left boundary, top end. .

(errno )

Null boundary condition at top boundary, left end. .

(errno )

Null boundary condition at right boundary, top end. .

(errno )

Null boundary condition at top boundary, right end. .

(errno )

Null boundary condition at left boundary, bottom end. .

(errno )

Null boundary condition at bottom boundary, left end. .

(errno )

Null boundary condition at right boundary, bottom end. .

(errno )

Null boundary condition at bottom boundary, right end. .

(errno )

Null boundary condition at right boundary. .

(errno )

Null boundary condition at left boundary. .

(errno )

Null boundary condition at top boundary. .

(errno )

Null boundary condition at bottom boundary. .

Warns
NagAlgorithmicWarning
(errno )

Equation not elliptic at some point.

(errno )

There is no unique solution with Neumann Boundary conditions.

(errno )

The linear equations were not diagonally dominant.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

dim2_ellip_discret discretizes a second-order linear elliptic partial differential equation of the form

on a rectangular region

subject to boundary conditions of the form

where denotes the outward pointing normal derivative on the boundary. Equation (1) is said to be elliptic if

for all points in the rectangular region. The linear equations produced are in a form suitable for passing directly to the multigrid function dim2_ellip_mgrid().

The equation is discretized on a rectangular grid, with grid points in the -direction and grid points in the -direction. The grid spacing used is, therefore,

and the coordinates of the grid points are

At each grid point six neighbouring grid points are used to approximate the partial differential equation, so that the equation is discretized on the seven-point stencil shown in Figure [label omitted].

[figure omitted]

For convenience the approximation to the exact solution is denoted by , and the neighbouring approximations are labelled according to points of the compass as shown. Where numerical labels for the seven points are required, these are also shown.

The following approximations are used for the second derivatives:

Two possible schemes may be used to approximate the first derivatives:

Central Differences

Upwind Differences

Central differences are more accurate than upwind differences, but upwind differences may lead to a more diagonally dominant matrix for those problems where the coefficients of the first derivatives are significantly larger than the coefficients of the second derivatives.

The approximations used for the first derivatives may be written in a more compact form as follows:

where and for upwind differences, and for central differences.

At all points in the rectangular domain, including the boundary, the coefficients in the partial differential equation are evaluated by calling , and applying the approximations. This leads to a seven-diagonal system of linear equations of the form:

where the coefficients are given by

These equations then have to be modified to take account of the boundary conditions. These may be Dirichlet (where the solution is given), Neumann (where the derivative of the solution is given), or mixed (where a linear combination of solution and derivative is given).

If the boundary conditions are Dirichlet, there are an infinity of possible equations which may be applied:

If dim2_ellip_mgrid() is used to solve the discretized equations, it turns out that the choice of can have a dramatic effect on the rate of convergence, and the obvious choice is not the best. Some choices may even cause the multigrid method to fail altogether. In practice it has been found that a value of the same order as the other diagonal elements of the matrix is best, and the following value has been found to work well in practice:

If the boundary conditions are either mixed or Neumann (i.e., on return from ), then one of the points in the seven-point stencil lies outside the domain. In this case the normal derivative in the boundary conditions is used to eliminate the ‘fictitious’ point, :

It should be noted that if the boundary conditions are Neumann and , then there is no unique solution. The function returns with = 5 in this case, and the seven-diagonal matrix is singular.

The four corners are treated separately. is called twice, once along each of the edges meeting at the corner. If both boundary conditions at this point are Dirichlet and the prescribed solution values agree, then this value is used in an equation of the form (2). If the prescribed solution is discontinuous at the corner, then the average of the two values is used. If one boundary condition is Dirichlet and the other is mixed, then the value prescribed by the Dirichlet condition is used in an equation of the form given above. Finally, if both conditions are mixed or Neumann, then two ‘fictitious’ points are eliminated using two equations of the form (3).

It is possible that equations for which the solution is known at all points on the boundary, have coefficients which are not defined on the boundary. Since this function calls at all points in the domain, including boundary points, arithmetic errors may occur in which this function cannot trap. If you have an equation with Dirichlet boundary conditions (i.e., at all points on the boundary), but with PDE coefficients which are singular on the boundary, then dim2_ellip_mgrid() could be called directly only using interior grid points at your discretization.

After the equations have been set up as described above, they are checked for diagonal dominance. That is to say,

If this condition is not satisfied then the function returns with = 6. The multigrid function:meth:dim2_ellip_mgrid may still converge in this case, but if the coefficients of the first derivatives in the partial differential equation are large compared with the coefficients of the second derivative, you should consider using upwind differences ().

Since this function is designed primarily for use with dim2_ellip_mgrid(), this document should be read in conjunction with the document for that function.

References

Wesseling, P, 1982, MGD1 – a robust and efficient multigrid method, Multigrid Methods. Lecture Notes in Mathematics (960), 614–630, Springer–Verlag