A Matlab package for investigating the stability properties of polynomial integrators and computing their coefficients.
Below we describe how to use the key features of this library. Example scripts that showcase all the features descriebd in this document are available in the repository https://github.com/pipack/pipack-mat-examples
Polynomial integrators are described by general construction strategies that are not limited to a single node set. This code is designed so that you can initialize a generator object that can construct families of PBMs with any number of nodes.
To initialize a method generator, you must first select a node set generator, ODE polynomial generator, and for Adams methods an expansion point generator.
Node set generators inherit from the abstract class NodeSetGenerator and are located in classes/generators/nodes/families. Several currently available families of nodes generators are:
- IEquiNSG: imaginary equispaced nodes
- IChebNSG: imaginary chebyshev nodes
- EquiNSG: equispaced nodes
- ChebNSG: chebyshev nodes
All node set generators are initialized in the following way:
NodeSetGenerator(ordering, precision, options)
where the parameters are:
- ordering: string with value 'leftsweep' | 'rightsweep' | 'inwards' | 'outwards' | 'classical'| 'rclassical'
- precision: string with value 'double' | 'vpa' | 'sym'
- options: optional struct with additional options.
Adams methods also require a generator for the expansion points (also called left integration endpoints). Endpoint generators inherit from the abstract class JD_ExpansionPointGenerator and are located in classes/generators/expansionpoints/families. Currently available expansion points are:
- FixedInputEPG
- SweepingInputEPG
- VariableINputEPG
All endpoint generators can be initilized in the following way:
ExpansionPointGenerator(options)
where options is a struct with specific options pertinant to the endpoints. For example, FixedInputEPG reacts to the field 'l' that denotes the index of the node used for the endpoint.
ODE polynomials generators inherit from the abstract class JD_ODEPolynomialGenerator, and are located in *classes/generators/odepolynomials/families. Three example families are
- Adams_PG: an Adams ODE polynomial
- BDF_PG: A BDF ODE polynomial
- GBDF_PG: A GBDF ODE polynomial
The constructors for these polynomial differ depending on the family. BDF and GBDF ODE polynomials generators can be initialized using
GBDF_PG(IBSet, type)
where the parameter are:
- IBSet: string with value 'PMFO', 'PMFOmj', 'SMFO', 'SMFOmj', or 'SMVO'. It describes the AII and AOI sets I(j) and B(j).
- type: string with value 'explicit' or 'diagonally_implicit'.
For Adams ODE polynomials the ODE polynomial generators can be initialized using
Adams_PG(Ly_IBSet, LF_IBSet, EP_generator, type)
where the parameter are:
- Ly_IBSet: string with value 'PMFO', 'PMFOmj', 'SMFO', 'SMFOmj', or 'SMVO'. Describes AII and AOI set for polynomial
- LF_IBSet: string with value 'PMFO', 'PMFOmj', 'SMFO', 'SMFOmj', or 'SMVO'. Describes AII and AOI set for polynomial
- type: string with value 'explicit' or 'diagonally_implicit'
The function PBMGenerator(options) can be used to quickly initialize a method generator. It accepts a single parameter of type struct. The struct should have at minimum the following fields
- NodeSet_generator: Object of type NodeSetGenerator that described the node set
- ODEPoly_generator: Object of type JD_ODEPolynomialGenerator that describes the ODE polynomial family
For example a diagonally-implicit Adams Method with imaginary equispaced nodes, SMFO active sets, and FixedInput endpoints can be initialized using
adams_generator = PBMGenerator(struct( ...
'NodeSet_generator', IEquiNSG('inwards', 'double'), ...
'ODEPoly_generator', Adams_PG('PMFO', 'SMFOmj', FixedInputEPG(struct('l', 2)), 'diagonally_implicit') ...
));
Similarly, an implicit BDF with imaginary nodes and SMVO method can be initilized with
bdf_generator = PBMGenerator(struct( ...
'NodeSet_generator', IEquiNSG('inwards', 'double'), ...
'ODEPoly_generator', BDF_PG('SMVO', 'diagonally_implicit') ...
));
The generators can now be used to initilize methods of any number of nodes. For example we can use the result of the previous two commands to initialize methods with four nodes by running the commands
bdf_method = bdf_generator.generate(4);
adams_method = adams_generator.generate(4);
The returned type will inherit from the class PBM.
You compute the coefficients for any object of type PBM using
[A, B, C, D] = method.blockMatrices(alpha, format);
where the parameters are:
-
alpha: positive real number representing the extrapolation factor
-
format: string with value 'full' or 'compact' or 'full_traditional' or 'compact_traditional':
Note. If the method is initialized with a NodeSetGenerator with precision='double', then coefficients will have double precision. Similarly, a method generated using a NodeSetGenerator with precision='vpa' will produce coefficients in variable precision, and finally if precision='sym' then coefficients will be fully symbolic. To obtain exact coefficients, initialize the method using a MethodGenerator with a NodeSetGenerator with precision='sym' then set with sym(alpha).
You can visualize the polynomial diagram of a method, or the expansion point diagram by calling:
adams_method.polynomialDiagram();
adams_method.expansionPointDiagram();
The stability of methods can be investigated with a variety of functions
alpha = 1/2
re_z = linspace(-5, 1, 100)
im_z = linspace(-5, 5, 200)
stabilityFigure(method, alpha, re_z, im_z) % plots stabilty region in complex z-plane
imStabilityFigure(method,alpha, im_z) % plots stability region along imaginary axis
isRootStable(method, alpha) % root stability
stabilityTheta(method, alpha) % stability angle
stabilityOfAlphaMovie(method, alphas, z_real, z_imag, struct('path', 'movie.mp4'))