Skip to content

Commit 9fbff87

Browse files
author
Dou Du
committed
update the bz visualizer notebook
1 parent 1af8153 commit 9fbff87

File tree

2 files changed

+66
-11
lines changed

2 files changed

+66
-11
lines changed

widgets/.ipynb_checkpoints/widget_bzvisualizer-checkpoint.ipynb

+34-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"metadata": {},
77
"source": [
88
"# `widget-bzvisualizer`: A Jupyter widget to visualize the 1st Brillouin zone and band paths\n",
9-
"**Source code**: https://github.com/osscar-org/widget-bzvisualizer\n",
9+
"\n",
10+
"**Source code**: [https://github.com/osscar-org/widget-bzvisualizer](https://github.com/osscar-org/widget-bzvisualizer) \n",
1011
"\n",
1112
"**Introduction**: A Jupyter widget to plot the 1st Brillouin zone and band paths. \n",
1213
"It uses the Javascript package [tools-seekpath](https://seekpath.readthedocs.io) developed \n",
@@ -52,10 +53,27 @@
5253
"metadata": {},
5354
"outputs": [],
5455
"source": [
55-
"lattice = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])\n",
56+
"from widget_bzvisualizer import BZVisualizer\n",
57+
"\n",
58+
"cell = [\n",
59+
" [5.0, 0.0, 0.0],\n",
60+
" [0.0, 5.0, 0.0],\n",
61+
" [0.0, 0.0, 5.0],\n",
62+
"]\n",
63+
"# atomic coordinates in terms of unit vectors\n",
64+
"rel_coords = [[0.0, 0.0, 0.0]]\n",
65+
"# element numbers of atoms\n",
66+
"atom_numbers = [6]\n",
5667
"\n",
57-
"w = BZVisualizer(lattice, [[0.0, 0.0, 0.0]], [1], True)\n",
58-
"display(w)"
68+
"bz = BZVisualizer(\n",
69+
" cell, rel_coords, atom_numbers,\n",
70+
" width=\"100%\", height=\"400px\",\n",
71+
" show_axes=True,\n",
72+
" show_bvectors=True,\n",
73+
" show_pathpoints=True,\n",
74+
" disable_interact_overlay=True,\n",
75+
")\n",
76+
"display(bz)"
5977
]
6078
},
6179
{
@@ -86,7 +104,7 @@
86104
"metadata": {},
87105
"outputs": [],
88106
"source": [
89-
"w.kpts = (monkhorst_pack((8, 8, 8))*2*np.pi).tolist()"
107+
"bz.kpts = (monkhorst_pack((8, 8, 8))*2*np.pi).tolist()"
90108
]
91109
},
92110
{
@@ -95,6 +113,16 @@
95113
"id": "stretch-animal",
96114
"metadata": {},
97115
"outputs": [],
116+
"source": [
117+
"bz.kpts"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": null,
123+
"id": "5157f61b-e6da-4167-83f8-771d3eea6e0b",
124+
"metadata": {},
125+
"outputs": [],
98126
"source": []
99127
}
100128
],
@@ -114,7 +142,7 @@
114142
"name": "python",
115143
"nbconvert_exporter": "python",
116144
"pygments_lexer": "ipython3",
117-
"version": "3.9.7"
145+
"version": "3.11.5"
118146
}
119147
},
120148
"nbformat": 4,

widgets/widget_bzvisualizer.ipynb

+32-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,27 @@
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
56-
"lattice = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])\n",
56+
"from widget_bzvisualizer import BZVisualizer\n",
57+
"\n",
58+
"cell = [\n",
59+
" [5.0, 0.0, 0.0],\n",
60+
" [0.0, 5.0, 0.0],\n",
61+
" [0.0, 0.0, 5.0],\n",
62+
"]\n",
63+
"# atomic coordinates in terms of unit vectors\n",
64+
"rel_coords = [[0.0, 0.0, 0.0]]\n",
65+
"# element numbers of atoms\n",
66+
"atom_numbers = [6]\n",
5767
"\n",
58-
"w = BZVisualizer(lattice, [[0.0, 0.0, 0.0]], [1], True)\n",
59-
"display(w)"
68+
"bz = BZVisualizer(\n",
69+
" cell, rel_coords, atom_numbers,\n",
70+
" width=\"100%\", height=\"400px\",\n",
71+
" show_axes=True,\n",
72+
" show_bvectors=True,\n",
73+
" show_pathpoints=True,\n",
74+
" disable_interact_overlay=True,\n",
75+
")\n",
76+
"display(bz)"
6077
]
6178
},
6279
{
@@ -87,7 +104,7 @@
87104
"metadata": {},
88105
"outputs": [],
89106
"source": [
90-
"w.kpts = (monkhorst_pack((8, 8, 8))*2*np.pi).tolist()"
107+
"bz.kpts = (monkhorst_pack((8, 8, 8))*2*np.pi).tolist()"
91108
]
92109
},
93110
{
@@ -96,6 +113,16 @@
96113
"id": "stretch-animal",
97114
"metadata": {},
98115
"outputs": [],
116+
"source": [
117+
"bz.kpts"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": null,
123+
"id": "5157f61b-e6da-4167-83f8-771d3eea6e0b",
124+
"metadata": {},
125+
"outputs": [],
99126
"source": []
100127
}
101128
],
@@ -115,7 +142,7 @@
115142
"name": "python",
116143
"nbconvert_exporter": "python",
117144
"pygments_lexer": "ipython3",
118-
"version": "3.9.7"
145+
"version": "3.11.5"
119146
}
120147
},
121148
"nbformat": 4,

0 commit comments

Comments
 (0)