Skip to content

Commit 806f64a

Browse files
Merge pull request #160 from Exabyte-io/feature/SOF-7488
feature/SOF-7488 import from Standata
2 parents b13cabd + 8c4b056 commit 806f64a

File tree

2 files changed

+186
-3
lines changed

2 files changed

+186
-3
lines changed

other/materials_designer/Introduction.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@
7676
"\n",
7777
"### 6.1. Import Data.\n",
7878
"\n",
79-
"#### [6.1.1. Import from files in ASE-supported formats](import_materials_from_files.ipynb).\n",
79+
"#### [6.1.1. Import from Mat3ra Standata](import_materials_from_standata.ipynb).\n",
80+
"\n",
81+
"#### [6.1.2. Import from files in ASE-supported formats](import_materials_from_files.ipynb).\n",
8082
"\n",
8183
"Converting materials data from user-uploaded files in [formats supported by ASE](https://wiki.fysik.dtu.dk/ase/ase/io/io.html) into ESSE format for use with Mat3ra.com platform.\n",
8284
"\n",
83-
"#### [6.1.2. Materials import from JARVIS](import_material_from_jarvis_db_entry.ipynb).\n",
85+
"#### [6.1.3. Import from JARVIS-NIST](import_material_from_jarvis_db_entry.ipynb).\n",
8486
"\n",
85-
"This notebook demonstrates a workflow for converting materials data from the [JARVIS](https://jarvis.nist.gov/) database into ESSE format for use with Mat3ra.com platform.\n",
87+
"This notebook demonstrates a workflow for converting materials data from the [JARVIS](https://jarvis.nist.gov/) database into ESSE format for use with the Mat3ra.com platform.\n",
8688
"\n",
8789
"## 7. Read more\n",
8890
"\n",
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Import materials from Standata\n",
7+
"\n",
8+
"This notebook uses Mat3ra Standata package to import materials.\n",
9+
"\n",
10+
"<h2 style=\"color:green\">Usage</h2>\n",
11+
"\n",
12+
"1. Run the first cell to import the required libraries.\n",
13+
"2. Run the second cell to get the list of available materials.\n",
14+
"3. Run the third cell to select a material by name.\n",
15+
"4. Run the fourth cell to select materials by categories\n"
16+
],
17+
"metadata": {
18+
"collapsed": false
19+
},
20+
"id": "ffad30f04755fde0"
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"source": [
25+
"## 1. Install the required libraries"
26+
],
27+
"metadata": {
28+
"collapsed": false
29+
},
30+
"id": "3a21510793fa71f1"
31+
},
32+
{
33+
"cell_type": "code",
34+
"outputs": [],
35+
"source": [
36+
"import sys\n",
37+
"\n",
38+
"if sys.platform == \"emscripten\":\n",
39+
" import micropip\n",
40+
" \n",
41+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
42+
" await micropip.install('mat3ra-standata')\n",
43+
" from utils.jupyterlite import install_packages\n",
44+
" await install_packages(\"\", \"../../config.yml\")"
45+
],
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"id": "7a8c49f4612498a6",
50+
"execution_count": null
51+
},
52+
{
53+
"cell_type": "markdown",
54+
"source": [
55+
"## 2. Get materials\n",
56+
"### 2.1. List the names of available materials"
57+
],
58+
"metadata": {
59+
"collapsed": false
60+
},
61+
"id": "bd6a3ff0c7b23744"
62+
},
63+
{
64+
"cell_type": "code",
65+
"outputs": [],
66+
"source": [
67+
"from mat3ra.standata.materials import Materials\n",
68+
"Materials.get_names()"
69+
],
70+
"metadata": {
71+
"collapsed": false
72+
},
73+
"id": "494aa9dceabed0e1",
74+
"execution_count": null
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"source": [
79+
"### 2.2. Select a material by name\n",
80+
"A partial name match can be used to select a material."
81+
],
82+
"metadata": {
83+
"collapsed": false
84+
},
85+
"id": "c29a8101462297ad"
86+
},
87+
{
88+
"cell_type": "code",
89+
"outputs": [],
90+
"source": [
91+
"from mat3ra.made.material import Material\n",
92+
"from utils.visualize import visualize_materials\n",
93+
"\n",
94+
"# use colloquial name, formula, dimensionality to select a material\n",
95+
"# returned material is a JSON object and needs to be converted to Material object\n",
96+
"material_by_name = Material(Materials.get_by_name(\"Graphene\")[0])\n",
97+
"material_by_name_first_match = Material(Materials.get_by_name_first_match(\"Graphene\"))\n",
98+
"visualize_materials([material_by_name, material_by_name_first_match])"
99+
],
100+
"metadata": {
101+
"collapsed": false
102+
},
103+
"id": "a570e2668e86dfab",
104+
"execution_count": null
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"source": [
109+
"### 2.3. Select materials by categories"
110+
],
111+
"metadata": {
112+
"collapsed": false
113+
},
114+
"id": "456456a81a911d66"
115+
},
116+
{
117+
"cell_type": "code",
118+
"outputs": [],
119+
"source": [
120+
"materials_2d_jsons = Materials.get_by_categories(\"2D\")\n",
121+
"materials_2d = [Material(material_json) for material_json in materials_2d_jsons]\n",
122+
"\n",
123+
"materials_3d_insulator_jsons = Materials.get_by_categories(\"3D\", \"Insulator\")\n",
124+
"materials_3d_insulator = [Material(material_json) for material_json in materials_3d_insulator_jsons]\n",
125+
"\n",
126+
"visualize_materials(materials_2d)\n",
127+
"visualize_materials(materials_3d_insulator)"
128+
],
129+
"metadata": {
130+
"collapsed": false
131+
},
132+
"id": "5f192496ce7776af",
133+
"execution_count": null
134+
},
135+
{
136+
"cell_type": "markdown",
137+
"source": [
138+
"## 3. Pass data to the outside runtime"
139+
],
140+
"metadata": {
141+
"collapsed": false
142+
},
143+
"id": "937e08e1120711f0"
144+
},
145+
{
146+
"cell_type": "code",
147+
"outputs": [],
148+
"source": [
149+
"from utils.jupyterlite import set_materials\n",
150+
"\n",
151+
"set_materials(materials_2d + materials_3d_insulator)"
152+
],
153+
"metadata": {
154+
"collapsed": false
155+
},
156+
"id": "dcb45a2daead9d55",
157+
"execution_count": null
158+
}
159+
],
160+
"metadata": {
161+
"kernelspec": {
162+
"display_name": "Python 3",
163+
"language": "python",
164+
"name": "python3"
165+
},
166+
"language_info": {
167+
"codemirror_mode": {
168+
"name": "ipython",
169+
"version": 2
170+
},
171+
"file_extension": ".py",
172+
"mimetype": "text/x-python",
173+
"name": "python",
174+
"nbconvert_exporter": "python",
175+
"pygments_lexer": "ipython2",
176+
"version": "2.7.6"
177+
}
178+
},
179+
"nbformat": 4,
180+
"nbformat_minor": 5
181+
}

0 commit comments

Comments
 (0)