Skip to content

Commit

Permalink
Updated bands widget tutorial page (code and image). Included comment…
Browse files Browse the repository at this point in the history
… on widgets index page regarding support for Jlab >=4.x
  • Loading branch information
Taylor-96 committed Jun 2, 2024
1 parent 7191167 commit 9fd81b9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
5 changes: 2 additions & 3 deletions tutorial/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
OSSCAR Jupyter widgets, JupyterLab extensions and other tools
##############################################################

We have developed custom Jupyter widgets related to computational chemistry
and physics. For instance, we developed a interactive periodic table.
Besides, we also developed JupyterLab extensions, which can help development.
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.
In addition to interactive widgets, we have also developed JupyterLab extensions, which can improve a user's development experience.

######################
Jupyter widgets
Expand Down
Binary file modified widgets/images/bands.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 50 additions & 25 deletions widgets/widget_bandsplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
" This widget facilitates the plotting of electronic bandstructure and density of states from supplied json files.\n",
"</p>\n",
"\n",
"```{image} ./images/bands.png\n",
":alt: image bandstructure\n",
":class: bg-primary mb-1\n",
":width: 800px\n",
":height: 500px\n",
":align: center\n",
"```\n",
"\n",
"\n",
"## **Input json files**\n",
Expand All @@ -44,8 +37,8 @@
" The json format for the DOS can be checked in the github repository.\n",
"</p>\n",
"\n",
"<a href=\"https://raw.githubusercontent.com/osscar-org/widget-bandsplot/develop/example/Si_pdos_data.json\">\n",
"https://raw.githubusercontent.com/osscar-org/widget-bandsplot/develop/example/Si_pdos_data.json</a>\n",
"<a href=\"https://github.com/osscar-org/widget-bandsplot/blob/main/example/data/Si_dos.json\">\n",
"https://github.com/osscar-org/widget-bandsplot/blob/main/example/data/Si_dos.json</a>\n",
"\n",
"<p style=\"text-align: justify;font-size:15px\">\n",
" Here, one needs to use the json package to load the json file and pass it to the widget.\n",
Expand Down Expand Up @@ -88,50 +81,82 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from widget_bandsplot import *\n",
"from widget_bandsplot import BandsPlotWidget\n",
"import json\n",
"from copy import deepcopy"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"with open('Si_bands.json', 'r') as file:\n",
" data1 = json.load(file)\n",
" \n",
"with open('Si_dos.json', 'r') as file:\n",
" data2 = json.load(file)"
"import json\n",
"\n",
"def load_file(filename):\n",
" with open(filename, 'r') as fhandle:\n",
" return json.load(fhandle)\n",
"\n",
"si_bands = load_file(\"./Si_bands.json\")\n",
"si_dos = load_file(\"./Si_dos.json\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"tags": []
},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b88eb5973a3f44f1886b173bde431f1d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"BandsPlotWidget(bands=[{'label': '', 'path': [['GAMMA', 'X'], ['X', 'U'], ['K', 'GAMMA'], ['GAMMA', 'L'], ['L'…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"w1 = BandsPlotWidget(bands=[data1], dos=data2, plot_fermilevel = True, show_legend = True, energy_range = {\"ymin\": -13.0, \"ymax\": 10.0})\n",
"w1 = BandsPlotWidget(\n",
" bands = [si_bands],\n",
" dos = si_dos,\n",
" energy_range = [-8.0, 8.0],\n",
" format_settings = {\n",
" \"showFermi\": True,\n",
" \"showLegend\": True,\n",
" }\n",
")\n",
"display(w1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
"source": [
"```{image} ./images/bands.png\n",
":alt: image bandstructure\n",
":class: bg-primary mb-1\n",
":width: 800px\n",
":height: 500px\n",
":align: center\n",
"```"
]
}
],
"metadata": {
Expand All @@ -150,7 +175,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.12"
},
"voila": {
"authors": "Dou Du and Giovanni Pizzi"
Expand Down

0 comments on commit 9fd81b9

Please sign in to comment.