Skip to content

Commit 11ebfda

Browse files
authored
Merge pull request #195 from Exabyte-io/feature/SOF-7525
SnO interstitial
2 parents b028d18 + a5e0316 commit 11ebfda

File tree

1 file changed

+288
-0
lines changed

1 file changed

+288
-0
lines changed
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Oxygen interstitial Defect(s) in SnO.\n",
7+
"\n",
8+
"This example demonstrates how to create a O interstitial defect in a SnO material. Following the publication:\n",
9+
"\n",
10+
"> **A. Togo, F. Oba, and I. Tanaka**\n",
11+
"> \"First-principles calculations of native defects in tin monoxide\"\n",
12+
"> Phys. Rev. B 74, 195128 (2006)\n",
13+
"> [DOI: 10.1103/PhysRevB.74.195128](https://doi.org/10.1103/PhysRevB.74.195128)\n",
14+
"\n",
15+
"Focusing on the Fig 4. a):\n",
16+
"<img src=\"https://i.imgur.com/xlZ4tsE.png\" alt=\"SnO with O-interstitial\" width=\"200\"/>\n",
17+
"\n",
18+
"!Note: Voronoi site placement method is used for the interstitial defect, for a precise reproduction relaxation is needed."
19+
],
20+
"metadata": {
21+
"collapsed": false
22+
},
23+
"id": "f2e1e795020d7b3f"
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"source": [
28+
"## 1. Prepare the Environment\n",
29+
"### 1.1. Set up defects parameters \n",
30+
"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)."
31+
],
32+
"metadata": {
33+
"collapsed": false
34+
},
35+
"id": "5e43ff288847b784"
36+
},
37+
{
38+
"cell_type": "code",
39+
"outputs": [],
40+
"source": [
41+
"MATERIAL_NAME = \"SnO\"\n",
42+
"SUPERCELL_MATRIX = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]\n",
43+
"\n",
44+
"# List of dictionaries with defect parameters\n",
45+
"DEFECT_CONFIGS = [\n",
46+
" {\n",
47+
" \"defect_type\": \"vacancy\",\n",
48+
" \"approximate_coordinate\": [0.0, 0.25, 0.525],\n",
49+
" },\n",
50+
" {\n",
51+
" \"defect_type\": \"interstitial\",\n",
52+
" \"coordinate\": [0.0, 0.25, 0.35],\n",
53+
" \"chemical_element\": \"O\",\n",
54+
" \"placement_method\": \"voronoi_site\"\n",
55+
" }\n",
56+
"]"
57+
],
58+
"metadata": {
59+
"collapsed": false
60+
},
61+
"id": "9d8b1890b34d850a",
62+
"execution_count": null
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"source": [
67+
"### 1.2. Install Packages\n",
68+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
69+
],
70+
"metadata": {
71+
"collapsed": false
72+
},
73+
"id": "bb64de5ff32649f8"
74+
},
75+
{
76+
"cell_type": "code",
77+
"outputs": [],
78+
"source": [
79+
"import sys\n",
80+
"\n",
81+
"if sys.platform == \"emscripten\":\n",
82+
" import micropip\n",
83+
"\n",
84+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
85+
" from utils.jupyterlite import install_packages\n",
86+
"\n",
87+
" await install_packages(\"specific_examples|create_point_defect.ipynb\")"
88+
],
89+
"metadata": {
90+
"collapsed": false
91+
},
92+
"id": "ef664b14457530fd",
93+
"execution_count": null
94+
},
95+
{
96+
"cell_type": "markdown",
97+
"source": [
98+
"### 1.3. Get input material"
99+
],
100+
"metadata": {
101+
"collapsed": false
102+
},
103+
"id": "919ad7af8dceeedd"
104+
},
105+
{
106+
"cell_type": "code",
107+
"outputs": [],
108+
"source": [
109+
"from mat3ra.made.material import Material\n",
110+
"from mat3ra.standata.materials import Materials\n",
111+
"\n",
112+
"material = Material(Materials.get_by_name_first_match(MATERIAL_NAME))"
113+
],
114+
"metadata": {
115+
"collapsed": false
116+
},
117+
"id": "be38fdda1984c654",
118+
"execution_count": null
119+
},
120+
{
121+
"cell_type": "markdown",
122+
"source": [
123+
"### 1.4. Create and preview Supercell"
124+
],
125+
"metadata": {
126+
"collapsed": false
127+
},
128+
"id": "a132fe0ef8bbf0d0"
129+
},
130+
{
131+
"cell_type": "code",
132+
"outputs": [],
133+
"source": [
134+
"from utils.visualize import visualize_materials as visualize\n",
135+
"from mat3ra.made.tools.build.supercell import create_supercell\n",
136+
"\n",
137+
"supercell = create_supercell(material, supercell_matrix=SUPERCELL_MATRIX)\n",
138+
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")"
139+
],
140+
"metadata": {
141+
"collapsed": false
142+
},
143+
"id": "e2d24109d3068c9e",
144+
"execution_count": null
145+
},
146+
{
147+
"cell_type": "markdown",
148+
"source": [
149+
"## 2. Create the Defect\n",
150+
"### 2.1. Initialize Configuration and Builder parameters"
151+
],
152+
"metadata": {
153+
"collapsed": false
154+
},
155+
"id": "5da5b0380583c952"
156+
},
157+
{
158+
"cell_type": "code",
159+
"outputs": [],
160+
"source": [
161+
"from mat3ra.made.tools.build.defect import PointDefectConfiguration\n",
162+
"from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters, \\\n",
163+
" VoronoiInterstitialPointDefectBuilderParameters\n",
164+
"\n",
165+
"defect_configurations = [PointDefectConfiguration.from_dict(\n",
166+
" crystal=supercell,\n",
167+
" data=DEFECT_CONFIG,\n",
168+
") for DEFECT_CONFIG in DEFECT_CONFIGS]\n",
169+
"\n",
170+
"params = VoronoiInterstitialPointDefectBuilderParameters(clustering_tol=0.9, min_dist=0.2)"
171+
],
172+
"metadata": {
173+
"collapsed": false
174+
},
175+
"id": "e385e50ae11ed2b9",
176+
"execution_count": null
177+
},
178+
{
179+
"cell_type": "markdown",
180+
"source": [
181+
"### 2.2. Create the defects"
182+
],
183+
"metadata": {
184+
"collapsed": false
185+
},
186+
"id": "489b51f0ee122c48"
187+
},
188+
{
189+
"cell_type": "code",
190+
"outputs": [],
191+
"source": [
192+
"from mat3ra.made.tools.build.defect import create_defects\n",
193+
"\n",
194+
"material_with_defect = create_defects(configurations=defect_configurations, builder_parameters=params)"
195+
],
196+
"metadata": {
197+
"collapsed": false
198+
},
199+
"id": "a990fa35742d7269",
200+
"execution_count": null
201+
},
202+
{
203+
"cell_type": "markdown",
204+
"source": [
205+
"## 3. Visualize Result(s)"
206+
],
207+
"metadata": {
208+
"collapsed": false
209+
},
210+
"id": "462549d016073446"
211+
},
212+
{
213+
"cell_type": "code",
214+
"outputs": [],
215+
"source": [
216+
"from utils.visualize import visualize_materials as visualize\n",
217+
"\n",
218+
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
219+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n",
220+
" rotation=\"-90x\")\n",
221+
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
222+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n",
223+
" rotation=\"-90x,90y\"\n",
224+
" )"
225+
],
226+
"metadata": {
227+
"collapsed": false
228+
},
229+
"id": "509b18661a069e42",
230+
"execution_count": null
231+
},
232+
{
233+
"cell_type": "markdown",
234+
"source": [
235+
"## 4. Pass data to the outside runtime"
236+
],
237+
"metadata": {
238+
"collapsed": false
239+
},
240+
"id": "d381df29a6bbdd82"
241+
},
242+
{
243+
"cell_type": "code",
244+
"outputs": [],
245+
"source": [
246+
"from utils.jupyterlite import set_materials, download_content_to_file\n",
247+
"\n",
248+
"set_materials([material_with_defect])\n",
249+
"download_content_to_file(material_with_defect, f\"{material_with_defect.name}.json\")"
250+
],
251+
"metadata": {
252+
"collapsed": false
253+
},
254+
"id": "61daa5afcbc078a9",
255+
"execution_count": null
256+
},
257+
{
258+
"cell_type": "code",
259+
"outputs": [],
260+
"source": [],
261+
"metadata": {
262+
"collapsed": false
263+
},
264+
"id": "2c7d61327984af1c"
265+
}
266+
],
267+
"metadata": {
268+
"kernelspec": {
269+
"display_name": "Python 3",
270+
"language": "python",
271+
"name": "python3"
272+
},
273+
"language_info": {
274+
"codemirror_mode": {
275+
"name": "ipython",
276+
"version": 2
277+
},
278+
"file_extension": ".py",
279+
"mimetype": "text/x-python",
280+
"name": "python",
281+
"nbconvert_exporter": "python",
282+
"pygments_lexer": "ipython2",
283+
"version": "2.7.6"
284+
}
285+
},
286+
"nbformat": 4,
287+
"nbformat_minor": 5
288+
}

0 commit comments

Comments
 (0)