# Lecture 2 - Symbolic quantum mechanics using SymPsi - Two-level systems¶

Author: J. R. Johansson ([email protected]), http://jrjohansson.github.io.

Status: Preliminary (work in progress)

This notebook is part of a series of IPython notebooks on symbolic quantum mechanics computations using SymPy and SymPsi. SymPsi is an experimental fork and extension of the sympy.physics.quantum module in SymPy. The latest version of this notebook is available at http://github.com/jrjohansson/sympy-quantum-notebooks, and the other notebooks in this lecture series are also indexed at http://jrjohansson.github.io.

Requirements: A recent version of SymPy and the latest development version of SymPsi is required to execute this notebook. Instructions for how to install SymPsi is available here.

Disclaimer: The SymPsi module is still under active development and may change in behavior without notice, and the intention is to move some of its features to sympy.physics.quantum when they matured and have been tested. However, these notebooks will be kept up-to-date the latest versions of SymPy and SymPsi.

## Setup modules¶

In [1]:
from sympy import *
init_printing()

In [2]:
from sympsi import *
from sympsi.pauli import *


## Introduction: Hamiltonian and Pauli matrices¶

One of the simplest possible quantum system is the two-level system, such as a spin-$1/2$, or an atom or artificial-atom (nano-device) with (effectively) only two quantum states.

The Hamiltonian for a two-level quantum system is conveniently written in terms of the Pauli matrices $\sigma_x$, $\sigma_y$ and $\sigma_z$, and their annihilation and creation operators $\sigma_-$ and $\sigma_+$. In terms of these operators we can write the Hamiltonian on the form:

$$H = -\frac{1}{2}\Delta\sigma_x - \frac{1}{2}\epsilon\sigma_z$$

where $\epsilon$ is the bare energy splitting and $\Delta$ is the tunneling rate between the two states of the two-level system.

In SymPy we can represent this Hamiltonian as:

In [3]:
theta, t = symbols("theta, t")
eps, Delta, Omega = symbols("epsilon, Delta, Omega", positive=True)
Hsym = symbols("H")

In [4]:
sx, sy, sz = SigmaX(), SigmaY(), SigmaZ()

In [5]:
H = -eps/2 * sz - Delta/2 * sx

Eq(Hsym, H)

Out[5]:
$$H = - \frac{\Delta {\sigma_x}}{2} - \frac{\epsilon {\sigma_z}}{2}$$

## Instantaneous eigenbasis¶

Is often convenient to perform basis transformation that simplifies the Hamiltonian. For example, we can transform the Hamiltonian to the eigenbasis (where the Hamiltonian is diagonal, that is only containing a $\sigma_z$ term) by applying the unitary tranformation:

In [6]:
U = exp(I * theta/2 * sy); U

Out[6]:
$$e^{\frac{i \theta}{2} {\sigma_y}}$$

This unitary tranformation transforms the operators in the Hamiltonian according to these well-known relations:

In [7]:
hamiltonian_transformation(U, sx)

Out[7]:
$$\sin{\left (\theta \right )} {\sigma_z} + \cos{\left (\theta \right )} {\sigma_x}$$
In [8]:
hamiltonian_transformation(U, sz)

Out[8]:
$$- \sin{\left (\theta \right )} {\sigma_x} + \cos{\left (\theta \right )} {\sigma_z}$$

so the Hamiltonian after this transformation takes the form

In [9]:
H1 = hamiltonian_transformation(U, H)

H1

Out[9]:
$$- \frac{\Delta}{2} \left(\sin{\left (\theta \right )} {\sigma_z} + \cos{\left (\theta \right )} {\sigma_x}\right) - \frac{\epsilon}{2} \left(- \sin{\left (\theta \right )} {\sigma_x} + \cos{\left (\theta \right )} {\sigma_z}\right)$$
In [10]:
H2 = collect(H1.expand(), (sx, sz))

H2

Out[10]:
$$\left(- \frac{\Delta}{2} \sin{\left (\theta \right )} - \frac{\epsilon}{2} \cos{\left (\theta \right )}\right) {\sigma_z} + \left(- \frac{\Delta}{2} \cos{\left (\theta \right )} + \frac{\epsilon}{2} \sin{\left (\theta \right )}\right) {\sigma_x}$$

In the eigenbasis we require the coefficient of $\sigma_x$ to be zero, so we have the condition:

In [11]:
c, o = split_coeff_operator(H2.args[0])

Eq(c, 0)

Out[11]:
$$- \frac{\Delta}{2} \cos{\left (\theta \right )} + \frac{\epsilon}{2} \sin{\left (\theta \right )} = 0$$

with the solution

In [12]:
Eq(tan(theta), Delta/eps)

Out[12]:
$$\tan{\left (\theta \right )} = \frac{\Delta}{\epsilon}$$

Substituting this into the Hamiltonian results in

In [13]:
H3 = simplify(H2.subs(theta, atan(Delta/eps)))

H3

Out[13]:
$$- \frac{{\sigma_z}}{2} \sqrt{\Delta^{2} + \epsilon^{2}}$$

Now introduce $\Omega = \sqrt{\Delta^2 + \epsilon^2}$, which is the eigenenergies of the two-level system:

In [14]:
H3.subs(Delta, sqrt(Omega ** 2 - eps ** 2))

Out[14]:
$$- \frac{\Omega {\sigma_z}}{2}$$

In summary, to reach this basis, we have transformed $\sigma_x$ and $\sigma_z$ as:

In [15]:
hamiltonian_transformation(U, sx)

Out[15]:
$$\sin{\left (\theta \right )} {\sigma_z} + \cos{\left (\theta \right )} {\sigma_x}$$
In [16]:
hamiltonian_transformation(U, sz)

Out[16]:
$$- \sin{\left (\theta \right )} {\sigma_x} + \cos{\left (\theta \right )} {\sigma_z}$$

and chosen $\theta = \arctan(\Delta/\epsilon)$.

## Versions¶

In [17]:
%reload_ext version_information

%version_information sympy, sympsi

Out[17]:
SoftwareVersion
Python3.4.1 (default, Sep 20 2014, 19:44:17) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]
IPython2.3.0
OSDarwin 13.4.0 x86_64 i386 64bit
sympy0.7.5-git
sympsi0.1.0.dev-0c6e514
Thu Oct 09 15:23:41 2014 JST