From c9acdf66bfdafb8e55f98506161677f417b286e5 Mon Sep 17 00:00:00 2001 From: Robert Johansson Date: Fri, 23 Jan 2015 11:54:10 +0900 Subject: [PATCH] updated notebook for qutip 3.1.0 --- ...ueezed-states-of-harmonic-oscillator.ipynb | 2538 +---------------- 1 file changed, 60 insertions(+), 2478 deletions(-) diff --git a/Lecture-9-Squeezed-states-of-harmonic-oscillator.ipynb b/Lecture-9-Squeezed-states-of-harmonic-oscillator.ipynb index ebfd060..990abd4 100644 --- a/Lecture-9-Squeezed-states-of-harmonic-oscillator.ipynb +++ b/Lecture-9-Squeezed-states-of-harmonic-oscillator.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:389a3295cb8e41366e5e1f24a6961e9da9e8dad1bfdfce337ca61a9e95fd89a8" }, "nbformat": 3, "nbformat_minor": 0, @@ -93,13 +94,13 @@ "collapsed": false, "input": [ "N = 35\n", - "w = 1 * 2 * pi # oscillator frequency\n", + "w = 1 * 2 * np.pi # oscillator frequency\n", "tlist = np.linspace(0, 4, 101) # periods" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 5 + "prompt_number": 4 }, { "cell_type": "code", @@ -108,13 +109,13 @@ "# operators\n", "a = destroy(N)\n", "n = num(N)\n", - "x = (a + a.dag())/sqrt(2)\n", - "p = -1j * (a - a.dag())/sqrt(2)" + "x = (a + a.dag())/np.sqrt(2)\n", + "p = -1j * (a - a.dag())/np.sqrt(2)" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 6 + "prompt_number": 5 }, { "cell_type": "code", @@ -126,7 +127,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 7 + "prompt_number": 6 }, { "cell_type": "code", @@ -135,12 +136,12 @@ "c_ops = []\n", "\n", "# uncomment to see how things change when disspation is included\n", - "# c_ops = [sqrt(0.25) * a]" + "# c_ops = [np.sqrt(0.25) * a]" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 8 + "prompt_number": 7 }, { "cell_type": "markdown", @@ -168,7 +169,7 @@ " 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].fill_between(tlist, e_op - np.sqrt(v_op), e_op + np.sqrt(v_op), color=\"green\", alpha=0.5);\n", " axes[idx].plot(tlist, e_op, label=\"expectation\")\n", " axes[idx].set_xlabel('Time')\n", " axes[idx].set_title(op_title[idx])\n", @@ -178,22 +179,24 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 9 + "prompt_number": 8 }, { "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 = video.encode(\"base64\")\n", + " video_encoded = b64encode(video).decode(\"ascii\")\n", " video_tag = '