Skip to content

Implementation

Dominique Delande edited this page Feb 20, 2023 · 10 revisions

In these pages, I discuss the details of the implementation.

The software is almost entirely written in Python 3 (Python 2 is NOT supported and will never be, even if you give much money), using mostly the standard modules numpy and scipy. However, few pieces have also pure C implementations, for the inner heavy computational routines. These may speed up the calculation by roughly one order of magnitude. Note that there is always a Python implementation available, which is 100% compatible. See C interface for details. The list of standard Python modules used is:

  • math
  • numpy
  • scipy.integrate
  • scipy.sparse
  • scipy.special
  • os
  • sys
  • copy
  • time
  • timeit
  • getpass
  • argparse
  • configparser

All these modules are very standard, available on any reasonnable installation of Python. I recommend to use anaconda.

In addition, some less standard modules can be used. They are optional, so that the and-python package will work without them (it automatically detects if they are present). These are:

  • numba This speeds up very significantly pure Python code using Numpy or Scipy. Very easy to use as you only have to add a decorator like @numba.jit(nopython=True,fastmath=True,cache=True) before the defintion of a function. It is used in the Hamiltonian and Propagation modules. If numba is not available on your computer, it uses a standard Python implementation.
  • ctypes (and the companion module numpy.ctypeslib). This module makes it possible to interface Python with a pure C code. If used in the computationally intensive parts, it may speed up things by one order of magnitude. See section C_interface for details.
  • mkl, mkl_random and mkl_fft. The mkl module is only used to set the number of OpenMP threads, it is probably useless. If the mkl_random module is present, the MKL random number generator is used. If not, the program uses numpy.random, which has roughly the same speed. If the mkl_fft module is present, most FFTs (the ones which use a lot of CPU time) are performed using the MKL FFT routines. If not present, the program uses numpy.fft, which is a bit slower. In a future version, it will be probably better to try to use Pyfftw which is apparently faster and has a syntax very close to numpy.fft.

All the and-python software is available from one internal module named anderson, so that any program using the software should have the line:

import anderson

at the beginning. This imports everything useful, it should be sufficient for all applications.

The internal structure is described in the Anderson module page.

Back to Home

Clone this wiki locally