{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# QuTiP example: eseries" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "J.R. Johansson and P.D. Nation\n", "\n", "For more information about QuTiP see [http://qutip.org](http://qutip.org)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from numpy import pi" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from qutip import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example eseries object: $\\sigma_x \\exp(i\\omega t)$" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "omega = 1.0\n", "es1 = eseries(sigmax(), 1j * omega)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 1 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example eseries object: $\\sigma_x \\cos(\\omega t)$" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "omega = 1.0\n", "es2 = eseries(0.5 * sigmax(), 1j * omega) + eseries(0.5 * sigmax(), -1j * omega)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 0.5]\n", " [ 0.5 0. ]]\n", "Exponent #1 = -1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 0.5]\n", " [ 0.5 0. ]]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Evaluate eseries object at time $t = 0$" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0\\\\1.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "esval(es2, 0.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Evaluate eseries object at array of times $t = [0, \\pi, 2\\pi]$" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]],\n", " Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. -1.]\n", " [-1. 0.]],\n", " Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]], dtype=object)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tlist = [0.0, 1.0 * pi, 2.0 * pi]\n", "esval(es2, tlist)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Expectation values of eseries" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 0.5]\n", " [ 0.5 0. ]]\n", "Exponent #1 = -1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 0.5]\n", " [ 0.5 0. ]]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es2" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[1, 1]]\n", "Exponent #0 = 1j\n", "1.0\n", "Exponent #1 = -1j\n", "1.0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "expect(sigmax(), es2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Arithmetics with eseries" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 1 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es1 = eseries(sigmax(), 1j * omega)\n", "es1" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 1 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = -1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es2 = eseries(sigmax(), -1j * omega)\n", "es2" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]\n", "Exponent #1 = -1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es1 + es2" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]\n", "Exponent #1 = -1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. -1.]\n", " [-1. 0.]]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es1 - es2" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 1 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 0j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 1.]]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es1 * es2" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = 2j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 1.]]\n", "Exponent #1 = -2j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[-1. 0.]\n", " [ 0. -1.]]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(es1 + es2) * (es1 - es2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Expectation values of eseries" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[2], [2]]\n", "Exponent #0 = (-0-1j)\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[ 0.5+0.j 0.0+0.5j]\n", " [ 0.0+0.5j -0.5+0.j ]]\n", "Exponent #1 = 1j\n", "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[ 0.5+0.j 0.0-0.5j]\n", " [ 0.0-0.5j -0.5+0.j ]]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es3 = eseries([0.5*sigmaz(), 0.5*sigmaz()], [1j, -1j]) + eseries([-0.5j*sigmax(), \n", " 0.5j*sigmax()], [1j, -1j])\n", "es3" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}1.0 & 0.0\\\\0.0 & -1.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. -1.]]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es3.value(0.0)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0\\\\1.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 1.]\n", " [ 1. 0.]]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es3.value(pi/2)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ESERIES object: 2 terms\n", "Hilbert space dimensions: [[1, 1]]\n", "Exponent #0 = (-0-1j)\n", "(-0.5+0j)\n", "Exponent #1 = 1j\n", "(-0.5+0j)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho = fock_dm(2, 1)\n", "es3_expect = expect(rho, es3)\n", "\n", "es3_expect" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ -1.00000000e+00, -6.12323400e-17])" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "es3_expect.value([0.0, pi/2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Versions" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Software | Version |
---|---|
QuTiP | 4.2.0 |
Numpy | 1.13.1 |
SciPy | 0.19.1 |
matplotlib | 2.0.2 |
Cython | 0.25.2 |
Number of CPUs | 2 |
BLAS Info | INTEL MKL |
IPython | 6.1.0 |
Python | 3.6.1 |Anaconda custom (x86_64)| (default, May 11 2017, 13:04:09) \n", "[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] |
OS | posix [darwin] |
Wed Jul 19 22:16:28 2017 MDT |