Skip to content

Commit f50be78

Browse files
Merge pull request #95 from Exabyte-io/feat/SOF-7221-jarvis-structure
feature: example import of structural data from JARVIS
2 parents 9b39916 + a6d2273 commit f50be78

File tree

4 files changed

+136
-1
lines changed

4 files changed

+136
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Below, we list the contents of this repository, in roughly the order that a user
1212
| [Examples/Material](examples/material/) | [Get Materials by Formula](examples/material/get_materials_by_formula.ipynb) | Shows how [queries](https://docs.mat3ra.com/rest-api/query-structure/) can be made to search for materials stored on your account by their formula. In this example, we search for a system containing Si.
1313
| [Examples/Material](examples/material/) | [Create Material](examples/material/create_material.ipynb) | Gives an overview of how materials can be generated in [JSON format](https://docs.mat3ra.com/materials/data/) and uploaded to your user account. In this example, we create an FCC Si crystal and upload it.
1414
| [Examples/Material](examples/material/) | [Import Materials from Materials Project](examples/material/import_materials_from_materialsproject.ipynb) | Demonstrates how materials can be imported from [Materials Project](https://materialsproject.org/about), if their Materials Project ID is known. In this example, we import monoclinic and hexagonal SiGe cells.
15-
| [Examples/Material](examples/material/) | [Import Materials from Poscar](examples/material/import_materials_from_poscar.ipynb) | Provides an example of how materials can be imported directly from Poscar files (a common chemical file format best-known [for its use in VASP](https://www.vasp.at/wiki/index.php/Input)). In this example, we import the unit cell of SiGe.
15+
| [Examples/Material](examples/material/) | [Import Materials from Poscar](examples/material/upload_materials_from_file_poscar.ipynb) | Provides an example of how materials can be imported directly from Poscar files (a common chemical file format best-known [for its use in VASP](https://www.vasp.at/wiki/index.php/Input)). In this example, we import the unit cell of SiGe.
1616
| [Examples/Material](examples/material/) | [Interoperability between Mat3ra and Materials Project](examples/material/api_interoperability_showcase.ipynb) | In this notebook, we showcase a major advantage of APIs: interoperability. We begin by performing a query using the [Materials Project](https://materialsproject.org) API for all systems containing Iron and Oxygen. We then filter our results (for demonstraiton purposes, we keep only the first 10 materials found). Finally, we upload our results to the Mat3ra platform, where further calculations could be performed to characterize these materials.
1717
| [Examples/Job](examples/job/) | [Create and Submit Job](examples/job/create_and_submit_job.ipynb) | Shows how to use the Mat3ra API to [create jobs](https://docs.mat3ra.com/jobs/data/) and run them on our cluster. In this example, we run a DFT calculation to get the total energy of an FCC Si unit cell using Quantum Espresso.
1818
| [Examples/Job](examples/job/) | [Get File from Job](examples/job/get-file-from-job.ipynb) | Guides you through using the Mat3ra API to query for a list of files produced by a job, describes the metadata assigned to each file, and ends by demonstrating how to download any remote file generated by a job to the local disk.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"<a href=\"https://colab.research.google.com/github/Exabyte-io/api-examples/blob/dev/other/material/import_material_from_jarvis_db_entry.ipynb\" target=\"_parent\">\n",
7+
"<img alt=\"Open in Google Colab\" src=\"https://user-images.githubusercontent.com/20477508/128780728-491fea90-9b23-495f-a091-11681150db37.jpeg\" width=\"150\" border=\"0\">\n",
8+
"</a>"
9+
],
10+
"metadata": {
11+
"collapsed": false
12+
},
13+
"id": "3c567b6400249971"
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"source": [
18+
"## Install Packages\n",
19+
"First, install `express-py` which includes `jarvis-tools` as dependency."
20+
],
21+
"metadata": {
22+
"collapsed": false
23+
},
24+
"id": "8b00ab6854f2263b"
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"outputs": [],
30+
"source": [
31+
"!pip install express-py==2024.1.25.post7"
32+
],
33+
"metadata": {
34+
"collapsed": false
35+
},
36+
"id": "b1288bc79ee2c828"
37+
},
38+
{
39+
"cell_type": "markdown",
40+
"source": [
41+
"## Get Materials Data From JARVIS\n",
42+
"Then, let's get the dataset containing 2D materials from JARVIS and wrap it into a pandas dataframe."
43+
],
44+
"metadata": {
45+
"collapsed": false
46+
},
47+
"id": "f418c51a7f794f9f"
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"outputs": [],
53+
"source": [
54+
"import pandas as pd\n",
55+
"from jarvis.db.figshare import data, get_jid_data\n",
56+
"\n",
57+
"dft_2d=data('dft_2d')\n",
58+
"df = pd.DataFrame(dft_2d)"
59+
],
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"id": "b1ee775d1476f884"
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"source": [
68+
"## Extract Structure and Convert to ESSE\n",
69+
"Next, we extract an entry from the JARVIS dataset and convert it into ESSE format ready to be uploaded to Mat3ra.com."
70+
],
71+
"metadata": {
72+
"collapsed": false
73+
},
74+
"id": "15fe5f9de299c935"
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"outputs": [],
80+
"source": [
81+
"import json\n",
82+
"## Note: JVASP-670 is an entry for MoTe2\n",
83+
"jarvis_db_entry = json.dumps(json.loads(df[(df['jid']=='JVASP-670')].to_json(orient='records'))[0])\n",
84+
"\n",
85+
"kwargs = {\n",
86+
" \"structure_string\": jarvis_db_entry,\n",
87+
" \"cell_type\": \"original\",\n",
88+
" \"structure_format\": \"jarvis-db-entry\"\n",
89+
"}\n",
90+
"\n",
91+
"handler = ExPrESS(\"structure\", **kwargs)\n",
92+
"data = handler.property(\"material\", **kwargs)\n",
93+
"\n",
94+
"# To preview resulting JSON data\n",
95+
"print(json.dumps(data, indent=4))"
96+
],
97+
"metadata": {
98+
"collapsed": false
99+
},
100+
"id": "c41fb68c6d25fe48"
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"source": [
105+
"## Upload to Mat3ra.com\n",
106+
"Finally, we can upload the material to Mat3ra.com using the REST API: follow the explanation in another example notebook [here](../../examples/material/create_material.ipynb)."
107+
],
108+
"metadata": {
109+
"collapsed": false
110+
},
111+
"id": "a4a48479c7ea090f"
112+
}
113+
],
114+
"metadata": {
115+
"kernelspec": {
116+
"display_name": "Python 3",
117+
"language": "python",
118+
"name": "python3"
119+
},
120+
"language_info": {
121+
"codemirror_mode": {
122+
"name": "ipython",
123+
"version": 2
124+
},
125+
"file_extension": ".py",
126+
"mimetype": "text/x-python",
127+
"name": "python",
128+
"nbconvert_exporter": "python",
129+
"pygments_lexer": "ipython2",
130+
"version": "2.7.6"
131+
}
132+
},
133+
"nbformat": 4,
134+
"nbformat_minor": 5
135+
}

0 commit comments

Comments
 (0)