naginterfaces.library.pde.dim3_ellip_fd¶
- naginterfaces.library.pde.dim3_ellip_fd(n2, a, b, c, d, e, f, g, q, t, aparam, itmax, itcoun, ndir, ixn, iyn, izn, conres, conchn)[source]¶
dim3_ellip_fd
uses the Strongly Implicit Procedure to calculate the solution to a system of simultaneous algebraic equations of seven-point molecule form on a three-dimensional topologically-rectangular mesh. (‘Topological’ means that a polar grid, for example, can be used if it is equivalent to a rectangular box.)For full information please refer to the NAG Library document for d03ec
https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/d03/d03ecf.html
- Parameters
- n2int
The number of nodes in the second coordinate direction, .
- afloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- bfloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- cfloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- dfloat, array-like, shape
must contain the coefficient of (the ‘central’ term) in the th equation of the system (1), for , for , for . The elements of are checked to ensure that they are nonzero. If any element is found to be zero, the corresponding algebraic equation is assumed to be . This feature can be used to define the equations for nodes at which, for example, Dirichlet boundary conditions are applied, or for nodes external to the problem of interest. Setting at appropriate points, and the corresponding value of to the appropriate value, namely the prescribed value of in the Dirichlet case, or to zero at an external point.
- efloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- ffloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- gfloat, array-like, shape
must contain the coefficient of in the th equation of the system (1), for , for , for . The elements of , for , must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
- qfloat, array-like, shape
must contain , for , for , for , i.e., the source-term values at the nodal points of the system (1).
- tfloat, array-like, shape
must contain the element of an approximate solution to the equations, for , for , for .
If no better approximation is known, an array of zeros can be used.
- aparamfloat
The iteration acceleration factor. A value of is adequate for most typical problems. However, if convergence is slow, the value can be reduced, typically to or . If divergence is obtained, the value can be increased, typically to , or .
- itmaxint
The maximum number of iterations to be used by the function in seeking the solution. A reasonable value might be for a problem with nodes and convergence criteria of about of the original residual and change.
- itcounint
On the first call of
dim3_ellip_fd
, must be set to . On subsequent entries, its value must be unchanged from the previous call.- ndirint
Indicates whether or not the system of equations has a unique solution. For systems which have a unique solution, must be set to any nonzero value. For systems derived from problems to which an arbitrary constant can be added to the solution, for example Poisson’s equation with all Neumann boundary conditions, should be set to and the values of the next three arguments must be specified. For such problems the function subtracts the value of the function derived at the node (, , ) from the whole solution after each iteration to reduce the possibility of large rounding errors. You must also ensure for such problems that the appropriate compatibility condition on the source terms is satisfied. See the comments at the end of Notes.
- ixnint
Is ignored unless is equal to zero, in which case it must specify the first index of the nodal point at which the solution is to be set to zero. The node should not correspond to a corner node, or to a node external to the region of interest.
- iynint
Is ignored unless is equal to zero, in which case it must specify the second index of the nodal point at which the solution is to be set to zero. The node should not correspond to a corner node, or to a node external to the region of interest.
- iznint
Is ignored unless is equal to zero, in which case it must specify the third index of the nodal point at which the solution is to be set to zero. The node should not correspond to a corner node, or to a node external to the region of interest.
- conresfloat
The convergence criterion to be used on the maximum absolute value of the normalized residual vector components. The latter is defined as the residual of the algebraic equation divided by the central coefficient when the latter is not equal to , and defined as the residual when the central coefficient is zero.
should not be less than a reasonable multiple of the machine precision.
- conchnfloat
The convergence criterion to be used on the maximum absolute value of the change made at each iteration to the elements of the array , namely the dependent variable. should not be less than a reasonable multiple of the machine accuracy multiplied by the maximum value of attained.
Convergence is achieved when both the convergence criteria are satisfied.
You can, therefore, set convergence on either the residual or on the change, or (as is recommended) on a requirement that both are below prescribed limits.
- Returns
- tfloat, ndarray, shape
The solution derived by the function.
- itcounint
Its value is increased by the number of iterations used on this call (namely ). It, therefore, stores the accumulated number of iterations actually used.
For subsequent calls for the same problem, i.e., with the same , and but possibly different coefficients and/or source terms, as occur with nonlinear systems or with time-dependent systems, should not be reset, i.e., it must contain the accumulated number of iterations.
In this way a suitable cycling of the sequence of iteration arguments is obtained in the calls to
dim3_ellip_fd_iter()
.- itusedint
The number of iterations actually used on that call.
- residsfloat, ndarray, shape
The maximum absolute value of the residuals calculated at the th iteration, for . If the residual of the solution is sought you must calculate this in the function from which
dim3_ellip_fd
is called. The sequence of values indicates the rate of convergence.- chngsfloat, ndarray, shape
The maximum absolute value of the changes made to the components of the dependent variable at the th iteration, for . The sequence of values indicates the rate of convergence.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, , , and .
Constraint: .
- (errno )
Convergence not achieved in iterations: .
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
Given a set of simultaneous equations
(which could be nonlinear) derived, for example, from a finite difference representation of a three-dimensional elliptic partial differential equation and its boundary conditions, the function determines the values of the dependent variable . is a square by matrix and is a known vector of length .
The equations must be of seven-diagonal form:
for , and , provided that .
Indeed, if , then the equation is assumed to be:
The system is solved iteratively from a starting approximation by the formulae:
Thus is the residual of the th approximate solution , and is the update change vector.
The calling program supplies an initial approximation for the values of the dependent variable in the array , the coefficients of the seven-point molecule system of equations in the arrays , , , , , and , and the source terms in the array . The function derives the residual of the latest approximate solution, and then uses the approximate factorization of the Strongly Implicit Procedure with the necessary acceleration argument adjustment by calling
dim3_ellip_fd_iter()
at each iteration.dim3_ellip_fd
combines the newly derived change with the old approximation to obtain the new approximate solution for . The new solution is checked for convergence against the user-supplied convergence criteria, and if these have not been satisfied, the iterative cycle is repeated. Convergence is based on both the maximum absolute normalized residuals (calculated with reference to the previous approximate solution as these are calculated at the commencement of each iteration) and on the maximum absolute change made to the values of .Problems in topologically non-rectangular-box-shaped regions can be solved using the function by surrounding the region by a circumscribing topologically rectangular box. The equations for the nodal values external to the region of interest are set to zero (i.e., ) and the boundary conditions are incorporated into the equations for the appropriate nodes.
If there is no better initial approximation when starting the iterative cycle, one can use an array of zeros as the initial approximation.
The function can be used to solve linear elliptic equations in which case the arrays , , , , , , and remain constant and for which a single call provides the required solution. It can also be used to solve nonlinear elliptic equations, in which case some or all of these arrays may require updating during the progress of the iterations as more accurate solutions are derived. The function will then have to be called repeatedly in an outer iterative cycle. Dependent on the nonlinearity, some under-relaxation of the coefficients and/or source terms may be needed during their recalculation using the new estimates of the solution.
The function can also be used to solve each step of a time-dependent parabolic equation in three space dimensions. The solution at each time step can be expressed in terms of an elliptic equation if the Crank–Nicolson or other form of implicit time integration is used.
Neither diagonal dominance, nor positive-definiteness, of the matrix formed from the arrays , , , , , and is necessary to ensure convergence.
For problems in which the solution is not unique in the sense that an arbitrary constant can be added to the solution (for example Poisson’s equation with all Neumann boundary conditions), an argument is incorporated so that the solution can be rescaled. A specified nodal value is subtracted from the whole solution after the completion of every iteration. This keeps rounding errors to a minimum for those cases when convergence is slow. For such problems there is generally an associated compatibility condition. For the example mentioned this compatibility condition equates the total net source within the region (i.e., the source integrated over the region) with the total net outflow across the boundaries defined by the Neumann conditions (i.e., the normal derivative integrated along the whole boundary). It is very important that the algebraic equations derived to model such a problem implement accurately the compatibility condition. If they do not, a net source or sink is very likely to be represented by the set of algebraic equations and no steady-state solution of the equations exists.
- References
Jacobs, D A H, 1972, The strongly implicit procedure for the numerical solution of parabolic and elliptic partial differential equations, Note RD/L/N66/72, Central Electricity Research Laboratory
Stone, H L, 1968, Iterative solution of implicit approximations of multi-dimensional partial differential equations, SIAM J. Numer. Anal. (5), 530–558
Weinstein, H G, Stone, H L and Kwan, T V, 1969, Iterative procedure for solution of systems of parabolic and elliptic equations in three dimensions, Industrial and Engineering Chemistry Fundamentals (8), 281–287