{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Investigating the reflectionless potential using the split-step algorithm\n", "\n", "The [reflectionless potential](http://www.physicspages.com/2012/08/27/reflectionless-potential/) has the following functional form:\n", "\\begin{equation}\n", " V(x) = -\\frac{\\hbar^2a^2}{m}sech^2(ax)\n", "\\end{equation}\n", "\n", "By comparing the propagation of a Gaussian wavepacket in this reflectionless potential to a similar strength and width square well, this unique behaviour can be observed.\n", "\n", "For an explaination of the split-step method see the [previous notebook](split_step_schrodinger.ipynb)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#NAME: Reflectionless Potential (1D)\n", "#DESCRIPTION: Investigating the reflectionless potential in 1D using the split-step algorithm.\n", "\n", "import pycav.display as display" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example Animation" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "display.display_animation('reflectionless.mp4')" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "display.display_animation('reflection.mp4')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Below is the code used to produce these examples\n", "\n", "Starting with a Gaussian wavepacket incident on the potential barrier, the width and depth of potential is modified by the parameter $a$." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "\n", "import pycav.pde as pde\n", "import matplotlib.pyplot as plt\n", "import matplotlib.animation as anim\n", "\n", "def oneD_gaussian(x,mean,std,k0):\n", " return np.exp(-((x-mean)**2)/(4*std**2)+ 1j*x*k0)/(2*np.pi*std**2)**0.25\n", "\n", "def V(x):\n", " V_x = np.zeros_like(x)\n", " a = 1.5\n", " x_mid = (x.max()+x.min())/2.\n", " V_x = -a**2*(1/np.cosh(a*(x-x_mid)))**2\n", " return V_x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We must define the spatial domain as well as the time step size and number of steps. Then the initial wavefunction is passed to the split step algorithm." ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [], "source": [ "N_x = 2**11\n", "dx = 0.05\n", "x = dx * (np.arange(N_x) - 0.5 * N_x)\n", "\n", "dt = 0.01\n", "N_t = 2000\n", "\n", "p0 = 2.0\n", "d = np.sqrt(N_t*dt/2.)\n", "\n", "psi_0 = oneD_gaussian(x,x.max()-10*d,d,-p0)\n", "\n", "psi_x,psi_k,k = pde.split_step_schrodinger(psi_0, dx, dt, V, N_t, x_0 = x[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The time evolution can then be animated showing the expected behaviour. The momentum space wavefunction can also be visualised (here shown in the second subplot)." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "real_psi = np.real(psi_x)\n", "imag_psi = np.imag(psi_x)\n", "absl_psi = np.absolute(psi_x)\n", "abs_psik = np.absolute(psi_k)\n", "\n", "fig = plt.figure(figsize = (10,10))\n", "ax1 = plt.subplot(211)\n", "line1_R = ax1.plot(x,real_psi[:,0],'b')[0]\n", "line1_I = ax1.plot(x,imag_psi[:,0],'r')[0]\n", "line1_A = ax1.plot(x,absl_psi[:,0],'k')[0]\n", "line_V = ax1.plot(x,0.5*V(x),'k',alpha=0.5)[0]\n", "ax1.set_ylim((real_psi.min(),real_psi.max()))\n", "ax1.set_xlim((x.min(),x.max()))\n", "\n", "ax2 = plt.subplot(212)\n", "line2 = ax2.plot(k,abs_psik[:,1],'k')[0]\n", "ax2.set_ylim((abs_psik.min(),abs_psik.max()))\n", "ax2.set_xlim((-5,5))\n", "\n", "def nextframe(arg):\n", " line1_R.set_data(x,real_psi[:,10*arg])\n", " line1_I.set_data(x,imag_psi[:,10*arg])\n", " line1_A.set_data(x,absl_psi[:,10*arg])\n", " line2.set_data(k,abs_psik[:,10*arg])\n", " \n", "animate = anim.FuncAnimation(fig, nextframe, frames = int(N_t/10), interval = 50, repeat = False)\n", "animate = display.create_animation(animate,temp = True)\n", "display.display_animation(animate)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [default]", "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.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }