Skip to content

Implementation

Dominique Delande edited this page Apr 6, 2022 · 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 should all be optional, but this is not fully implemented yet. 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 (producing an error at execution), you can remove all the import numba and @numba.jit(nopython=True,fastmath=True,cache=True) lines and you will have a working version.
  • ctypes This module makes it possible to interface Python woth 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. This module should be made optional, but it is not at the moment.
  • mkl, mkl_random and mkl_fft. These 3 modules are optional, the software works without them. 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.

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.

Back to Home

Clone this wiki locally