{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "import numpy as np\n", "import scipy.special\n", "import scipy.misc\n", "\n", "r = lambda x,y,z: np.sqrt(x**2+y**2+z**2)\n", "theta = lambda x,y,z: np.arccos(z/r(x,y,z))\n", "phi = lambda x,y,z: np.arctan(y/x)\n", "\n", "a0 = 1.\n", "R = lambda r,n,l: (2*r/n/a0)**l * np.exp(-r/n/a0) * scipy.special.genlaguerre(n-l-1,2*l+1)(2*r/n/a0)\n", "WF = lambda r,theta,phi,n,l,m: R(r,n,l) * scipy.special.sph_harm(m,l,phi,theta)\n", "absWF = lambda r,theta,phi,n,l,m: abs(WF(r,theta,phi,n,l,m))**2\n", "N=100j\n", "a = 200.0\n", "x,y,z = np.ogrid[-a:a:N,-a:a:N,-a:a:N]\n", "x = x.astype(np.float32)\n", "y = y.astype(np.float32)\n", "z = z.astype(np.float32)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "orbital = absWF(r(x,y,z),theta(x,y,z),phi(x,y,z),1,0,0) # 1s" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = k3d.plot()\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.grid_auto_fit = False" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "E = 10\n", "volume_animation = {}\n", "label_animation = {}\n", "i = 0\n", "\n", "for l in range(E):\n", " print(l, '/', E-1, end='\\r')\n", " for m in range(-l,l+1):\n", " psi2 = absWF(r(x, y, z), theta(x, y, z), phi(x, y, z), E, l, m)\n", " \n", " volume_animation[str(i)] = (psi2/np.max(psi2))\n", " label_animation[str(i)] = 'n=%d \\quad l=%d \\quad m=%d' % (E,l,m)\n", " \n", " i += 0.1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot += k3d.text2d(label_animation, (0.,0.))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "plot += k3d.volume(volume_animation, color_map=k3d.colormaps.basic_color_maps.CoolWarm, \n", " color_range=(0.0,0.1))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.array(volume_animation).tolist()['0'].dtype" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.colorbar_object_id = 0" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.start_auto_play()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.stop_auto_play()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "finalized": { "timestamp": 1588633465952, "trusted": true }, "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }