{ "metadata": { "name": "", "signature": "sha256:a36f02a255d513e6d41f87171c0a71f3237474457335e7176f7812ccb2685b6d" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lecture 14: Kerr nonlinearities\n", "\n", "Author: J.R. Johansson, robert@riken.jp\n", "\n", "http://jrjohansson.github.io\n", "\n", "Latest version of this ipython notebook is available at: http://github.com/jrjohansson/qutip-lectures" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "from numpy import *" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import HTML" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "from matplotlib import animation" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "from qutip import *" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "\n", "The Kerr effect describes a self-interaction electromagnetic quantum field which occur in a nonlinear medium. A single mode of the quantum field can be described by the effective Hamiltonian\n", "\n", "$\\displaystyle H = \\frac{1}{2}\\chi (a^\\dagger)^2a^2$\n", "\n", "where $\\chi$ is related to the third-order nonlinear suseptibility. The Kerr effect is one of the typical nonlinearities that can occur in quantum optics due to a nonlinear medium.\n", "\n", "In this notebook we'll see how to setup the model in QuTiP and look at some interesting properties of the states that evolve according to this Hamiltonian." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Parameters" ] }, { "cell_type": "code", "collapsed": false, "input": [ "N = 15\n", "chi = 1 * 2 * pi # Kerr-nonlinearity\n", "tlist = linspace(0, 1.0, 101) # time" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "# operators: the annihilation operator of the field\n", "a = destroy(N)\n", "\n", "# and we'll also need the following operators in calculation of\n", "# expectation values when visualizing the dynamics \n", "n = num(N)\n", "x = a + a.dag()\n", "p = -1j * (a - a.dag())" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "# the Kerr Hamiltonian\n", "H = 0.5 * chi * a.dag() * a.dag() * a * a" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Functions for plotting\n", "\n", "We start by defining some function for visualizing the dynamics. We'll use these further down in the notebook. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "def plot_expect_with_variance(N, op_list, op_title, states):\n", " \"\"\"\n", " Plot the expectation value of an operator (list of operators)\n", " with an envelope that describes the operators variance.\n", " \"\"\"\n", " \n", " fig, axes = plt.subplots(1, len(op_list), figsize=(14,3))\n", "\n", " for idx, op in enumerate(op_list):\n", " \n", " e_op = expect(op, states)\n", " v_op = variance(op, states)\n", "\n", " axes[idx].fill_between(tlist, e_op - sqrt(v_op), e_op + sqrt(v_op), color=\"green\", alpha=0.5);\n", " axes[idx].plot(tlist, e_op)\n", " axes[idx].set_xlabel('Time')\n", " axes[idx].set_title(op_title[idx])\n", " axes[idx].set_xlim(0, max(tlist))\n", "\n", " return fig, axes" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "def plot_wigner(rho, fig=None, ax=None):\n", " \"\"\"\n", " Plot the Wigner function and the Fock state distribution given a density matrix for\n", " a harmonic oscillator mode.\n", " \"\"\"\n", " \n", " if fig is None or ax is None:\n", " fig, ax = plt.subplots(1, 1, figsize=(8,8))\n", "\n", " if isket(rho):\n", " rho = ket2dm(rho)\n", " \n", " xvec = linspace(-7.5,7.5,200)\n", "\n", " W = wigner(rho, xvec, xvec)\n", " wlim = abs(W).max()\n", "\n", " ax.contourf(xvec, xvec, W, 100, norm=mpl.colors.Normalize(-wlim,wlim), cmap=mpl.cm.get_cmap('RdBu'))\n", " ax.set_xlabel(r'$x_1$', fontsize=16)\n", " ax.set_ylabel(r'$x_2$', fontsize=16)\n", "\n", " return fig, ax" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "def plot_fock_distribution_vs_time(tlist, states, fig=None, ax=None):\n", " \n", " Z = zeros((len(tlist), states[0].shape[0]))\n", " \n", " for state_idx, state in enumerate(states):\n", " Z[state_idx,:] = real(ket2dm(state).diag())\n", " \n", " if fig is None or axes is None:\n", " fig, ax = plt.subplots(1, 1, figsize=(8,6))\n", "\n", " Y, X = meshgrid(tlist, range(states[0].shape[0]))\n", " p = ax.pcolor(X, Y, Z.T, norm=mpl.colors.Normalize(0, 0.5), cmap=mpl.cm.get_cmap('Reds'), edgecolors='k')\n", " ax.set_xlabel(r'$N$', fontsize=16)\n", " ax.set_ylabel(r'$t$', fontsize=16) \n", " \n", " cb = fig.colorbar(p)\n", " cb.set_label('Probability')\n", " \n", " return fig, ax" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [ "from base64 import b64encode\n", "\n", "def display_embedded_video(filename):\n", " video = open(filename, \"rb\").read()\n", " video_encoded = b64encode(video).decode(\"ascii\")\n", " video_tag = '