# daepy.bvp¶

class daepy.bvp.BVP(dae, degree=3, intervals=10)

This class is used to construct and solve the nonlinear system. It is initialised with a class dae which follows the DAETemplate, the degree of the differential variables and the number of intervals in the mesh.

solve(method='nleqres', tol=1e-08, maxiter=100, disp=False)

Solve the nonlinear system where method is one of

• ‘nleqres’ a damped global Newton method 1 (the default)

• ‘lm’ the Leveberg–Marquardt method 2

• ‘partial_inverse’ Newton-like method which calculates a partial inverse of the Jacobian by calculating a QR decomposition and doing a partial backwards substitution when the step doesn’t converge

• ‘steepest_descent’ steepest descent method

tol is required residual tolerance, maxiter is the maximum number of iterations and disp controls whether convergence messages are printed.

Returns the final solution as a BVPSolution.

1
1. Deuflhard. Systems of Equations: Global Newton Methods. In Newton Methods for Nonlinear Problems, Springer Series in Computational Mathematics, pages 109–172. Springer, Berlin, Heidelberg, 2011.

2
1. Dennis and R. Schnabel. Numerical Methods for Unconstrained Optimization and Nonlinear Equations. Classics in Applied Mathematics. Society for Industrial and Applied Mathematics, January 1996.

continuation(param, method='pseudo_arclength', steps=1, stepsize=1.0, target=None, tol=1e-08, maxiter=100, disp=False, callback=None)

Perform a continuation run starting from parameter value param where method is one of

• ‘pseudo_arclength’ the pseudo-arclength method 3 (the default)

• ‘naive’ naive continuation with no predictive step

steps is either a maximum number of steps or a numpy array of parameter values which determine the steps explicitly, stepsize is the initial stepsize (the pseudo-arclength method will adapt the stepsize, ignored if steps are given explicitly), target is a value for the parameter at which the continuation will stop (optional), tol is the required solution tolerance, maxiter is the maximum number of iterations for the nonlinear solver, disp determines whether to print progress messages and callback(parameter, solution) is a function that will be called before each continuation step, for example to draw a new line on a plot at each step (optional).

Returns the final solution as a BVPSolution.

Note

The bvp must have been initialised with a dae object that defines the update_parameter() method and all the jacobian methods. In the future, continuation using a finite difference approximation of the jacobian may be supported although it would still be strongly recommended to use an analytic jacobian, if available.

Note

When using the ‘pseudo_arclength’ method, setting a target or expilicity giving steps does not guarantee that the parameter value of the solution will correspond to the given value. If you wish to use parameter continuation to reach a specific parameter value, specify target or give explicit steps to get close to the desired parameter value and then use solve() with the exact parameter value.

3
1. Allgower and K. Georg. Introduction to Numerical Continuation Methods. Classics in Applied Mathematics. Society for Industrial and Applied Mathematics, January 2003.

state()

Returns an array containing the current coefficients of the collocation solution, coordinate transform and the coordinate scaling.

eval(coeffs)

Update the polynomial coefficients and evaluate the nonlinear system.

jac(coeffs)

Evaluate the jacobian of the system.

param_jac(x, y)

Construct the derivative of the nonlinear system with respect to a parameter.

check_jacobian()

Draws a plot to show the error between the analytic jacobian and a finite difference jacobian. Can be useful for checking jacobians.

monitor(x)

The monitor function used to define the coordinate transform.

monitor_derivative(x)

Derivative of the monitor function.

initial_solution(sol)

Set the initial solution to BVPSolution sol if compatible, otherwise use sol to construct an initial guess.

initial_guess(fun_list, transform=None, initial_interval=None)

Determine the initial polynomial coefficients from guesses for the variables given as a list of functions and, optionally, an initial coordinate transform and initial solution interval. If transform is given then initial_interval is ignored and the initial functions are assumed to be parametrised by the internal coordinate. If transform is None then the functions are assumed to be parametrised by the transformed coordinate.

initial_transform(transform_coeffs, fun_list, initial_interval)

Evaluates the residual of the coordinate transform. Used when calculating an initial coordinate transform.

initial_transform_derivative(transform_coeffs, fun_list)

Calculates the jacobian of the residual of the coordinate transform. Used when calculating an initial coordinate transform.

class daepy.bvp.BVPSolution(N, degree, intervals, continuous)

Solution to a BVP. This class collects the collocation solution, coordinate transform and coordinate scaling together. The collocation solution (parametrised by the internal coordinate) can be accessed using the solution attribute and the components of the coordinate transform can be accessed using the forward and backward shortcut attributes. Indexing a BVPSolution object returns a new BVPSolution object with 1-dimensional collocation solution corresponding to the given index and the same coordinate transform.

The solution can be evaluated at internal coordinates by using the evaluate_internal() method or by calling the object like a function. The solution can be evaluated at transformed coordinates by using the eval() method.

state()

Returns an array containing the current coefficients of the collocation solution, coordinate transform and the coordinate scaling.

update_coeffs(coeffs)

Update the polynomial coefficients of the collocation solution, coordinate transform and the coordinate scaling.

evaluate_internal(t)

Evaluate the collocation solution at internal coordinate points t. Equivalent to calling the object like a function.

eval(s)

Evaluate the collocation solution at transformed points s.

transformed_coordinate(t)

Returns the coordinate transform evaluated at t. Alias of forward.

scaled_derivative(x)

Returns the derivative of the collocation solution, scaled by the coordinate transform.

scaled_delay(x, delay_index)

Returns the value in [0,1] that corresponds to the delayed value. The delay must be one of the variables of the system with index delay_index.

scaled_antiderivative(x)

Return the integral of the collocation solution with respect to the transformed coordinate.

derivative_wrt_current(x, jac=None, nonautonomous_jac=None, sparse=True)

Calculate the derivative of the nonlinear system with respect to non-delayed arguments where jac(x,y) is a function that returns the jacobian of the system with respect to non-delayed arguments at a point x. If the system is non-autonomous then a function nonautonomous_jac(x,y) which returns the jacobian of the non-autonmous part with respect to the coordinate transform may be provided and this method will return the corresponding derivative of the nonlinear system. If either jac or nonautonomous_jac is not provided then the corresponding derivative is zero. The results are returned as scipy.sparse.csr_matrix unless sparse is False, in which case the result is returned as a full numpy array.

derivative_wrt_derivative(x, jac, sparse=True)

Calculate the derivative of the nonlinear system with respect to non-delayed derivatives where jac(x,y) is a function that returns the jacobian of the system with respect to non-delayed derivatives at a point x. Also calculates the corresponding derivative with respect to the coordinate transform. The results are returned as scipy.sparse.csr_matrix unless sparse is False, in which case the result is returned as a full numpy array.

derivative_wrt_delayed(x, jac, delay_index, sparse=True)

Calculate the derivative of the nonlinear system with respect to delayed arguments where jac(x,y) is a function that returns the jacobian of the system with respect to delayed arguments at a point x. The delay must be one of the variables of the system with index delay_index. Also calculates the corresponding derivative with respect to the coordinate transform. The results are returned as scipy.sparse.csr_matrix unless sparse is False, in which case the result is returned as a full numpy array. If your system has multiple delays, this function must be used for each delay separately.

save(savename)

Save the solution in compressed format. The file extension .npz is appended automatically. The solution can be loaded again using load_solution().

daepy.bvp.load_solution(filename)

Load a solution from compressed format.