|
19 | 19 | " This widget facilitates the plotting of electronic bandstructure and density of states from supplied json files.\n",
|
20 | 20 | "</p>\n",
|
21 | 21 | "\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", |
29 | 22 | "\n",
|
30 | 23 | "\n",
|
31 | 24 | "## **Input json files**\n",
|
|
44 | 37 | " The json format for the DOS can be checked in the github repository.\n",
|
45 | 38 | "</p>\n",
|
46 | 39 | "\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", |
49 | 42 | "\n",
|
50 | 43 | "<p style=\"text-align: justify;font-size:15px\">\n",
|
51 | 44 | " Here, one needs to use the json package to load the json file and pass it to the widget.\n",
|
|
88 | 81 | },
|
89 | 82 | {
|
90 | 83 | "cell_type": "code",
|
91 |
| - "execution_count": null, |
| 84 | + "execution_count": 2, |
92 | 85 | "metadata": {
|
93 | 86 | "tags": []
|
94 | 87 | },
|
95 | 88 | "outputs": [],
|
96 | 89 | "source": [
|
97 |
| - "from widget_bandsplot import *\n", |
| 90 | + "from widget_bandsplot import BandsPlotWidget\n", |
98 | 91 | "import json\n",
|
99 | 92 | "from copy import deepcopy"
|
100 | 93 | ]
|
101 | 94 | },
|
102 | 95 | {
|
103 | 96 | "cell_type": "code",
|
104 |
| - "execution_count": null, |
| 97 | + "execution_count": 3, |
105 | 98 | "metadata": {
|
106 | 99 | "tags": []
|
107 | 100 | },
|
108 | 101 | "outputs": [],
|
109 | 102 | "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" |
115 | 111 | ]
|
116 | 112 | },
|
117 | 113 | {
|
118 | 114 | "cell_type": "code",
|
119 |
| - "execution_count": null, |
| 115 | + "execution_count": 4, |
120 | 116 | "metadata": {
|
121 | 117 | "tags": []
|
122 | 118 | },
|
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 | + ], |
124 | 135 | "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", |
126 | 145 | "display(w1)"
|
127 | 146 | ]
|
128 | 147 | },
|
129 | 148 | {
|
130 |
| - "cell_type": "code", |
131 |
| - "execution_count": null, |
| 149 | + "cell_type": "markdown", |
132 | 150 | "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 | + ] |
135 | 160 | }
|
136 | 161 | ],
|
137 | 162 | "metadata": {
|
|
150 | 175 | "name": "python",
|
151 | 176 | "nbconvert_exporter": "python",
|
152 | 177 | "pygments_lexer": "ipython3",
|
153 |
| - "version": "3.9.12" |
| 178 | + "version": "3.10.12" |
154 | 179 | },
|
155 | 180 | "voila": {
|
156 | 181 | "authors": "Dou Du and Giovanni Pizzi"
|
|
0 commit comments