Skip to content

Commit

Permalink
Revised the text of interactive and theory notebooks. Removed code re…
Browse files Browse the repository at this point in the history
…lated to orientation sync for now.
  • Loading branch information
Taylor-96 committed Oct 11, 2023
1 parent 4f2c566 commit 53fe90d
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 138 deletions.
180 changes: 63 additions & 117 deletions notebook/band-theory/brillouin_zone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
" $$\\vec{a}_1 \\cdot \\vec{b}_1 = 2 \\pi \\vec{a}_1 \\cdot \\frac{\\vec{a}_2 \\times \\vec{a}_3}{\\vec{a}_1 \\cdot (\\vec{a}_2 \\times \\vec{a}_3)} = 2 \\pi$$\n",
" $$\\vec{a}_2 \\cdot \\vec{b}_1 =2 \\pi \\vec{a}_2 \\cdot \\frac{\\vec{a}_2 \\times \\vec{a}_3}{\\vec{a}_1 \\cdot (\\vec{a}_2 \\times \\vec{a}_3)} = 0$$\n",
" $$\\vec{a}_3 \\cdot \\vec{b}_1 =2 \\pi \\vec{a}_3 \\cdot \\frac{\\vec{a}_2 \\times \\vec{a}_3}{\\vec{a}_1 \\cdot (\\vec{a}_2 \\times \\vec{a}_3)} = 0$$\n",
" Similarly, one can compute for other reciprocal lattice vector $\\vec{b}_2$ and \n",
" $\\vec{b}_3$. In summary, we have the relation as $\\vec{a}_i \\cdot \\vec{b}_j = 2\\pi \\delta _{ij}$.\n",
" One can carry out similar computations for the other reciprocal lattice vectors $\\vec{b}_2$ and \n",
" $\\vec{b}_3$. In summary, we have the relationship $\\vec{a}_i \\cdot \\vec{b}_j = 2\\pi \\delta _{ij}$.\n",
" </details>\n",
" </li>\n",
" <li> What is the volume of the primitive cell in reciprocal space? How it is related \n",
Expand All @@ -75,7 +75,7 @@
" $$\\Omega_b = \\vec{b}_1 \\cdot (\\vec{b}_2 \\times \\vec{b}_3) = \n",
" 2\\pi \\frac{\\vec{a}_2 \\times \\vec{a}_3}{\\vec{a}_1 \\cdot (\\vec{a}_2 \\times \\vec{a}_3)}\n",
" (\\vec{b}_2 \\times \\vec{b}_3)$$\n",
" According to the Lagrange's identity, one can show:\n",
" According to Lagrange's identity, one can show:\n",
" $$(\\vec{a}_2 \\times \\vec{a}_3) \\cdot (\\vec{b}_2 \\times \\vec{b}_3) =\n",
" (\\vec{a}_2 \\cdot \\vec{b}_2)(\\vec{a}_3 \\cdot \\vec{b}_3) - \n",
" (\\vec{a}_2 \\cdot \\vec{b}_3)(\\vec{a}_3 \\cdot \\vec{b}_2) = 2\\pi \\cdot 2\\pi - 0 = 4\\pi^2$$\n",
Expand All @@ -91,24 +91,25 @@
" <img src=\"./images/BCC.png\" alt=\"drawing\" style=\"width:300px;\"/>\n",
" <figcaption>Figure 1. Demonstration of the procedure for constructing the primitive lattice vectors for the body-centered cubic (BCC) structure.</figcaption>\n",
" </div>\n",
" \n",
" For a BCC structure, as shown in the Figure 1, the primitive lattice vectors can\n",
" be constructed as:\n",
" be written as:\n",
" $$\\vec{a}_1 = \\frac{a}{2} (\\vec{x}+\\vec{y}-\\vec{z})$$\n",
" $$\\vec{a}_2 = \\frac{a}{2} (-\\vec{x}+\\vec{y}+\\vec{z})$$\n",
" $$\\vec{a}_3 = \\frac{a}{2} (\\vec{x}-\\vec{y}+\\vec{z})$$\n",
" \n",
" The corresponding reciprocal lattice vectors are:\n",
" $$\\vec{b}_1 = 2\\pi \\frac{\\vec{a}_2 \\times \\vec{a}_3}\n",
" {\\vec{a}_1 (\\vec{a}_2 \\times \\vec{a}_3)} = \\frac{2\\pi}{\\Omega}\n",
" (\\vec{a}_2 \\times \\vec{a}_3) = \\frac{\\pi a^2}{\\Omega} (x + y)$$\n",
" (\\vec{a}_2 \\times \\vec{a}_3) = \\frac{\\pi a^2}{\\Omega} (\\vec{x} + \\vec{y})$$\n",
" \n",
" $$\\vec{b}_2 = 2\\pi \\frac{\\vec{a}_3 \\times \\vec{a}_1}\n",
" {\\vec{a}_1 (\\vec{a}_2 \\times \\vec{a}_3)} = \\frac{2\\pi}{\\Omega}\n",
" (\\vec{a}_3 \\times \\vec{a}_1) = \\frac{\\pi a^2}{\\Omega} (y + z)$$\n",
" (\\vec{a}_3 \\times \\vec{a}_1) = \\frac{\\pi a^2}{\\Omega} (\\vec{y} + \\vec{z})$$\n",
" \n",
" $$\\vec{b}_1 = 2\\pi \\frac{\\vec{a}_1 \\times \\vec{a}_2}\n",
" {\\vec{a}_1 (\\vec{a}_2 \\times \\vec{a}_3)} = \\frac{2\\pi}{\\Omega}\n",
" (\\vec{a}_2 \\times \\vec{a}_3) = \\frac{\\pi a^2}{\\Omega} (x + y)$$\n",
" (\\vec{a}_1 \\times \\vec{a}_2) = \\frac{\\pi a^2}{\\Omega} (\\vec{x} + \\vec{y})$$\n",
" \n",
" <div style=\"text-align:center\">\n",
" <img src=\"./images/FCC.png\" alt=\"drawing\" style=\"width:300px;\"/>\n",
Expand All @@ -135,7 +136,7 @@
" \n",
" $$\\vec{b}_1 = 2\\pi \\frac{\\vec{a}_1 \\times \\vec{a}_2}\n",
" {\\vec{a}_1 \\cdot (\\vec{a}_2 \\times \\vec{a}_3)} = \\frac{2\\pi}{\\Omega}\n",
" (\\vec{a}_2 \\times \\vec{a}_3) = \\frac{\\pi a^2}{2 \\Omega}\n",
" (\\vec{a}_1 \\times \\vec{a}_2) = \\frac{\\pi a^2}{2 \\Omega}\n",
" (\\vec{x}-\\vec{y}+\\vec{z})$$\n",
" \n",
" One can see that the reciprocal lattice vectors of the BCC structure are simply \n",
Expand All @@ -144,7 +145,8 @@
" has the same structure as the Wigner-Seitz primitive cell of FCC.\n",
" And the 1st Brillouin zone of the FCC lattice has the same structure as the\n",
" the Wigner-Seitz primitive cell of BCC.\n",
" </details> \n",
" </details> \n",
" \n",
" </li>\n",
"</ol>"
]
Expand All @@ -159,7 +161,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "posted-injection",
"metadata": {},
"outputs": [],
Expand All @@ -186,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "5bd45845-7969-4808-aba4-8f60f850f139",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -246,13 +248,56 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "e813f33a-8d73-469f-8b9b-ec4e93763abc",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1befff4a7c964e37810b483e84aad4bf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(HTML(value=\"<div style='width: 400px; text-align:center;'><b><font color='blue'><font size=5>St…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3e93345b0a1f4bc1af661d861e18840f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(NGLWidget(), VBox(children=(BZVisualizer(cell=[[1.8, 0.0, 0.0], [0.0, 1.8, 0.0], [0.0, 0.0, 1.8…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6a065a7edbc64470ad4426cc22bcd937",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(VBox(children=(Text(value='Crystal family'), RadioButtons(options=('Cubic', 'Hexagonal', 'Rhomb…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\"\"\"\n",
"now contents are dropdwn menus. \n",
Expand Down Expand Up @@ -316,63 +361,6 @@
" param_dict[crystal_family+'-'+centering]['gamma'] = gamma\n",
" \n",
"\n",
"\n",
"def on_orientation_sync(c):\n",
" ngl_dict=m.__dict__['_trait_values']\n",
" init_ngl_matrix= np.array([24.451005287902106, 0.0, 0.0, -3.5999999046325684, 0.0, 24.451005287902106, 0.0, -3.5999999046325684, 0.0, 0.0, 24.451005287902106, -3.5999999046325684, 0.0, 0.0, 0.0, 1.0]).reshape((4,4))\n",
" temp = (np.linalg.inv(init_ngl_matrix))@np.array(ngl_dict[\"_camera_orientation\"]).reshape(4,4).T\n",
" temp2 = (np.array(ngl_dict[\"_camera_orientation\"]).reshape(4,4).T)@(np.linalg.inv(init_ngl_matrix))\n",
" ngl_extmat=np.array(ngl_dict[\"_camera_orientation\"]).reshape(4,4).T\n",
" init_worldmatrix = np.array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,10.471975511965978,1]).reshape((4,4)).T\n",
" ngl_extmat = init_worldmatrix@temp\n",
"# orientation = init_worldmatrix@temp\n",
"# orientation = temp@init_worldmatrix\n",
"# ngl_extmat = [email protected](init_worldmatrix)\n",
"# ngl_extmat = temp@init_worldmatrix\n",
"\n",
"# ngl_extmat = temp2@init_worldmatrix\n",
"\n",
" R=ngl_extmat[0:3,0:3]\n",
" T=ngl_extmat[0:3,-1]\n",
" campos=list(-(R.T)@T) \n",
" camdir=list((R.T)@np.array([0,0,1]))\n",
" cam_dict={\"campos\":campos, \"camdir\":camdir}\n",
"\n",
"# # orientation=temp\n",
"# # orientation = orientation.T\n",
"# orientation = orientation.flatten()\n",
"# orientation[-1] = 1\n",
"# orientation[12]=0.\n",
"# orientation[13]=0.\n",
"# orientation[14]=0.\n",
"# orientation *=1/100.\n",
"# orientation[3] =0.\n",
"# orientation[7] =0.\n",
"# orientation[11]=0.\n",
"\n",
"# orientation -= np.array([24.451005287902106, 0.0, 0.0, -3.5999999046325684, 0.0, 24.451005287902106, 0.0, -3.5999999046325684, 0.0, 0.0, 24.451005287902106, -3.5999999046325684, 0.0, 0.0, 0.0, 0.0])\n",
"# orientation += np.array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,10.471975511965978,0])\n",
" # orientation=[0.7500277180472348,5.551115123125783e-17,0.6614063971272561,0,0.5078318190417079,0.6406823725596474,-0.5758758035029177,0,-0.4237514197376189,0.7678060285588679,0.48052953788400066,0,-4.437514490653162,8.040445929008314,5.0320935534975835,1]\n",
"# orientation = [0.7683450340620741,-5.551115123125783e-17,0.6400358651139405,0,0.5491434688219112,0.5136687465056196,-0.659231271644166,0,-0.32876642055171756,0.8579885890053234,0.39467483053048313,0,-3.964409288439841,8.830108018321802,3.6037858154548483,1]\n",
" # orientation = [0.9709872600909863,0,0.2391312207575565,0,0.23913122075743692,0.0000010000000000287557,-0.9709872600905007,0,-2.3913122074170623e-7,0.9999999999995,9.709872600405234e-7,0,-0.000002504176287919244,10.471975511960737,0.000010168154810102051,1]\n",
" w.orientation=cam_dict\n",
"# w.orientation = list(orientation)\n",
" # with output:\n",
" # #print(\"set orientation ={}\".format(w.orientation))\n",
" # ngl_dict=m.__dict__['_trait_values']\n",
" \n",
"# print(\"w = {}\\n\".format(w.__dict__))\n",
"# print(\"init_world_matrix= {}\".format(init_worldmatrix))\n",
"\n",
"# print(\"init_ngl_matrix= {}\".format(init_ngl_matrix))\n",
" \n",
"# print(\"np.array(ngl_dict[\\\"_camera_orientation\\\"]).reshape(4,4).T = {}\\n\".format(np.array(ngl_dict[\"_camera_orientation\"]).reshape(4,4).T))\n",
"# print(\"camdict={}\".format(cam_dict))\n",
"# print(\"(np.linalg.inv(init_ngl_matrix)@np.array(ngl_dict[\\\"_camera_orientation\\\"]).reshape(4,4)).T{}\".format(np.linalg.inv(init_ngl_matrix)@np.array(ngl_dict[\"_camera_orientation\"]).reshape(4,4)))\n",
" # set the bz visualizer camera orientation equal to this\n",
"\n",
"\n",
"\n",
"output = Output(layout=Layout(width=\"400px\"))\n",
"a_slider=widgets.FloatSlider(\n",
" value=3.5,\n",
Expand Down Expand Up @@ -531,16 +519,11 @@
" # then we will need some logic to prevent overriding them when we change crystal\n",
" # structure or centering\n",
" \n",
" # if type(change['owner']) == widgets.widget_selection.RadioButtons:\n",
" # save_lat_params=False\n",
" # print(\"reset sliders: type(change[owner]) = {}\".format(type(change['owner'])))\n",
" # if change['owner'] = \n",
" \n",
" crystal_family_radio.unobserve(reset_sliders, names='value')\n",
"\n",
" crystal_family = crystal_family_radio.value\n",
" # with output:\n",
" # print(\"crystal family = {}\".format(crystal_family))\n",
" \n",
" \n",
" a_slider.unobserve(compute_BZ,names='value')\n",
" b_slider.unobserve(compute_BZ,names='value')\n",
" c_slider.unobserve(compute_BZ,names='value')\n",
Expand Down Expand Up @@ -821,9 +804,6 @@
" global m,c1, crystal_family_radio,w, real_lattice\n",
" \n",
" crystal_family = crystal_family_radio.value\n",
" # with output:\n",
" # print(\"compute_bz. crystal fam = {}, c == {}\\n\".format(crystal_family,c))\n",
"\n",
" \n",
" try:\n",
" a_slider.unobserve(compute_BZ,names='value')\n",
Expand Down Expand Up @@ -988,45 +968,12 @@
"gamma_slider.observe(compute_BZ,names='value')\n",
"\n",
"\n",
"# bt_compute.on_click(compute_BZ);\n",
"\n",
"label1 = HTML(value = f\"<div style='width: 400px; text-align:center;'><b><font color='blue'><font size=5>Structure</b></div>\")\n",
"label2 = HTML(value = f\"<div style='width: 400px; text-align:center;'><b><font color='blue'><font size=5>Brillouin zone</b></div>\")\n",
"\n",
"# orientation_sync_button = Button(description=\"Sync orientations\")\n",
"# orientation_sync_button.on_click(on_orientation_sync)\n",
"# display(HBox([label1, label2]), HBox([m, VBox([w,orientation_sync_button])]), HBox([col0, col1,col2]))\n",
"display(HBox([label1, label2]), HBox([m, VBox([w])]), HBox([col0, col1,col2]))\n",
"\n",
"# display(orientation_sync_button)\n",
"# try the following [0.7500277180472348,5.551115123125783e-17,0.6614063971272561,0,0.5078318190417079,0.6406823725596474,-0.5758758035029177,0,-0.4237514197376189,0.7678060285588679,0.48052953788400066,0,-4.437514490653162,8.040445929008314,5.0320935534975835,1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "52fcce72",
"metadata": {},
"outputs": [],
"source": [
"#[1,0,0,0,0,1,0,0,0,0,1,0,0,0,10.471975511965978,1] is init world vec\n",
"# [24.451005287902106, 0.0, 0.0, -3.5999999046325684, 0.0, 24.451005287902106, 0.0, -3.5999999046325684, 0.0, 0.0, 24.451005287902106, -3.5999999046325684, 0.0, 0.0, 0.0, 1.0\n",
"# is init orientation\n",
"# np.array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,10.471975511965978,1]).reshape((4,4)).T"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74673cfe",
"metadata": {},
"outputs": [],
"source": [
"# a = np.array([[24.45100529 , 0. , 0. , -3.5999999 ],\n",
"# [ 0. , 24.45100529, 0. , -3.5999999 ],\n",
"# [ 0. , 0. , 24.45100529 ,-3.5999999 ],\n",
"# [ 0. , 0. , 0. , 1. ]])\n",
"# np.linalg.inv(a)@a"
"display(HBox([label1, label2]), HBox([m, VBox([w])]), HBox([col0, col1,col2]))\n"
]
},
{
Expand All @@ -1042,8 +989,7 @@
"### Interactive figures\n",
"\n",
"There are two visualizers for the real space lattice structure (top left) and its 1st Brillouin zone in reciprocal space (top right) respectively. One can left-click\n",
"and rotate both structures. Middle wheel of the mouse can zoom in and zoom out\n",
"the structures. In the 1st Brillouin zone visualizer, the high symmetry points\n",
"and rotate both structures. The mousewheel can be used to zoom in and zoom out. In the 1st Brillouin zone visualizer, the high symmetry points\n",
"are also shown in the figure.\n",
"\n",
"### Controls\n",
Expand Down Expand Up @@ -1080,7 +1026,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 53fe90d

Please sign in to comment.