{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Two-Level: Collision of Two 2π Pulses" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "SECH_FWHM_CONV = 1.0 / 2.6339157938\n", "t_width_1 = 2.0 * SECH_FWHM_CONV # [τ]\n", "print(\"t_width\", t_width_1)\n", "# n = 2.0 # For a pulse area of nπ\n", "# ampl_1 = n/t_width_1/(2*np.pi) # Pulse amplitude [2π Γ]\n", "# print('ampl_1', ampl_1)\n", "\n", "t_width_2 = 1.0 * SECH_FWHM_CONV # [τ]\n", "# ampl_2 = n/t_width_2/(2*np.pi)\n", "# print('t_width_2', t_width_2)\n", "# print('ampl_2', ampl_2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mb_solve_json = \"\"\"\n", "{\n", " \"atom\": {\n", " \"fields\": [\n", " {\n", " \"coupled_levels\": [[0, 1]]\n", " }\n", " ],\n", " \"num_states\": 2\n", " },\n", " \"t_min\": -5.0,\n", " \"t_max\": 25.0,\n", " \"t_steps\": 240,\n", " \"z_min\": -0.5,\n", " \"z_max\": 1.5,\n", " \"z_steps\": 200,\n", " \"interaction_strengths\": [\n", " 10.0\n", " ],\n", " \"savefile\": \"mbs-two-sech-2pi-collision\"\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": [ "from maxwellbloch import t_funcs\n", "\n", "probe_field = mbs.atom.fields[0]\n", "two_pulse_t_func = lambda t, args: t_funcs.sech(1)(t, args) + t_funcs.sech(2)(t, args)\n", "probe_field.rabi_freq_t_func = two_pulse_t_func\n", "probe_field.rabi_freq_t_args = {\n", " \"n_pi_2\": 2.0,\n", " \"centre_2\": 5.0,\n", " \"width_2\": t_width_2,\n", " \"n_pi_1\": 2.0,\n", " \"centre_1\": 0.0,\n", " \"width_1\": t_width_1,\n", "}\n", "\n", "mbs.atom.build_H_Omega() # We have to rebuild H_Omega\n", "mbs.init_Omegas_zt();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll just check that the pulse area is what we want. Should be 4π" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\n", " \"The input pulse area is {0:.4f}π\".format(\n", " np.trapezoid(mbs.Omegas_zt[0, 0, :].real, mbs.tlist) / np.pi\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "%matplotlib inline\n", "import seaborn as sns\n", "\n", "sns.set_style(\"darkgrid\")\n", "\n", "plt.plot(mbs.tlist, np.abs(mbs.Omegas_zt[0, 0, :]));" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solve the Problem" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Omegas_zt, states_zt = mbs.mbsolve(recalc=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot Output" ] }, { "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\")\n", "fig = plt.figure(1, figsize=(16, 6))\n", "ax = fig.add_subplot(111)\n", "cmap_range = np.linspace(0.0, 1.0, 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);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pulse area" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(16, 4))\n", "ax.plot(mbs.zlist, mbs.fields_area()[0] / np.pi, clip_on=False)\n", "# ax.set_ylim([0.0, 4.0])\n", "ax.set_xlabel(\"Distance ($L$)\")\n", "ax.set_ylabel(r\"Pulse Area ($\\pi$)\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Movie" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# C = 0.1 # speed of light\n", "# Y_MIN = 0.0 # Y-axis min\n", "# Y_MAX = 4.0 # y-axis max\n", "# ZOOM = 2 # level of linear interpolation\n", "# FPS = 60 # frames per second\n", "# ATOMS_ALPHA = 0.2 # Atom indicator transparency" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# FNAME = \"images/mb-solve-two-sech-2pi-collision\"\n", "# FNAME_JSON = FNAME + '.json'\n", "# with open(FNAME_JSON, \"w\") as f:\n", "# f.write(mb_solve_json)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !make-mp4-fixed-frame.py -f $FNAME_JSON -c $C --fps $FPS --y-min $Y_MIN --y-max $Y_MAX \\\n", "# --zoom $ZOOM --atoms-alpha $ATOMS_ALPHA #--peak-line --c-line" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# FNAME_MP4 = FNAME + '.mp4'\n", "# !make-gif-ffmpeg.sh -f $FNAME_MP4 --in-fps $FPS" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# from IPython.display import Image\n", "# Image(url=FNAME_MP4 +'.gif', format='gif')" ] } ], "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 }