Skip to content

Commit 8a1d506

Browse files
authored
Merge pull request #172 from Exabyte-io/feature/SOF-7507
feature/SOF-7507 feat: Mg in GaN defect tutorial
2 parents c37ece6 + 48a6b4b commit 8a1d506

2 files changed

Lines changed: 269 additions & 6 deletions

File tree

other/materials_designer/create_point_defect_pair.ipynb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
"cell_type": "code",
4141
"outputs": [],
4242
"source": [
43-
"DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
44-
"SITE_ID = None # Site index of the defect\n",
45-
"COORDINATE = None # Position of the defect in crystal coordinates\n",
46-
"APPROXIMATE_COORDINATE = None # Approximate coordinates of the defect in crystal coordinates\n",
47-
"CHEMICAL_ELEMENT = \"C\" # Element to be placed at the site (ignored for vacancy)\n",
48-
"\n",
4943
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n",
5044
"\n",
5145
"# List of dictionaries with defect parameters\n",
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Vacancy and Substitutional defect pair in GaN\n",
7+
"\n",
8+
"Focusing on recreating the defect pair in GaN from the Figure 1. c) in the publication:\n",
9+
"\n",
10+
"<img src=\"https://i.imgur.com/1JsDwXO.png\" width=\"400\" />"
11+
],
12+
"metadata": {
13+
"collapsed": false
14+
},
15+
"id": "4f901763903359e6"
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"source": [
20+
"## 1. Prepare the Environment\n",
21+
"### 1.1. Set up defects parameters \n",
22+
"Defect Configuration parameters are described in [Defect Configuration](https://github.com/Exabyte-io/made/blob/8196b759242551c77d1791bf5bd2f4150763cfef/src/py/mat3ra/made/tools/build/defect/configuration.py#L102)."
23+
],
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"id": "7863267c827cfbc2"
28+
},
29+
{
30+
"cell_type": "code",
31+
"outputs": [],
32+
"source": [
33+
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 2]]\n",
34+
"\n",
35+
"# List of dictionaries with defect parameters\n",
36+
"PRIMARY_DEFECT_CONFIG = {\n",
37+
" \"defect_type\": \"substitution\",\n",
38+
" \"approximate_coordinate\": [0.5, 0.5, 0.5],\n",
39+
" \"chemical_element\": \"Mg\",\n",
40+
"}\n",
41+
"\n",
42+
"SECONDARY_DEFECT_CONFIG = {\n",
43+
" \"defect_type\": \"vacancy\",\n",
44+
" \"approximate_coordinate\": [0.5, 0.5, 0.65],\n",
45+
"}"
46+
],
47+
"metadata": {
48+
"collapsed": false
49+
},
50+
"id": "2719b1a0b211ce20",
51+
"execution_count": null
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"source": [
56+
"### 1.2. Install Packages\n",
57+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
58+
],
59+
"metadata": {
60+
"collapsed": false
61+
},
62+
"id": "5626829bece625b"
63+
},
64+
{
65+
"cell_type": "code",
66+
"outputs": [],
67+
"source": [
68+
"import sys\n",
69+
"\n",
70+
"if sys.platform == \"emscripten\":\n",
71+
" import micropip\n",
72+
"\n",
73+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
74+
" from utils.jupyterlite import install_packages\n",
75+
"\n",
76+
" await install_packages(\"create_point_defect.ipynb\")"
77+
],
78+
"metadata": {
79+
"collapsed": false
80+
},
81+
"id": "f4994342ac9f2cbd",
82+
"execution_count": null
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"source": [
87+
"### 1.3. Get input materials\n",
88+
"Materials are loaded with `get_materials()`."
89+
],
90+
"metadata": {
91+
"collapsed": false
92+
},
93+
"id": "683ce558645b4465"
94+
},
95+
{
96+
"cell_type": "code",
97+
"outputs": [],
98+
"source": [
99+
"from mat3ra.standata.materials import Materials\n",
100+
"from mat3ra.made.material import Material\n",
101+
"\n",
102+
"material = Material(Materials.get_by_name_first_match(\"GaN\"))"
103+
],
104+
"metadata": {
105+
"collapsed": false
106+
},
107+
"id": "4a6bab14f63024d1",
108+
"execution_count": null
109+
},
110+
{
111+
"cell_type": "markdown",
112+
"source": [
113+
"### 1.4. Create and preview Supercell"
114+
],
115+
"metadata": {
116+
"collapsed": false
117+
},
118+
"id": "acfef1aa207eb977"
119+
},
120+
{
121+
"cell_type": "code",
122+
"outputs": [],
123+
"source": [
124+
"from utils.visualize import visualize_materials as visualize\n",
125+
"from mat3ra.made.tools.build.supercell import create_supercell\n",
126+
"\n",
127+
"unit_cell = material\n",
128+
"supercell = create_supercell(unit_cell, supercell_matrix=SUPERCELL_MATRIX)\n",
129+
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")"
130+
],
131+
"metadata": {
132+
"collapsed": false
133+
},
134+
"id": "4580fda63efa927e",
135+
"execution_count": null
136+
},
137+
{
138+
"cell_type": "markdown",
139+
"source": [
140+
"## 2. Create the Defect\n",
141+
"### 2.1. Initialize Configuration and Builder parameters"
142+
],
143+
"metadata": {
144+
"collapsed": false
145+
},
146+
"id": "4391a0f444f4b64a"
147+
},
148+
{
149+
"cell_type": "code",
150+
"outputs": [],
151+
"source": [
152+
"from mat3ra.made.tools.build.defect.configuration import PointDefectPairConfiguration, PointDefectConfiguration\n",
153+
"from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n",
154+
"\n",
155+
"primary_defect_configuration = PointDefectConfiguration.from_dict(supercell, PRIMARY_DEFECT_CONFIG)\n",
156+
"secondary_defect_configuration = PointDefectConfiguration.from_dict(supercell, SECONDARY_DEFECT_CONFIG)\n",
157+
"\n",
158+
"point_defect_pair_configuration = PointDefectPairConfiguration(\n",
159+
" primary_defect_configuration=primary_defect_configuration,\n",
160+
" secondary_defect_configuration=secondary_defect_configuration\n",
161+
")\n",
162+
"\n",
163+
"defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)"
164+
],
165+
"metadata": {
166+
"collapsed": false
167+
},
168+
"id": "c686498fc4419e3c",
169+
"execution_count": null
170+
},
171+
{
172+
"cell_type": "markdown",
173+
"source": [
174+
"### 2.2. Create the defects"
175+
],
176+
"metadata": {
177+
"collapsed": false
178+
},
179+
"id": "358ae5cd995c821f"
180+
},
181+
{
182+
"cell_type": "code",
183+
"outputs": [],
184+
"source": [
185+
"from mat3ra.made.tools.build.defect.builders import PointDefectPairBuilder\n",
186+
"\n",
187+
"material_with_defect = PointDefectPairBuilder(defect_builder_parameters).get_material(point_defect_pair_configuration)"
188+
],
189+
"metadata": {
190+
"collapsed": false
191+
},
192+
"id": "7a584be241ab1548",
193+
"execution_count": null
194+
},
195+
{
196+
"cell_type": "markdown",
197+
"source": [
198+
"## 3. Visualize Result(s)"
199+
],
200+
"metadata": {
201+
"collapsed": false
202+
},
203+
"id": "f99753a31e0123a"
204+
},
205+
{
206+
"cell_type": "code",
207+
"outputs": [],
208+
"source": [
209+
"from utils.visualize import visualize_materials as visualize\n",
210+
"\n",
211+
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
212+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n",
213+
" rotation=\"-90x\")\n",
214+
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
215+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])"
216+
],
217+
"metadata": {
218+
"collapsed": false
219+
},
220+
"id": "951f0cffe9389d5e",
221+
"execution_count": null
222+
},
223+
{
224+
"cell_type": "markdown",
225+
"source": [
226+
"## 4. Pass data to the outside runtime"
227+
],
228+
"metadata": {
229+
"collapsed": false
230+
},
231+
"id": "1c5d8e66b5b105ee"
232+
},
233+
{
234+
"cell_type": "code",
235+
"outputs": [],
236+
"source": [
237+
"from utils.jupyterlite import download_content_to_file\n",
238+
"\n",
239+
"download_content_to_file(material_with_defect, \"Mg substitution and vacancy in GaN.json\")"
240+
],
241+
"metadata": {
242+
"collapsed": false
243+
},
244+
"id": "b9e1aba13faf1bf0",
245+
"execution_count": null
246+
}
247+
],
248+
"metadata": {
249+
"kernelspec": {
250+
"display_name": "Python 3",
251+
"language": "python",
252+
"name": "python3"
253+
},
254+
"language_info": {
255+
"codemirror_mode": {
256+
"name": "ipython",
257+
"version": 2
258+
},
259+
"file_extension": ".py",
260+
"mimetype": "text/x-python",
261+
"name": "python",
262+
"nbconvert_exporter": "python",
263+
"pygments_lexer": "ipython2",
264+
"version": "2.7.6"
265+
}
266+
},
267+
"nbformat": 4,
268+
"nbformat_minor": 5
269+
}

0 commit comments

Comments
 (0)