Skip to content

Commit

Permalink
Set play and loop to default. Added arrows by default. Revised text a…
Browse files Browse the repository at this point in the history
…nd fixed links.
  • Loading branch information
Taylor-96 committed Oct 11, 2023
1 parent 4f2c566 commit 654b149
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 22 deletions.
115 changes: 99 additions & 16 deletions notebook/lattice-vibration/Molecule_Vibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"\n",
"<i class=\"fa fa-home fa-2x\"></i><a href=\"../index.ipynb\" style=\"font-size: 20px\"> Go back to index</a>\n",
"\n",
"**Source code:** https://github.com/osscar-org/quantum-mechanics/blob/develop/notebook/lattice-vibration/Molecule_Vibration.ipynb\n",
"**Source code:** https://github.com/osscar-org/quantum-mechanics/blob/master/notebook/lattice-vibration/Molecule_Vibration.ipynb\n",
"\n",
"\n",
"With this notebook, the concept of molecular vibration is explored and visualized in an interactive fashion.\n",
"With this notebook, vibrational modes within molecules are explored and visualized in an interactive fashion.\n",
"<hr style=\"height:1px;border:none;color:#cccccc;background-color:#cccccc;\" />"
]
},
Expand All @@ -23,9 +23,9 @@
"source": [
"## **Goals**\n",
"\n",
"* Understand normal modes of vibrations.\n",
"* Learn about normal modes and their frequency.\n",
"* Explore the vast variety of vibrational modes."
"* Learn about the nature of vibrational modes within molecules.\n",
"* Investigate the different frequencies and oscillation patterns of these modes.\n",
"* Explore the variety of molecular vibrations and how they arise from the molecular topology."
]
},
{
Expand All @@ -52,7 +52,7 @@
"2. Compare O$_2$ and OH, what do you observe regarding oscillation amplitudes?\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" In a diatomic molecule, the relative amplitudes are given by $A_1=-\\frac{M_2}{M_1}A_2$ (c.f. theory). Therefore, hydrogen being a much lighter element compared to oxygen, its amplitude is much greater. This can be understood intuitively as the hydrogen atom as a much lower inertia than oxygene, and thus when given the same energy, the hydrogen atom will oscillate more easily.\n",
" In a diatomic molecule, the relative amplitudes are given by $A_1=-\\frac{M_2}{M_1}A_2$ (c.f. theory). Therefore, since hydrogen is a much lighter element than oxygen, its amplitude is much greater. This can be understood intuitively: as the hydrogen atom has a much smaller moment of inertia than oxygen, when given the same energy, the hydrogen atom will oscillate more easily.\n",
" </details>\n",
"<br>\n",
"3. Compare H$_2$O and CO$_2$, how many vibrational modes does each one have? Are all CO$_2$ vibrations distinct? Can you explain the difference in energy between vibrational modes? \n",
Expand All @@ -66,7 +66,7 @@
"4. Compute the conversion factor between energy in eV and frequency in cm$^{-1}$.\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" The relation between frequency and energy is given by $E=h\\nu$ with $\\nu$ the frequency. With $[h]=[m^2\\cdot kg\\cdot s^{-1}]$ and $\\lambda=\\frac{c}{\\nu}$, with $c$ the speed of light and $\\lambda$ the wavelength, we have :<br> \n",
" The relation between frequency and energy is given by $E=h\\nu$, with $\\nu$ the frequency. Here, $[h]=[m^2\\cdot kg\\cdot s^{-1}]$ and $\\lambda=\\frac{c}{\\nu}$, with $c$ the speed of light and $\\lambda$ the wavelength, we have :<br> \n",
" $$\\begin{align}\n",
" [eV]&=6.63\\cdot10^{-34}[m^2\\cdot kg\\cdot s^{-1}][Hz]\\\\\n",
" 1.6\\cdot10^{-19}[J]&=6.63\\cdot10^{-34}[m^2\\cdot kg\\cdot s^{-1}]3\\cdot10^8[m\\cdot s^{-1}][m^{-1}]\\\\\n",
Expand All @@ -87,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -100,9 +100,14 @@
"from NGLMoleculeClass import NGLMolecule"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -124,6 +129,21 @@
" }, false);\n",
"\"\"\")\n",
"\n",
"# Cause animation to play and loop by default.\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",
"handler.set_view_dimensions()\n",
"handler.set_view_parameters(clipDist=5)\n",
"handler.set_player_parameters(delay=25)\n",
Expand All @@ -141,6 +161,8 @@
" handler.tick_box_label,\n",
"]\n",
"\n",
"handler.tick_box_arrows.value = True\n",
"\n",
"for widget in widgets:\n",
" handler.widgetList.append(widget)\n",
"\n",
Expand Down Expand Up @@ -223,9 +245,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<style>\n",
".box_style{\n",
" width: 640px;\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 @@ -238,9 +278,52 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c77b3adc86c24f88b0b22ccbde9face6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(GridBox(children=(HBox(children=(HTMLMath(value='Extended list', layout=Layout(width='100px')), …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0eddc78bbbdd458caf3143bef96e6fcd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Label(value='Camera axis: '), Button(description='x', layout=Layout(width='50px'), style=Button…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e827564e1d14efe895a347b9d16e78e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"NGLWidget(max_frame=59, _dom_classes=('box_style',))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(\n",
" tab,\n",
Expand All @@ -261,9 +344,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr style=\"height:1px;border:none;color:#cccccc;background-color:#cccccc;\" />\n",
"# Legend\n",
"\n",
"# Using the interactive visualization\n",
"(How to use the interactive visualization)\n",
"\n",
"\n",
"### Molecule viewer\n",
Expand Down Expand Up @@ -338,7 +421,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"# **Background theory**: Introduction to molecular vibrations\n",
"<i class=\"fa fa-book fa-2x\"></i><a href=\"../Molecule_Vibration.ipynb\" style=\"font-size: 20px\"> Go back to the interactive notebook</a>\n",
"\n",
"**Source code:** https://github.com/osscar-org/quantum-mechanics/tree/develop/notebook/lattice-vibration/theory/theory_molecular_vibration.ipynb\n",
"**Source code:** https://github.com/osscar-org/quantum-mechanics/tree/master/notebook/lattice-vibration/theory/theory_molecular_vibration.ipynb\n",
"\n",
"<hr style=\"height:1px;border:none;color:#cccccc;background-color:#cccccc;\" />"
]
Expand All @@ -19,7 +19,11 @@
"outputs": [
{
"data": {
"application/javascript": "MathJax.Hub.Config({\n TeX: { equationNumbers: { autoNumber: \"AMS\" } }\n});\n",
"application/javascript": [
"MathJax.Hub.Config({\n",
" TeX: { equationNumbers: { autoNumber: \"AMS\" } }\n",
"});\n"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
Expand Down Expand Up @@ -49,7 +53,6 @@
"where\n",
"\\begin{equation}\n",
" \\mathcal{L}=K-V\n",
" \n",
"\\end{equation}\n",
"with $K$ the kinetic energy and $V$ the potential energy of the system.\n",
"In the case of small vibrations $\\Delta x_i, \\Delta y_i, \\Delta z_i$ of an atom, the kinetic term is described by:\n",
Expand All @@ -62,7 +65,7 @@
" K=\\frac{1}{2} \\sum_{i=1}^{3 N} \\dot{q}_{i}^{2}\n",
" \\label{eq:kinetic}\n",
"\\end{equation}\n",
"The potential energy ca be expended as:\n",
"The potential energy can be expanded as:\n",
"\\begin{equation}\n",
" V=V_{0}+\\sum_{i=1}^{3 N}\\left(\\frac{\\partial V}{\\partial q_{i}}\\right)_{0} q_{i}+\\frac{1}{2} \\sum_{i=1}^{3 N}\\left(\\frac{\\partial^{2} V}{\\partial q_{i} \\partial q_{j}}\\right)_{0} q_{i} q_{j}+\\cdots\n",
" \\label{eq:potential}\n",
Expand Down Expand Up @@ -158,9 +161,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 654b149

Please sign in to comment.