naginterfaces.library.ode.bvp_fd_lin_gen¶
- naginterfaces.library.ode.bvp_fd_lin_gen(a, b, tol, fcnf, fcng, c, d, gam, x, np, itrace, comm, data=None, io_manager=None, spiked_sorder='C')[source]¶
bvp_fd_lin_gen
solves a general linear two-point boundary value problem for a system of ordinary differential equations, using a deferred correction technique.For full information please refer to the NAG Library document for d02gb
https://support.nag.com/numeric/nl/nagdoc_30.1/flhtml/d02/d02gbf.html
- Parameters
- afloat
, the left-hand boundary point.
- bfloat
, the right-hand boundary point.
- tolfloat
A positive absolute error tolerance. If
is the final mesh, is the approximate solution from
bvp_fd_lin_gen
and is the true solution of equations (1) and (2) then, except in extreme cases, it is expected thatwhere
- fcnfcallable f = fcnf(n, x, data=None)
must evaluate the matrix in (1) at a general point .
- Parameters
- nint
, the number of equations.
- xfloat
, the value of the independent variable.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- ffloat, array-like, shape
must contain the th element of the matrix , for , for .
- fcngcallable g = fcng(n, x, data=None)
must evaluate the vector in (1) at a general point .
- Parameters
- nint
, the number of equations.
- xfloat
, the value of the independent variable.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- gfloat, array-like, shape
The th element of the vector , for .
- cfloat, array-like, shape
The arrays and must be set to the matrices and in (2)). must be set to the vector in (2).
- dfloat, array-like, shape
The arrays and must be set to the matrices and in (2)). must be set to the vector in (2).
- gamfloat, array-like, shape
The arrays and must be set to the matrices and in (2)). must be set to the vector in (2).
- xfloat, array-like, shape
If (see ), the first elements must define an initial mesh. Otherwise the elements of need not be set.
- npint
Determines whether a default mesh or user-supplied mesh is used.
A default value of for and a corresponding equispaced mesh are used.
You must define an initial mesh as in [equation].
- itraceint
If warning messages be suppressed, otherwise warning messages will be printed (see Exceptions).
- commdict, communication object, modified in place
Communication structure.
On initial entry: need not be set.
- dataarbitrary, optional
User-communication data for callback functions.
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- spiked_sorderstr, optional
If and are spiked (i.e., have unit extent in all but one dimension, or have size ), selects the storage order to associate with them in the NAG Engine:
- spiked_sorder =
row-major storage will be used;
- spiked_sorder =
column-major storage will be used.
Two-dimensional arrays returned from callback functions in this routine must then use the same storage order.
- Returns
- cfloat, ndarray, shape
The rows of and and the components of are reordered so that the boundary conditions are in the order:
conditions on only;
condition involving and ; and
conditions on only.
The function will be slightly more efficient if the arrays , and are ordered in this way before entry, and in this event they will be unchanged on exit.
Note that the problems (1) and (2) must be of boundary value type, that is neither nor may be identically zero.
Note also that the rank of the matrix must be for the problem to be properly posed.
Any violation of these conditions will lead to an error exit.
- dfloat, ndarray, shape
The rows of and and the components of are reordered so that the boundary conditions are in the order:
conditions on only;
condition involving and ; and
conditions on only.
The function will be slightly more efficient if the arrays , and are ordered in this way before entry, and in this event they will be unchanged on exit.
Note that the problems (1) and (2) must be of boundary value type, that is neither nor may be identically zero.
Note also that the rank of the matrix must be for the problem to be properly posed.
Any violation of these conditions will lead to an error exit.
- gamfloat, ndarray, shape
The rows of and and the components of are reordered so that the boundary conditions are in the order:
conditions on only;
condition involving and ; and
conditions on only.
The function will be slightly more efficient if the arrays , and are ordered in this way before entry, and in this event they will be unchanged on exit.
Note that the problems (1) and (2) must be of boundary value type, that is neither nor may be identically zero.
Note also that the rank of the matrix must be for the problem to be properly posed.
Any violation of these conditions will lead to an error exit.
- xfloat, ndarray, shape
define the final mesh (with the returned value of ) satisfying the relation [equation].
- yfloat, ndarray, shape
The approximate solution satisfying [equation], on the final mesh, that is
where is the number of points in the final mesh.
The remaining columns of are not used.
- npint
The number of points in the final (returned) mesh.
- Raises
- NagValueError
- (errno )
The sequence is not strictly increasing. For , and .
- (errno )
On entry: and .
Constraint: .
- (errno )
On entry: and .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
More than columns of the by matrix are identically zero, i.e., the boundary conditions are rank deficient. The number of non-identically zero columns is .
- (errno )
Row of the array and the corresponding row of array are identically zero, i.e., the boundary conditions are rank deficient.
- (errno )
is identically zero; conditions are set in .
At least one condition must be on the left. .
- (errno )
is identically zero; conditions are set in .
At least one condition must be on the right. .
- (errno )
A serious error occurred in a call to the internal integrator.
The error code internally was . Please contact NAG.
- (errno )
At least one row of the by matrix is a linear combination of the other rows determined up to a numerical tolerance, i.e., the boundary conditions are rank deficient. The index of first such row is .
- (errno )
At least one row of the by matrix is a linear combination of the other rows, i.e., the boundary conditions are rank deficient. The index of the first such row is .
- Warns
- NagAlgorithmicWarning
- (errno )
Newton iteration has reached round-off level.
If desired accuracy has not been reached, is too small for this problem and this machine precision.
- (errno )
The Newton iteration has failed to converge.
This could be due to there being too few points in the initial mesh or to the initial approximate solution being too inaccurate. If this latter reason is suspected or you cannot make changes to prevent this error, you should use the routine with a continuation facility instead.
- (errno )
A finer mesh is required for the accuracy requested; that is, is not large enough.
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
bvp_fd_lin_gen
solves a linear two-point boundary value problem for a system of ordinary differential equations in the interval []. The system is written in the formand the boundary conditions are written in the form
Here , and are matrices, and and are -component vectors. The approximate solution to (1) and (2) is found using a finite difference method with deferred correction. The algorithm is a specialization of that used in function
bvp_fd_nonlin_gen()
which solves a nonlinear version of (1) and (2). The nonlinear version of the algorithm is described fully in Pereyra (1979).You supply an absolute error tolerance and may also supply an initial mesh for the construction of the finite difference equations (alternatively a default mesh is used). The algorithm constructs a solution on a mesh defined by adding points to the initial mesh. This solution is chosen so that the error is everywhere less than your tolerance and so that the error is approximately equidistributed on the final mesh. The solution is returned on this final mesh.
If the solution is required at a few specific points then these should be included in the initial mesh. If, on the other hand, the solution is required at several specific points, then you should use the interpolation functions provided in submodule
interp
if these points do not themselves form a convenient mesh.
- References
Pereyra, V, 1979, PASVA3: An adaptive finite-difference Fortran program for first order nonlinear, ordinary boundary problems, Codes for Boundary Value Problems in Ordinary Differential Equations. Lecture Notes in Computer Science, (eds B Childs, M Scott, J W Daniel, E Denman and P Nelson) (76), Springer–Verlag