Skip to content

Commit 9fd81b9

Browse files
committed
Updated bands widget tutorial page (code and image). Included comment on widgets index page regarding support for Jlab >=4.x
1 parent 7191167 commit 9fd81b9

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

tutorial/tools.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
OSSCAR Jupyter widgets, JupyterLab extensions and other tools
33
##############################################################
44

5-
We have developed custom Jupyter widgets related to computational chemistry
6-
and physics. For instance, we developed a interactive periodic table.
7-
Besides, we also developed JupyterLab extensions, which can help development.
5+
We have developed custom Jupyter widgets which facilitate a number of tasks typically carried out in computational chemistry and physics. All of these widgets are compatible with JupyterLab >= 4.x (Notebook 7) and were revised in 2024 to make use of the anywidget framework.
6+
In addition to interactive widgets, we have also developed JupyterLab extensions, which can improve a user's development experience.
87

98
######################
109
Jupyter widgets

widgets/images/bands.png

100755100644
19.5 KB
Loading

widgets/widget_bandsplot.ipynb

+50-25
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
" This widget facilitates the plotting of electronic bandstructure and density of states from supplied json files.\n",
2020
"</p>\n",
2121
"\n",
22-
"```{image} ./images/bands.png\n",
23-
":alt: image bandstructure\n",
24-
":class: bg-primary mb-1\n",
25-
":width: 800px\n",
26-
":height: 500px\n",
27-
":align: center\n",
28-
"```\n",
2922
"\n",
3023
"\n",
3124
"## **Input json files**\n",
@@ -44,8 +37,8 @@
4437
" The json format for the DOS can be checked in the github repository.\n",
4538
"</p>\n",
4639
"\n",
47-
"<a href=\"https://raw.githubusercontent.com/osscar-org/widget-bandsplot/develop/example/Si_pdos_data.json\">\n",
48-
"https://raw.githubusercontent.com/osscar-org/widget-bandsplot/develop/example/Si_pdos_data.json</a>\n",
40+
"<a href=\"https://github.com/osscar-org/widget-bandsplot/blob/main/example/data/Si_dos.json\">\n",
41+
"https://github.com/osscar-org/widget-bandsplot/blob/main/example/data/Si_dos.json</a>\n",
4942
"\n",
5043
"<p style=\"text-align: justify;font-size:15px\">\n",
5144
" Here, one needs to use the json package to load the json file and pass it to the widget.\n",
@@ -88,50 +81,82 @@
8881
},
8982
{
9083
"cell_type": "code",
91-
"execution_count": null,
84+
"execution_count": 2,
9285
"metadata": {
9386
"tags": []
9487
},
9588
"outputs": [],
9689
"source": [
97-
"from widget_bandsplot import *\n",
90+
"from widget_bandsplot import BandsPlotWidget\n",
9891
"import json\n",
9992
"from copy import deepcopy"
10093
]
10194
},
10295
{
10396
"cell_type": "code",
104-
"execution_count": null,
97+
"execution_count": 3,
10598
"metadata": {
10699
"tags": []
107100
},
108101
"outputs": [],
109102
"source": [
110-
"with open('Si_bands.json', 'r') as file:\n",
111-
" data1 = json.load(file)\n",
112-
" \n",
113-
"with open('Si_dos.json', 'r') as file:\n",
114-
" data2 = json.load(file)"
103+
"import json\n",
104+
"\n",
105+
"def load_file(filename):\n",
106+
" with open(filename, 'r') as fhandle:\n",
107+
" return json.load(fhandle)\n",
108+
"\n",
109+
"si_bands = load_file(\"./Si_bands.json\")\n",
110+
"si_dos = load_file(\"./Si_dos.json\")\n"
115111
]
116112
},
117113
{
118114
"cell_type": "code",
119-
"execution_count": null,
115+
"execution_count": 4,
120116
"metadata": {
121117
"tags": []
122118
},
123-
"outputs": [],
119+
"outputs": [
120+
{
121+
"data": {
122+
"application/vnd.jupyter.widget-view+json": {
123+
"model_id": "b88eb5973a3f44f1886b173bde431f1d",
124+
"version_major": 2,
125+
"version_minor": 0
126+
},
127+
"text/plain": [
128+
"BandsPlotWidget(bands=[{'label': '', 'path': [['GAMMA', 'X'], ['X', 'U'], ['K', 'GAMMA'], ['GAMMA', 'L'], ['L'…"
129+
]
130+
},
131+
"metadata": {},
132+
"output_type": "display_data"
133+
}
134+
],
124135
"source": [
125-
"w1 = BandsPlotWidget(bands=[data1], dos=data2, plot_fermilevel = True, show_legend = True, energy_range = {\"ymin\": -13.0, \"ymax\": 10.0})\n",
136+
"w1 = BandsPlotWidget(\n",
137+
" bands = [si_bands],\n",
138+
" dos = si_dos,\n",
139+
" energy_range = [-8.0, 8.0],\n",
140+
" format_settings = {\n",
141+
" \"showFermi\": True,\n",
142+
" \"showLegend\": True,\n",
143+
" }\n",
144+
")\n",
126145
"display(w1)"
127146
]
128147
},
129148
{
130-
"cell_type": "code",
131-
"execution_count": null,
149+
"cell_type": "markdown",
132150
"metadata": {},
133-
"outputs": [],
134-
"source": []
151+
"source": [
152+
"```{image} ./images/bands.png\n",
153+
":alt: image bandstructure\n",
154+
":class: bg-primary mb-1\n",
155+
":width: 800px\n",
156+
":height: 500px\n",
157+
":align: center\n",
158+
"```"
159+
]
135160
}
136161
],
137162
"metadata": {
@@ -150,7 +175,7 @@
150175
"name": "python",
151176
"nbconvert_exporter": "python",
152177
"pygments_lexer": "ipython3",
153-
"version": "3.9.12"
178+
"version": "3.10.12"
154179
},
155180
"voila": {
156181
"authors": "Dou Du and Giovanni Pizzi"

0 commit comments

Comments
 (0)