Mathematics |
Changing BVP Integration Properties
The default integration properties in the BVP solver bvp4c
are selected to handle common problems. In some cases, you can improve solver performance by changing these defaults. To do this, supply bvp4c
with one or more property values in an options structure.
In this and subsequent property tables, the most commonly used property categories are listed first, followed by more advanced categories.
Properties Category |
Property Names |
Error control |
RelTol , AbsTol |
Vectorization |
Vectorized |
Analytical partial derivatives |
FJacobian , BCJacobian |
Singular BVPs |
SingularTerm |
Mesh size |
NMax |
Output displayed |
Stats |
Note For other ways to improve solver efficiency, check Using Continuation to Make a Good Initial Guess and the tutorial, "Solving Boundary Value Problems for Ordinary Differential Equations in MATLAB with bvp4c," available at ftp://ftp.mathworks.com/pub/doc/papers/bvp/. |
Creating and Maintaining a BVP Options Structure
The bvpset
function creates an options
structure that you can supply to bvp4c
. You can use bvpget
to query the options
structure for the value of a specific property.
Creating an Options Structure. The bvpset
function accepts property name/property value pairs using the syntax
This creates a structure options
in which the named properties have the specified values. Unspecified properties retain their default values. For all properties, it is sufficient to type only the leading characters that uniquely identify the property name. bvpset
ignores case for property names.
With no arguments, bvpset
displays all property names and their possible values, indicating defaults with braces {}
.
Modifying an Existing Options Structure. To modify an existing options
argument, use
This overwrites any values in oldopts
that are specified using name/value pairs. The modified structure is returned as the output argument. In the same way, the command
combines the structures oldopts
and newopts
. In options
, any values set in newopts
overwrite those in oldopts
.
Querying an Options Structure. The bvpget
function extracts a property value from an options
structure created with bvpset
.
This returns the value of the specified property, or an empty matrix []
if the property value is unspecified in the options
structure.
As with bvpset
, it is sufficient to type only the leading characters that uniquely identify the property name; case is ignored for property names.
Error Tolerance Properties
Because bvp4c
uses a collocation formula, the numerical solution is based on a mesh of points at which the collocation equations are satisfied. Mesh selection and error control are based on the residual of this solution, such that the computed solution is the exact solution of a perturbed problem
. On each subinterval of the mesh, a norm of the residual in the i
th component of the solution, res(i)
, is estimated and is required to be less than or equal to a tolerance. This tolerance is a function of the relative and absolute tolerances, RelTol
and AbsTol
, defined by the user.
The following table describes the error tolerance properties. Use bvpset
to set these properties.
Vectorization
The following table describes the BVP vectorization property. Vectorization of the ODE function used by bvp4c
differs from the vectorization used by the ODE solvers:
bvp4c
, the ODE function must be vectorized with respect to the first argument as well as the second one, so that F([x1 x2 ...],[y1 y2 ...])
returns [F(x1,y1) F(x2,y2) ...]
.
bvp4c
benefits from vectorization even when analytical Jacobians are provided. For stiff ODE solvers, vectorization is ignored when analytical Jacobians are used.
Use bvpset
to set this property.
Property |
Value |
Description |
Vectorized |
on | {off } |
Set on to inform bvp4c that you have coded the ODE function F so that F([x1 x2 ...],[y1 y2 ...]) returns [F(x1,y1) F(x2,y2) ...] . This allows the solver to reduce the number of function evaluations, and may significantly reduce solution time.With the MATLAB array notation, it is typically an easy matter to vectorize an ODE function. In the shockbvp example shown previously, the shockODE function has been vectorized using colon notation into the subscripts and by using the array multiplication (.* ) operator. |
Analytical Partial Derivatives
By default, the bvp4c
solver approximates all partial derivatives with finite differences. bvp4c
can be more efficient if you provide analytical partial derivatives of the differential equations, and analytical partial derivatives, and , of the boundary conditions. If the problem involves unknown parameters, you must also provide partial derivatives, and , with respect to the parameters.
The following table describes the analytical partial derivatives properties. Use bvpset
to set these properties.
Singular BVPs
bvp4c
can solve singular problems of the form
posed on the interval where . For such problems, specify the constant matrix as the value of SingularTerm
. For equations of this form, odefun
evaluates only the term, where represents unknown parameters, if any.
Property |
Value |
Description |
SingularTerm |
Constant matrix |
Singular term of singular BVPs. Set to the constant matrix for equations of the form posed on the interval where . |
Mesh Size Property
bvp4c
solves a system of algebraic equations to determine the numerical solution to a BVP at each of the mesh points. The size of the algebraic system depends on the number of differential equations (n
) and the number of mesh points in the current mesh (N
). When the allowed number of mesh points is exhausted, the computation stops, bvp4c
displays a warning message and returns the solution it found so far. This solution does not satisfy the error tolerance, but it may provide an excellent initial guess for computations restarted with relaxed error tolerances or an increased value of NMax
.
The following table describes the mesh size property. Use bvpset
to set this property.
Solution Statistic Property
The Stats
property lets you view solution statistics.
The following table describes the solution statistics property. Use bvpset
to set this property.
Property |
Value |
Description |
Stats |
on | {off } |
Specifies whether statistics about the computations are displayed. If the |
Solving Singular BVPs | Partial Differential Equations |