Skip to content

Commit

Permalink
Added arrows by default and set play to default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor-96 committed Oct 7, 2023
1 parent 4f2c566 commit 2345c8b
Showing 1 changed file with 72 additions and 9 deletions.
81 changes: 72 additions & 9 deletions notebook/lattice-vibration/Phonon_1D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"\n",
"## **Tasks and exercises**\n",
"\n",
"1. Visualize the lattice vibration at $k=0$ and $k=\\frac{\\pi}{a}$, what characteristics do you observe ? \n",
"1. Visualize the lattice vibration at $k=0$ and $k=\\frac{\\pi}{a}$. What characteristics do you observe ? \n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" The atom indexed $n$ has a displacement given by $u=\\exp(i(n\\cdot ka-\\omega t))$.\n",
Expand Down Expand Up @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -90,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -108,6 +108,20 @@
" }, false);\n",
"\"\"\")\n",
"\n",
"stop = False\n",
"def loop(view):\n",
" import time\n",
" def do():\n",
" while True and not stop:\n",
" if view.frame == view.max_frame:\n",
" view.frame = 0\n",
" view.frame = view.frame + 1\n",
" time.sleep(0.2)\n",
" view._run_on_another_thread(do)\n",
" \n",
"view = handler.view \n",
"view.on_displayed(loop)\n",
"\n",
"widgets=[\n",
" handler.slider_C,\n",
" handler.slider_M,\n",
Expand All @@ -119,7 +133,8 @@
"\n",
"handler.slider_atom_radius.value=0.1\n",
"handler.slider_arrow_radius.value=0.1\n",
"handler.tick_box_arrows.value=False\n",
"handler.tick_box_arrows.value=True\n",
"handler.addArrows() # add arrows by default\n",
"handler.set_player_parameters(delay=handler.init_delay)\n",
"handler.set_view_parameters(clipDist=1,quality='low')\n",
"\n",
Expand All @@ -138,6 +153,8 @@
"handler.view.stage.set_parameters(mouse_preset=\"pymol\")\n",
"\n",
"\n",
"\n",
"\n",
"chain= HBox([handler.button_chain_description,handler.button_chain])\n",
"mass_ratio=handler.output_ratio\n",
"click=HTMLMath(value='''Click on the plot to get the corresponding phonon''')\n",
Expand Down Expand Up @@ -206,9 +223,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 36,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<style>\n",
".box_style{\n",
" border : 2px solid red;\n",
"}\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%html\n",
"<style>\n",
Expand All @@ -220,9 +254,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 37,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5fcc7dc436fc4fb49e968f36b35ce6ec",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Tab(children=(HBox(children=(VBox(children=(HBox(children=(HTMLMath(value='Atomic chain type', …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b58c0b65f41e420f953144a81ec71577",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(NGLWidget(max_frame=50),), layout=Layout(align_items='center', display='flex', flex_flow='colum…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(actions,HBox([handler.view],layout=layout).add_class(\"box_style\"))\n"
]
Expand Down Expand Up @@ -297,7 +360,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 2345c8b

Please sign in to comment.