Skip to content

Commit 06642f7

Browse files
authored
Merge pull request #187 from Exabyte-io/feature/SOF-7524
feature/SOF-7524 B-vacancy hBN
2 parents ddfdc52 + f84d340 commit 06642f7

File tree

1 file changed

+291
-0
lines changed

1 file changed

+291
-0
lines changed
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "f0ccd3190ce70a68",
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"source": [
10+
"# Vacancy Point Defect in boron nitride (h-BN)\n",
11+
"\n",
12+
"## 0. Introduction\n",
13+
"\n",
14+
"This tutorial demonstrates the process of creating materials with vacancy defects, based on the work presented in the following manuscript:\n",
15+
"\n",
16+
"> **Fabian Bertoldo, Sajid Ali, Simone Manti & Kristian S. Thygesen**,\n",
17+
"> \"Quantum point defects in 2D materials - the QPOD database\", Nature, 2022. \n",
18+
"> [DOI:10.1038/s41524-022-00730-w](https://doi.org/10.1038/s41524-022-00730-w)\n",
19+
"\n",
20+
"Below is the figure 1 from the manuscript demonstrating the boron vacancy defects in hexagonal boron nitride (hBN).\n",
21+
"\n",
22+
"In this notebook we will reproduce material from FIG. 6\n",
23+
"\n",
24+
"\n",
25+
"<img src=\"https://i.imgur.com/VsBdZ7g.png\" alt=\"vacancy in hBN\" width=\"400\"/>\n",
26+
"\n"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"id": "aae97744e3023a1b",
32+
"metadata": {
33+
"collapsed": false
34+
},
35+
"source": [
36+
"## 1. Prepare the Environment\n",
37+
"### 1.1. Set up defects parameters \n",
38+
"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).\n",
39+
"\n",
40+
"Note that we use approximate coordinates in crystal coordinates to define the defect positions. The approximate coordinates are used to find the closest site in the crystal to the given coordinates. The approximate coordinates are in the range of [0, 1] for each axis. Adjust the approximate coordinates to place the defect at the desired site in the crystal. Using the visuals provided in the notebook could help in determining the approximate coordinates.\n",
41+
"(Coordinates can be found using 3D editor in Materials Designer)"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 25,
47+
"id": "dff59577346dbece",
48+
"metadata": {
49+
"collapsed": false
50+
},
51+
"outputs": [],
52+
"source": [
53+
"WIDTH = 4 # in unit cell vector length\n",
54+
"LENGTH = 6 # in unit cell vector length\n",
55+
"VACUUM_WIDTH = 0 # in unit cell vector length\n",
56+
"VACUUM_LENGTH = 0 # in unit cell vector length\n",
57+
"\n",
58+
"DEFECT_CONFIGS = [\n",
59+
" {\n",
60+
" \"defect_type\": \"vacancy\",\n",
61+
" \"approximate_coordinate\": [0.5, 0.45, 0.5], # in crystall coordinates\n",
62+
" \"use_cartesian_coordinates\": False\n",
63+
" },\n",
64+
"\n",
65+
"]"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"id": "14d161d4b61ca219",
71+
"metadata": {
72+
"collapsed": false
73+
},
74+
"source": [
75+
"### 1.2. Install Packages\n",
76+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 26,
82+
"id": "8c6ea8b36f1a6cc",
83+
"metadata": {
84+
"collapsed": false
85+
},
86+
"outputs": [],
87+
"source": [
88+
"import sys\n",
89+
"\n",
90+
"if sys.platform == \"emscripten\":\n",
91+
" import micropip\n",
92+
"\n",
93+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
94+
" from utils.jupyterlite import install_packages\n",
95+
"\n",
96+
" await install_packages(\"specific_examples|create_point_defect.ipynb\")"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"id": "da6733a515019677",
102+
"metadata": {
103+
"collapsed": false
104+
},
105+
"source": [
106+
"### 1.3. Load input material\n",
107+
"In this notebook we will use the material from the `uploads` folder that has a few pre-set materials."
108+
]
109+
},
110+
{
111+
"cell_type": "code",
112+
"execution_count": 27,
113+
"id": "14c40630ba2974e6",
114+
"metadata": {
115+
"collapsed": false
116+
},
117+
"outputs": [],
118+
"source": [
119+
"from mat3ra.made.material import Material\n",
120+
"from mat3ra.standata.materials import Materials\n",
121+
"\n",
122+
"material = Material(Materials.get_by_name_and_categories(\"Boron_Nitride\", \"2D\"))"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"id": "9fcc51573071c301",
128+
"metadata": {
129+
"collapsed": false
130+
},
131+
"source": [
132+
"### 1.4. Create and preview Nanoribbon"
133+
]
134+
},
135+
{
136+
"cell_type": "code",
137+
"execution_count": null,
138+
"id": "6d5a793dd5e45f16",
139+
"metadata": {
140+
"collapsed": false
141+
},
142+
"outputs": [],
143+
"source": [
144+
"from utils.visualize import visualize_materials as visualize\n",
145+
"from mat3ra.made.tools.build.nanoribbon import NanoribbonConfiguration, create_nanoribbon\n",
146+
"\n",
147+
"config = NanoribbonConfiguration(\n",
148+
" material=material,\n",
149+
" width=WIDTH,\n",
150+
" length=LENGTH,\n",
151+
" vacuum_width=VACUUM_WIDTH,\n",
152+
" vacuum_length=VACUUM_LENGTH,\n",
153+
" edge_type=\"zigzag\")\n",
154+
"\n",
155+
"nanoribbon = create_nanoribbon(config)\n",
156+
"\n",
157+
"visualize(nanoribbon, repetitions=[1, 1, 1], rotation=\"0x\")\n",
158+
"visualize(nanoribbon, repetitions=[1, 1, 1], rotation=\"-90x\")"
159+
]
160+
},
161+
{
162+
"cell_type": "markdown",
163+
"id": "e41cf1646620915d",
164+
"metadata": {
165+
"collapsed": false
166+
},
167+
"source": [
168+
"## 2. Create the Defect\n",
169+
"### 2.1. Initialize Configuration and Builder parameters"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": 29,
175+
"id": "ae3bc8ed1bf133f4",
176+
"metadata": {
177+
"collapsed": false
178+
},
179+
"outputs": [],
180+
"source": [
181+
"from mat3ra.made.tools.build.defect import PointDefectConfiguration\n",
182+
"from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n",
183+
"\n",
184+
"defect_configurations = [PointDefectConfiguration.from_dict(nanoribbon, defect) for defect in DEFECT_CONFIGS]\n",
185+
"\n",
186+
"defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)"
187+
]
188+
},
189+
{
190+
"cell_type": "markdown",
191+
"id": "3a7b1416f29b2606",
192+
"metadata": {
193+
"collapsed": false
194+
},
195+
"source": [
196+
"### 2.2. Create the defects"
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": 30,
202+
"id": "db2d621e2fd4bbeb",
203+
"metadata": {
204+
"collapsed": false
205+
},
206+
"outputs": [],
207+
"source": [
208+
"from mat3ra.made.tools.build.defect import create_defects\n",
209+
"\n",
210+
"material_with_defect = create_defects(\n",
211+
" builder_parameters=defect_builder_parameters,\n",
212+
" configurations=defect_configurations\n",
213+
")"
214+
]
215+
},
216+
{
217+
"cell_type": "markdown",
218+
"id": "2b58b5e76bd167d8",
219+
"metadata": {
220+
"collapsed": false
221+
},
222+
"source": [
223+
"## 3. Visualize Result(s)"
224+
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": null,
229+
"id": "d4a1e920884b1a48",
230+
"metadata": {
231+
"collapsed": false
232+
},
233+
"outputs": [],
234+
"source": [
235+
"from utils.visualize import visualize_materials as visualize\n",
236+
"\n",
237+
"visualize([{\"material\": nanoribbon, \"title\": \"Original material\"},\n",
238+
" {\"material\": material_with_defect, \"title\": \"Material with defect\"}],\n",
239+
" rotation=\"-90x\")\n",
240+
"visualize([{\"material\": nanoribbon, \"title\": \"Original material\"},\n",
241+
" {\"material\": material_with_defect, \"title\": \"Material with defect\"}])"
242+
]
243+
},
244+
{
245+
"cell_type": "markdown",
246+
"id": "865c3b666e06fd10",
247+
"metadata": {
248+
"collapsed": false
249+
},
250+
"source": [
251+
"## 4. Write resulting material to the folder"
252+
]
253+
},
254+
{
255+
"cell_type": "code",
256+
"execution_count": null,
257+
"id": "7dcf867f46422fa9",
258+
"metadata": {
259+
"collapsed": false
260+
},
261+
"outputs": [],
262+
"source": [
263+
"from utils.jupyterlite import download_content_to_file\n",
264+
"\n",
265+
"material_with_defect.name = \"N-doped h-BN\"\n",
266+
"download_content_to_file(material_with_defect.to_json(), \"B-vacancy_hexagonal_boron_nitride.json\")"
267+
]
268+
}
269+
],
270+
"metadata": {
271+
"kernelspec": {
272+
"display_name": ".venv-3.11",
273+
"language": "python",
274+
"name": "python3"
275+
},
276+
"language_info": {
277+
"codemirror_mode": {
278+
"name": "ipython",
279+
"version": 3
280+
},
281+
"file_extension": ".py",
282+
"mimetype": "text/x-python",
283+
"name": "python",
284+
"nbconvert_exporter": "python",
285+
"pygments_lexer": "ipython3",
286+
"version": "3.11.7"
287+
}
288+
},
289+
"nbformat": 4,
290+
"nbformat_minor": 5
291+
}

0 commit comments

Comments
 (0)