-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,86 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"%env ANYWIDGET_HMR=1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from widget_bzvisualizer import BZVisualizer\n", | ||
"import ase.io\n", | ||
"\n", | ||
"def load_cif_cell_info(cif):\n", | ||
" \"\"\"Loads cell, relative positions and atom numbers from a CIF file\"\"\"\n", | ||
" struct = ase.io.read(cif)\n", | ||
" return struct.cell, struct.get_scaled_positions(), struct.numbers" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cell, rel_coords, atom_numbers = load_cif_cell_info(\"./mc3d-10.cif\")\n", | ||
"bz = BZVisualizer(cell, rel_coords, atom_numbers)\n", | ||
"bz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cell, rel_coords, atom_numbers = load_cif_cell_info(\"./mc3d-10016.cif\")\n", | ||
"bz = BZVisualizer(cell, rel_coords, atom_numbers, width=\"300px\", height=\"300px\")\n", | ||
"bz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# This cell is only needed for development!\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"%env ANYWIDGET_HMR=1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from widget_bzvisualizer import BZVisualizer\n", | ||
"\n", | ||
"cell = [\n", | ||
" [5.0, 0.0, 0.0],\n", | ||
" [0.0, 5.0, 0.0],\n", | ||
" [0.0, 0.0, 5.0],\n", | ||
"]\n", | ||
"# atomic coordinates in terms of unit vectors\n", | ||
"rel_coords = [[0.0, 0.0, 0.0]]\n", | ||
"# element numbers of atoms\n", | ||
"atom_numbers = [6]\n", | ||
"\n", | ||
"bz = BZVisualizer(cell, rel_coords, atom_numbers, width=\"100%\", height=\"400px\")\n", | ||
"display(bz)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Load info with ASE\n", | ||
"# NOTE: (ASE is not included as a direct dependency, needs to be installed separately)\n", | ||
"import ase.io\n", | ||
"\n", | ||
"def load_cell_info_ase(file):\n", | ||
" \"\"\"Loads cell, relative positions and atom numbers from a CIF file\"\"\"\n", | ||
" struct = ase.io.read(file)\n", | ||
" return struct.cell, struct.get_scaled_positions(), struct.numbers\n", | ||
"\n", | ||
"cell, rel_coords, atom_numbers = load_cell_info_ase(\"./mc3d-10016.cif\")\n", | ||
"bz2 = BZVisualizer(cell, rel_coords, atom_numbers)\n", | ||
"display(bz2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters