{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Two-Level: Weak Square Pulse with Decay" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Define and Solve" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mb_solve_json = \"\"\"\n", "{\n", " \"atom\": {\n", " \"decays\": [\n", " {\n", " \"channels\": [[0, 1]],\n", " \"rate\": 1.0\n", " }\n", " ],\n", " \"energies\": [],\n", " \"fields\": [\n", " {\n", " \"coupled_levels\": [[0, 1]],\n", " \"detuning\": 0.0,\n", " \"rabi_freq\": 1.0e-3,\n", " \"rabi_freq_t_args\": {\n", " \"ampl\": 1.0,\n", " \"on\": -0.5,\n", " \"off\": 0.5\n", " },\n", " \"rabi_freq_t_func\": \"square\"\n", " }\n", " ],\n", " \"num_states\": 2\n", " },\n", " \"t_min\": -2.0,\n", " \"t_max\": 10.0,\n", " \"t_steps\": 100,\n", " \"z_min\": -0.2,\n", " \"z_max\": 1.2,\n", " \"z_steps\": 20,\n", " \"interaction_strengths\": [\n", " 1.0\n", " ]\n", "}\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from maxwellbloch import mb_solve\n", "\n", "mbs = mb_solve.MBSolve().from_json_str(mb_solve_json)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Omegas_zt, states_zt = mbs.mbsolve()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "%matplotlib inline\n", "import numpy as np\n", "import seaborn as sns\n", "\n", "sns.set_style(\"darkgrid\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check the Input Pulse Profile\n", "\n", "We'll just confirm that the input pulse has the profile that we want: a Gaussian with an amplitude of $1.0 \\Gamma$ and a full-width at half maximum (FWHM) of $1.0 \\tau$. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from scipy import interpolate\n", "\n", "plt.plot(mbs.tlist, Omegas_zt[0, 0].real / (2 * np.pi))\n", "\n", "half_max = np.max(Omegas_zt[0, 0].real / (2 * np.pi)) / 2\n", "spline = interpolate.UnivariateSpline(\n", " mbs.tlist, (Omegas_zt[0, 0].real / (2 * np.pi) - half_max), s=0\n", ")\n", "r1, r2 = spline.roots()\n", "\n", "# draw line at FWHM\n", "plt.hlines(y=half_max, xmin=r1, xmax=r2, linestyle=\"dotted\")\n", "plt.annotate(\n", " \"FWHM: \" + \"%0.2f\" % (r2 - r1),\n", " xy=((r2 + r1) / 2, half_max),\n", " xycoords=\"data\",\n", " xytext=(25, 0),\n", " textcoords=\"offset points\",\n", ");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Field Output" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig = plt.figure(1, figsize=(16, 6))\n", "ax = fig.add_subplot(111)\n", "cmap_range = np.linspace(0.0, 1.0e-3, 11)\n", "cf = ax.contourf(\n", " mbs.tlist,\n", " mbs.zlist,\n", " np.abs(mbs.Omegas_zt[0] / (2 * np.pi)),\n", " cmap_range,\n", " cmap=plt.cm.Blues,\n", ")\n", "ax.set_title(r\"Rabi Frequency ($\\Gamma / 2\\pi $)\")\n", "ax.set_xlabel(r\"Time ($1/\\Gamma$)\")\n", "ax.set_ylabel(\"Distance ($L$)\")\n", "for y in [0.0, 1.0]:\n", " ax.axhline(y, c=\"grey\", lw=1.0, ls=\"dotted\")\n", "plt.colorbar(cf);" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }