pykinsol provides a Python interface to KINSOL from the SUNDIALS package suite.
pykinsol provides a Python binding to the Nonlinear system of equation solver algorithms from kinsol in the SUNDIALS suite. pykinsol allows a user to numerically solve (systems of) non-linear equations. Note that not all functionality of KINSOL are currently exposed in the python wrapper. Additional functinoality is however easy to add if needed.
You may also want to know that you can use pykinsol from pyneqsys which can e.g. derive the Jacobian analytically for you.
Autogenerated API documentation is found here.
Simplest way to install pykinsol is to use the conda package manager:
$ conda install -c bjodah pykinsol pytest $ python -m pytest --pyargs pykinsol
tests should pass.
Binary distribution is available here: https://anaconda.org/bjodah/pykinsol
Source distribution is available here: https://pypi.python.org/pypi/pykinsol
To compile from source you may proceed e.g. as follows:
$ LLAPACK=openblas python3.4 setup.py install --user
where we specified specifically what LAPACK implementation we used for building SUNDIALS.
See examples/, and rendered jupyter notebooks here: http://hera.physchem.kth.se/~pykinsol/branches/master/examples
Here is a simple example:
>>> def f(x, fout): ... fout = x + (x - x)**3/2 - 1 ... fout = x + (x - x)**3/2 ... >>> def j(x, Jout, fx): ... Jout[0, 0] = 1 + 3/2 * (x - x)**2 ... Jout[0, 1] = -3/2 * (x - x)**2 ... Jout[1, 0] = -3/2 * (x - x)**2 ... Jout[1, 1] = 1 + 3/2 * (x - x)**2 ... >>> from pykinsol import solve >>> result = solve(f, j, [0, 0]) >>> assert result['success'] >>> print(result['x']) # doctest: +SKIP [ 0.84116389 0.15883611]