From e22b3f4fc4b93a7da28b17abaf856f47b6398375 Mon Sep 17 00:00:00 2001 From: Taylor Date: Mon, 29 Apr 2024 22:02:10 +0200 Subject: [PATCH] Fixed matplotlib errors in shooting method notebook. Resolved issue with using nested boxes in voila for displaying widgets side-by-side by using AppLayout instead. --- .../quantum-mechanics/shooting_method.ipynb | 87 ++++++++++++++++--- 1 file changed, 73 insertions(+), 14 deletions(-) diff --git a/notebook/quantum-mechanics/shooting_method.ipynb b/notebook/quantum-mechanics/shooting_method.ipynb index b24f050..e9ef905 100644 --- a/notebook/quantum-mechanics/shooting_method.ipynb +++ b/notebook/quantum-mechanics/shooting_method.ipynb @@ -106,7 +106,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -121,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -221,9 +221,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0c205274437f4883b6b9a654632ebc51", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(VBox(children=(Label(value='Targeted eigenvalue'), HBox(children=(FloatSlider(value=-0.03, layo…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7befa6aa973542e698ef88e678524448", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "mu = 0.06 # Potential parameter\n", "L = 1.5 # x range [-L,L]\n", @@ -363,8 +392,8 @@ "\n", "def on_width_change(change):\n", " global ew, ef, x, dx, V\n", - " ax[0].lines.clear()\n", - " ax[1].lines.clear()\n", + " ax[0].clear()\n", + " ax[1].clear()\n", " \n", " try:\n", " ann.remove()\n", @@ -377,8 +406,8 @@ "\n", "def on_depth_change(change):\n", " global ew, ef, x, dx, V\n", - " ax[0].lines.clear()\n", - " ax[1].lines.clear()\n", + " ax[0].clear()\n", + " ax[1].clear()\n", " \n", " try:\n", " ann.remove()\n", @@ -391,8 +420,8 @@ " loop1.max = max(V)\n", " \n", "def on_xfak_change(change):\n", - " ax[0].lines.clear()\n", - " ax[1].lines.clear()\n", + " ax[0].clear()\n", + " ax[1].clear()\n", " \n", " try:\n", " ann.remove()\n", @@ -455,7 +484,8 @@ "label3 = Label(value=\"(click on a state to select it)\")\n", "label4 = Label(value=\"(tune to zoom the eigenfunctions)\")\n", "\n", - "display(HBox([VBox([label1, HBox([loop1, loop2, loop3, loop4]), Leng, search, order, label2, flip]), output]))" + "full_layout=HBox([VBox([label1, HBox([loop1, loop2, loop3, loop4]), Leng, search, order, label2, flip]),output])\n", + "display(full_layout)" ] }, { @@ -467,9 +497,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d36195895f1c408c806c02869c447a75", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(FloatSlider(value=1.2, description='Width: ', max=2.0, min=0.1), FloatSlider(value=0.2, descrip…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "028876bb1fec458ab2cf5bc547bd4011", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(HBox(children=(FloatSlider(value=3.0, description='Zoom factor: ', max=5.0, min=1.0, step=0.5),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "display(HBox([swidth, sdepth]), VBox([HBox([sfak, label4]), HBox([update, label3])]))" ] @@ -535,7 +594,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.10.12" }, "voila": { "authors": "Dou Du and Giovanni Pizzi"