Python implementation of Krotov's method for quantum optimal control.
This implementation follows the original implementation in the QDYN Fortran library. The method is described in detail in D. M. Reich, M. Ndong, and C. P. Koch, J. Chem. Phys. 136, 104103 (2012) (arXiv:1008.5126) :cite:`ReichJCP12`
The krotov
package is built on top of QuTiP.
Development happens on Github. You can read the full documentation at ReadTheDocs.
The Krotov package is available for Python versions >= 3.5. Its main dependency is QuTiP (apart from the core packages of the Python scientific ecosystem). Thus, you should consider QuTiP's installation instructions.
In any case, using some sort of virtual environment is strongly encouraged. Most packages in the Python scientific ecosystem are now available as wheels, making installation via pip easy. However, QuTiP currently does not provide wheels. Thus, on systems that do not have the necessary compilers installed (Windows, macOS), the conda package manager provides a good solution.
Assuming conda
is installed (e.g. through Miniconda), the following
commands set up a virtual (conda) environment into which the Krotov package can
then be installed:
$ conda create -n qucontrolenv python=3.6
$ conda activate qucontrolenv
$ conda config --append channels conda-forge
$ conda install qutip
To install the latest released version of krotov
into your current (conda)
environment, run this command in your terminal:
$ pip install krotov
This is the preferred method to install the krotov
package, as it will always install the most recent stable release.
You may also do
$ pip install krotov[dev,extras]
to install additional development dependencies.
Note: the latest released version is a placeholder release that is non-functional
If you don't have pip installed, this Python installation guide, respectively the Python Packaging User Guide can guide you through the process.
To install the latest development version of krotov
from Github:
$ pip install git+https://github.com/qucontrol/krotov.git@master#egg=krotov
To use Krotov's method for quantum optimal control in a Python script or Jupyter notebook, start with:
import krotov
Then,
- define the necessary quantum operators and states using QuTiP.
- create a list of objectives, as instances of :class:`krotov.Objective <krotov.objective.Objective>`
- call :func:`krotov.optimize_pulses <krotov.optimize.optimize_pulses>` to perform an optimization of an arbitrary number of control fields over all the objectives.
See :ref:`using-krotov-with-qutip` and :ref:`krotov-example-notebooks` for details.