|
35 | 35 | },
|
36 | 36 | {
|
37 | 37 | "cell_type": "code",
|
38 |
| - "execution_count": 2, |
39 | 38 | "id": "9c1f4e9e",
|
40 | 39 | "metadata": {},
|
41 |
| - "outputs": [], |
42 | 40 | "source": [
|
43 | 41 | "# Note: JVASP-670 is an entry for MoTe2 and JVASP-6838 is an entry for GaTe\n",
|
44 | 42 | "JARVIS_IDS = [\n",
|
45 | 43 | " \"JVASP-670\",\n",
|
46 | 44 | " \"JVASP-6838\",\n",
|
47 | 45 | "]"
|
48 |
| - ] |
| 46 | + ], |
| 47 | + "outputs": [], |
| 48 | + "execution_count": null |
49 | 49 | },
|
50 | 50 | {
|
51 | 51 | "cell_type": "markdown",
|
|
57 | 57 | },
|
58 | 58 | {
|
59 | 59 | "cell_type": "code",
|
60 |
| - "execution_count": null, |
61 | 60 | "id": "ef2b38a5-de7e-419e-b605-110e9e0095f5",
|
62 | 61 | "metadata": {
|
63 | 62 | "trusted": true
|
64 | 63 | },
|
65 |
| - "outputs": [], |
66 | 64 | "source": [
|
67 | 65 | "import sys\n",
|
| 66 | + "\n", |
68 | 67 | "if sys.platform == \"emscripten\":\n",
|
69 | 68 | " import micropip\n",
|
| 69 | + "\n", |
70 | 70 | " await micropip.install('mat3ra-api-examples', deps=False)\n",
|
71 |
| - "from utils.jupyterlite import install_packages\n", |
72 |
| - "await install_packages(\"import_material_from_jarvis_db_entry.ipynb\",\"../../config.yml\")" |
73 |
| - ] |
| 71 | + " from utils.jupyterlite import install_packages\n", |
| 72 | + "\n", |
| 73 | + " await install_packages(\"import_material_from_jarvis_db_entry.ipynb\")" |
| 74 | + ], |
| 75 | + "outputs": [], |
| 76 | + "execution_count": null |
74 | 77 | },
|
75 | 78 | {
|
76 | 79 | "cell_type": "markdown",
|
|
84 | 87 | },
|
85 | 88 | {
|
86 | 89 | "cell_type": "code",
|
87 |
| - "execution_count": null, |
88 | 90 | "id": "b1ee775d1476f884",
|
89 | 91 | "metadata": {
|
90 | 92 | "collapsed": false,
|
91 | 93 | "trusted": true
|
92 | 94 | },
|
93 |
| - "outputs": [], |
94 | 95 | "source": [
|
95 | 96 | "import pandas as pd\n",
|
96 | 97 | "from jarvis.db.figshare import data\n",
|
|
99 | 100 | "dft_3d = data(\"dft_3d\")\n",
|
100 | 101 | "dataframe_2d = pd.DataFrame(dft_2d)\n",
|
101 | 102 | "dataframe_3d = pd.DataFrame(dft_3d)\n",
|
102 |
| - "dataframe= pd.concat([dataframe_2d, dataframe_3d])" |
103 |
| - ] |
| 103 | + "dataframe = pd.concat([dataframe_2d, dataframe_3d])" |
| 104 | + ], |
| 105 | + "outputs": [], |
| 106 | + "execution_count": null |
104 | 107 | },
|
105 | 108 | {
|
106 | 109 | "cell_type": "markdown",
|
|
112 | 115 | },
|
113 | 116 | {
|
114 | 117 | "cell_type": "code",
|
115 |
| - "execution_count": null, |
116 | 118 | "id": "0e34472a",
|
117 | 119 | "metadata": {},
|
118 |
| - "outputs": [], |
119 | 120 | "source": [
|
120 | 121 | "dataframe"
|
121 |
| - ] |
| 122 | + ], |
| 123 | + "outputs": [], |
| 124 | + "execution_count": null |
122 | 125 | },
|
123 | 126 | {
|
124 | 127 | "cell_type": "markdown",
|
|
130 | 133 | },
|
131 | 134 | {
|
132 | 135 | "cell_type": "code",
|
133 |
| - "execution_count": null, |
134 | 136 | "id": "a771a36a",
|
135 | 137 | "metadata": {},
|
136 |
| - "outputs": [], |
137 | 138 | "source": [
|
138 | 139 | "import json\n",
|
139 | 140 | "from express import ExPrESS\n",
|
140 | 141 | "\n",
|
141 | 142 | "dataframe_entries_for_jarvis_ids = dataframe[(dataframe[\"jid\"].isin(JARVIS_IDS))]\n",
|
142 | 143 | "dataframe_entries_as_json = dataframe_entries_for_jarvis_ids.to_json(orient=\"records\")\n",
|
143 | 144 | "jarvis_db_entries = json.loads(dataframe_entries_as_json)"
|
144 |
| - ] |
| 145 | + ], |
| 146 | + "outputs": [], |
| 147 | + "execution_count": null |
145 | 148 | },
|
146 | 149 | {
|
147 | 150 | "cell_type": "markdown",
|
|
153 | 156 | },
|
154 | 157 | {
|
155 | 158 | "cell_type": "code",
|
156 |
| - "execution_count": null, |
157 | 159 | "id": "c41fb68c6d25fe48",
|
158 | 160 | "metadata": {
|
159 | 161 | "collapsed": false,
|
160 | 162 | "trusted": true
|
161 | 163 | },
|
162 |
| - "outputs": [], |
163 | 164 | "source": [
|
164 | 165 | "def convert_jarvis_entry_to_esse(jarvis_db_entry):\n",
|
165 | 166 | " jarvis_db_entry_json = json.dumps(jarvis_db_entry)\n",
|
|
173 | 174 | " poscar = handler.parser.jarvis_db_entry_json_to_poscar(jarvis_db_entry_json)\n",
|
174 | 175 | " return (esse, poscar)\n",
|
175 | 176 | "\n",
|
| 177 | + "\n", |
176 | 178 | "esse_entries = list(map(lambda e: convert_jarvis_entry_to_esse(e)[0], jarvis_db_entries))\n",
|
177 | 179 | "poscars = list(map(lambda e: convert_jarvis_entry_to_esse(e)[1], jarvis_db_entries))"
|
178 |
| - ] |
| 180 | + ], |
| 181 | + "outputs": [], |
| 182 | + "execution_count": null |
179 | 183 | },
|
180 | 184 | {
|
181 | 185 | "cell_type": "markdown",
|
|
187 | 191 | },
|
188 | 192 | {
|
189 | 193 | "cell_type": "code",
|
190 |
| - "execution_count": null, |
191 | 194 | "id": "860b5c1b",
|
192 | 195 | "metadata": {},
|
193 |
| - "outputs": [], |
194 | 196 | "source": [
|
195 |
| - "from src.utils import poscar_to_ase\n", |
196 |
| - "from ase.visualize import view\n", |
197 |
| - "from ase.io import write\n", |
198 |
| - "from ase.build import make_supercell\n", |
199 |
| - "from IPython.display import Image\n", |
| 197 | + "from utils.visualize import visualize_materials\n", |
| 198 | + "from mat3ra.made.tools.convert import from_poscar\n", |
| 199 | + "from mat3ra.made.material import Material\n", |
200 | 200 | "\n",
|
201 | 201 | "# Uncomment to see the JSON\n",
|
202 | 202 | "# print(json.dumps(data, indent=4))\n",
|
203 | 203 | "\n",
|
| 204 | + "materials = [Material(from_poscar(poscar)) for poscar in poscars]\n", |
204 | 205 | "\n",
|
205 |
| - "materials = list(map(lambda p: poscar_to_ase(p), poscars))\n", |
206 |
| - "\n", |
207 |
| - "def visualize_material(material, index: int, number_of_repetitions: int = 3):\n", |
208 |
| - " \"\"\"\n", |
209 |
| - " Visualize the material using ASE's visualization tool\n", |
210 |
| - " Repeat the unit cell to make it easier to see.\n", |
211 |
| - "\n", |
212 |
| - " Args:\n", |
213 |
| - " material: The material to visualize (Ase.Atoms object)\n", |
214 |
| - " index: The index of the material\n", |
215 |
| - " number_of_repetitions: The number of unit cell repetitions to visualize\n", |
216 |
| - " \"\"\"\n", |
217 |
| - " # Set the number of unit cell repetition for the structure to make it easier to see\n", |
218 |
| - " n = number_of_repetitions\n", |
219 |
| - " material_repeat = make_supercell(material, [[n,0,0],[0,n,0],[0,0,n]])\n", |
220 |
| - " filename = f\"material-{index}.png\"\n", |
221 |
| - " write(filename, material_repeat)\n", |
222 |
| - " img = Image(filename=filename)\n", |
223 |
| - " print(filename, \"-\", material.symbols)\n", |
224 |
| - " display(img)\n", |
225 |
| - "\n", |
226 |
| - "for idx, material in enumerate(materials):\n", |
227 |
| - " visualize_material(material, idx)" |
228 |
| - ] |
| 206 | + "visualize_materials(materials)" |
| 207 | + ], |
| 208 | + "outputs": [], |
| 209 | + "execution_count": null |
229 | 210 | },
|
230 | 211 | {
|
231 | 212 | "cell_type": "markdown",
|
|
237 | 218 | },
|
238 | 219 | {
|
239 | 220 | "cell_type": "code",
|
240 |
| - "execution_count": null, |
241 | 221 | "id": "00b187ab",
|
242 | 222 | "metadata": {},
|
243 |
| - "outputs": [], |
244 | 223 | "source": [
|
245 |
| - "from utils.jupyterlite import set_data\n", |
| 224 | + "from utils.jupyterlite import set_materials\n", |
246 | 225 | "\n",
|
247 |
| - "output_materials = esse_entries\n", |
248 |
| - "set_data(\"materials\", output_materials)" |
249 |
| - ] |
| 226 | + "set_materials(materials)" |
| 227 | + ], |
| 228 | + "outputs": [], |
| 229 | + "execution_count": null |
250 | 230 | }
|
251 | 231 | ],
|
252 | 232 | "metadata": {
|
|
0 commit comments