In [5]:
%matplotlib inline
import numpy as np
from pylab import *
from qutip import *

Introduction

For time-independent open quantum systems with decay rates larger than the corresponding excitation rates, the system will tend toward a steady state as $t\rightarrow\infty$ that satisfies the equation

$$\frac{d\hat{\rho}_{ss}}{dt}=\mathcal{L}\hat{\rho}_{ss}=0.$$

Although the requirement for time-independence seems quite restrictive, one can often employ a transformation to the interaction picture that yields a time-independent Hamiltonian. For many these systems, solving for the asymptotic density matrix $\hat{\rho}_{ss}$ can be achieved using direct or iterative solution methods faster than using master equation or Monte Carlo simulations. Although the steady state equation has a simple mathematical form, the non-symmetric structure of the Liouvillian operator are such that efficient solutions to this equation are anything but straightforward to find.

Steady State solvers in QuTiP

In QuTiP, the steady-state solution for a system Hamiltonian or Liouvillian is given by steadystate. This function implements a number of different methods for finding the steady state, each with their own pros and cons, where the method used can be chosen using the method keyword argument.

Method Keyword Description
Direct (default) 'direct' Direct solution solving $Ax=b$ via sparse LU decomposition.
Eigenvalue 'eigen' Iteratively find the eigenvector corresponding to the zero eigenvalue of $\mathcal{L}$.
Inverse-Power 'power' Iteratively solve for the steady-state solution using the inverse-power method.
GMRES 'iterative-gmres' Iteratively solve for the steady-state solution using the GMRES method and optional preconditioner.
LGMRES 'iterative-lgmres' Iteratively solve for the steady-state solution using the LGMRES method and optional preconditioner.
BICGSTAB 'iterative-bicgstab' Iteratively solve for the steady-state solution using the BICGSTAB method and optional preconditioner.
SVD 'svd' Steady-state solution via the SVD of the Liouvillian represented by a **dense** matrix.
Power GMRES 'power-gmres' Solution using a doubly-iterative inverse-power method using GMRES iteration and optional preconditioner.
Power LGMRES 'power-lgmres' Solution using a doubly-iterative inverse-power method using LGMRES iteration and optional preconditioner.
Power BICGSTAB 'power-bicgstab' Solution using a doubly-iterative inverse-power method using BICGSTAB iteration and optional preconditioner.

The function steadystate can take either a Hamiltonian and a list of collapse operators as input, generating internally the corresponding Liouvillian super operator in Lindblad form, or alternatively, an arbitrary Liouvillian passed by the user. When possible, we recommend passing the Hamiltonian and collapse operators to steadystate, and letting the function automatically build the Liouvillian for the system.

Using the Steadystate Solver

Solving for the steady state solution to the Lindblad master equation for a general system with steadystate can be accomplished using:

rho_ss = steadystate(H, c_ops)

where H is a quantum object representing the system Hamiltonian, and c_ops is a list of quantum objects for the system collapse operators. The output, labeled as rho_ss, is the steady-state solution for the systems. If no other keywords are passed to the solver, the default 'direct' method is used, generating a solution that is exact to machine precision at the expense of a large memory requirement. The large amount of memory need for the direct LU decomposition method stems from the large bandwidth of the system Liouvillian and the correspondingly large fill-in (extra nonzero elements) generated in the LU factors. This fill-in can be reduced by using bandwidth minimization algorithms. Additional parameters may be used by calling the steady-state solver as:

rho_ss = steadystate(H, c_ops, method='power', use_rcm=True)

where method='power' indicates that we are using the inverse-power solution method, and use_rcm=True turns on the bandwidth minimization routine.

Although it is not obvious, the 'direct', eigen, and 'power' methods all use an LU decomposition internally and thus suffer from a large memory overhead. In contrast, iterative methods such as the 'iterative-gmres', 'iterative-lgmres', and 'iterative-bicgstab' methods do not factor the matrix and thus take less memory than these previous methods and allowing, in principle, for extremely large system sizes. The downside is that these methods can take much longer than the direct method as the condition number of the Liouvillian matrix is large, indicating that these iterative methods require a large number of iterations for convergence. To overcome this, one can use a preconditioner $M$ that solves for an approximate inverse for the (modified) Liouvillian, thus better conditioning the problem, leading to faster convergence. The use of a preconditioner can actually make these iterative methods faster than the other solution methods. The problem with precondioning is that it is only well defined for Hermitian matrices. Since the Liouvillian is non-Hermitian, the ability to find a good preconditioner is not guaranteed. And moreover, if a preconditioner is found, it is not guaranteed to have a good condition number. QuTiP can make use of an incomplete LU preconditioner when using the iterative 'gmres', 'lgmres', and 'bicgstab' solvers by setting use_precond=True. The preconditioner optionally makes use of a combination of symmetric and anti-symmetric matrix permutations that attempt to improve the preconditioning process. These features are discussed in the Additional Solver Arguments section. Even with these state-of-the-art permutations, the generation of a successful preconditoner for non-symmetric matrices is currently a trial-and-error process due to the lack of mathematical work done in this area. It is always recommended to begin with the direct solver with no additional arguments before selecting a different method.

Finding the steady-state solution is not limited to the Lindblad form of the master equation. Any time-independent Liouvillian constructed from a Hamiltonian and collapse operators can be used as an input:

rho_ss = steadystate(L)

where L is the Louvillian. All of the additional arguments can also be used in this case.

Additional Solver Arguments

The following additional solver arguments are available for the steady-state solver:

Keyword Options (default listed first) Description
method 'direct', 'eigen', 'power', 'iterative-gmres','iterative-lgmres', 'svd', 'power-gmres', 'power-lgmres', 'power-bicgstab' Method used for solving for the steady-state density matrix.
sparse True, False Use sparse version of direct solver.
return_info False, True Return a dictionary of solver-specific information about the solution and how it was obtained.
weight None Allows the user to define the weighting factor used in the 'direct', 'iterative-gmres', 'iterative-lgmres', and 'iterative-bicgstab' solvers.
tol 1e-12 Tolerance used in finding the solution for all methods expect ``'direct'`` and ``'svd'``.
permc_spec 'COLAMD', 'NATURAL' Ordering used for the sparse LU decomposition.
use_rcm False, True Use a Reverse Cuthill-Mckee reordering to minimize the bandwidth of the modified Liouvillian used in the LU decomposition. If ``use_rcm=True`` then the column ordering is set to ``'Natural'`` automatically unless explicitly set.
use_wbm False, True Use a Weighted Bipartite Matching algorithm to attempt to make the modified Liouvillian more diagonally dominate, and thus for favorable for preconditioning.
use_umfpack False, True Use the umfpack solver rather than the default superLU. In SciPy 0.14+, this option requires installing the scikits.umfpack extension.
use_precond False, True Attempt to generate a preconditioner when using the ``'iterative-gmres'``, ``'iterative-lgmres'``, and ``'iterative-bicgstab'`` methods.
M None, sparse_matrix, LinearOperator A user defined preconditioner, if any.
maxiter 1000 Maximum number of iterations to perform for all methods expect ``'direct'`` and ``'svd'``.
fill_factor 100 Upper-bound on the allowed fill-in for the approximate inverse preconditioner.,This value may need to be set much higher than this in many cases.
drop_tol 1e-4 Sets the threshold for the relative magnitude of preconditioner elements that should be dropped. A lower number yields a more accurate approximate inverse at the expense of fill-in and increased runtime.
diag_pivot_thresh None Sets the threshold between $[0,1]$ for which diagonal elements are considered acceptable pivot points when using a preconditioner.
x0 None Optional guess for initial solution vector.
restart 20 Number of iterations before GMRES restarts.
ILU_MILU 'smilu_2' Type of iLU factorization to perform.

Example: Harmonic Oscillator in Thermal Bath


In [15]:
N = 20  # number of basis states to consider
a = destroy(N)
H = a.dag() * a
psi0 = basis(N, 10)  # initial state
kappa = 0.1  # coupling to the bath
c_op_list = []
n_th_a = 2  # temperature with average of 2 excitations
rate = kappa * (1 + n_th_a)
c_op_list.append(np.sqrt(rate) * a)  # decay operators
rate = kappa * n_th_a
c_op_list.append(np.sqrt(rate) * a.dag())  # excitation operators

#Steady state solution
final_state = steadystate(H, c_op_list)
fexpt = expect(a.dag() * a, final_state)

#Dynamical solutions
tlist = linspace(0, 50, 100)
mcdata = mcsolve(H, psi0, tlist, c_op_list, [a.dag() * a], ntraj=100)
medata = mesolve(H, psi0, tlist, c_op_list, [a.dag() * a])

#Plot results
figure(figsize=(6,4))
plot(tlist, mcdata.expect[0], tlist, medata.expect[0], lw=2)
axhline(y=fexpt, color='r', lw=1.5) # ss expt. value as horiz line (= 2)
ylim([0, 10])
xlabel('Time', fontsize=14)
ylabel('Number of excitations', fontsize=14)
legend(('Monte-Carlo', 'Master Equation', 'Steady State'))
title('Decay of Fock state $\left|10\\rangle\\right.$' +
      ' in a thermal environment with $\langle n\\rangle=2$', fontsize=14)
show()


10.0%. Run time:   0.29s. Est. time left: 00:00:00:02
20.0%. Run time:   0.57s. Est. time left: 00:00:00:02
30.0%. Run time:   0.84s. Est. time left: 00:00:00:01
40.0%. Run time:   1.05s. Est. time left: 00:00:00:01
50.0%. Run time:   1.26s. Est. time left: 00:00:00:01
60.0%. Run time:   1.48s. Est. time left: 00:00:00:00
70.0%. Run time:   1.81s. Est. time left: 00:00:00:00
80.0%. Run time:   2.14s. Est. time left: 00:00:00:00
90.0%. Run time:   2.41s. Est. time left: 00:00:00:00
100.0%. Run time:   2.69s. Est. time left: 00:00:00:00
Total run time:   2.72s

In [1]:
from IPython.core.display import HTML
def css_styling():
    styles = open("../styles/guide.css", "r").read()
    return HTML(styles)
css_styling()


Out[1]: