Skip to content

Commit 0c601c1

Browse files
authored
Merge pull request #157 from Exabyte-io/feature/SOF-7414
feature/SOF-7414 adatom tutorial NB
2 parents 2854d94 + f75108b commit 0c601c1

File tree

2 files changed

+309
-12
lines changed

2 files changed

+309
-12
lines changed

other/materials_designer/create_adatom_defect.ipynb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"source": [
66
"# Create adatom defects in a slab material\n",
77
"\n",
8-
"Create an adatom by specifying the chemical element, approximate position on surface and distance z, which will be resolved to:\n",
8+
"Create an adatom by specifying the chemical element, approximate position on surface and distance z, as well as placement method which will be resolved to:\n",
9+
"- exact coordinate,\n",
10+
"- closest site to provided coordinate,\n",
911
"- the equidistant position between the closes atoms on the surface according to Voronoi tesselation, \n",
1012
"- or the crystal site of the next layer that is closest to specified position.\n",
1113
"\n",
@@ -49,9 +51,13 @@
4951
"outputs": [],
5052
"source": [
5153
"DEFECT_TYPE = \"adatom\" \n",
54+
"PLACEMENT_METHOD = \"equidistant\" # Choose between \"equidistant\", \"crystal_site\", \"closest_site\", and \"coordinate\"\n",
55+
"CHEMICAL_ELEMENT = \"Si\" # Element to be placed at the site \n",
5256
"APPROXIMATE_POSITION_ON_SURFACE = [0.5, 0.5] # Position of the defect in crystal coordinates\n",
57+
"USE_CARTESIAN_COORDINATES = False # If True, the position is in Cartesian coordinates\n",
5358
"DISTANCE_Z = 2.0 # Distance of the defect from the surface in Angstrom\n",
54-
"CHEMICAL_ELEMENT = \"Si\" # Element to be placed at the site \n",
59+
"\n",
60+
"# Slab parameters\n",
5561
"MILLER_INDICES = (1, 1, 1) # Miller indices of the surface\n",
5662
"SLAB_THICKNESS = 3 # Thickness of the slab in unit cells\n",
5763
"VACUUM = 6 # Vacuum thickness in Angstrom\n",
@@ -168,13 +174,14 @@
168174
"outputs": [],
169175
"source": [
170176
"from mat3ra.made.tools.build.defect import AdatomSlabPointDefectConfiguration\n",
171-
"from mat3ra.made.tools.build.defect.builders import EquidistantAdatomSlabDefectBuilder, CrystalSiteAdatomSlabDefectBuilder\n",
172177
"\n",
173178
"adatom_config = AdatomSlabPointDefectConfiguration(crystal=slab, \n",
174179
" defect_type=DEFECT_TYPE, \n",
180+
" placement_method=PLACEMENT_METHOD,\n",
175181
" chemical_element=CHEMICAL_ELEMENT, \n",
182+
" position_on_surface=APPROXIMATE_POSITION_ON_SURFACE,\n",
176183
" distance_z=DISTANCE_Z, \n",
177-
" position_on_surface=APPROXIMATE_POSITION_ON_SURFACE\n",
184+
" use_cartesian_coordinates=USE_CARTESIAN_COORDINATES\n",
178185
")"
179186
],
180187
"metadata": {
@@ -198,9 +205,7 @@
198205
"outputs": [],
199206
"source": [
200207
"from mat3ra.made.tools.build.defect import create_slab_defect\n",
201-
"slab_with_adatom_at_specified_position = create_slab_defect(adatom_config)\n",
202-
"slab_with_adatom_at_equidistant_position = create_slab_defect(adatom_config, EquidistantAdatomSlabDefectBuilder())\n",
203-
"slab_with_adatom_at_crystal_site = create_slab_defect(adatom_config, CrystalSiteAdatomSlabDefectBuilder())"
208+
"slab_with_adatom = create_slab_defect(adatom_config)"
204209
],
205210
"metadata": {
206211
"collapsed": false
@@ -225,13 +230,11 @@
225230
"from utils.visualize import visualize_materials as visualize\n",
226231
"\n",
227232
"visualize([{\"material\": slab, \"title\": \"Original material\"},\n",
228-
" {\"material\": slab_with_adatom_at_equidistant_position, \"title\": f\"Material with adatom defect at equidistant position\"},\n",
229-
" {\"material\": slab_with_adatom_at_crystal_site, \"title\": f\"Material with adatom defect at crystal site\"}],\n",
233+
" {\"material\": slab_with_adatom, \"title\": f\"Material with adatom defect at {PLACEMENT_METHOD} position\"}],\n",
230234
" rotation=\"-90x\"\n",
231235
" )\n",
232236
"visualize([{\"material\": slab, \"title\": \"Original material\"},\n",
233-
" {\"material\": slab_with_adatom_at_equidistant_position, \"title\": f\"Material with adatom defect at equidistant position\"},\n",
234-
" {\"material\": slab_with_adatom_at_crystal_site, \"title\": f\"Material with adatom defect at crystal site\"}]\n",
237+
" {\"material\": slab_with_adatom, \"title\": f\"Material with adatom defect at {PLACEMENT_METHOD} position\"}],\n",
235238
")"
236239
],
237240
"metadata": {
@@ -256,7 +259,7 @@
256259
"source": [
257260
"from utils.jupyterlite import set_materials\n",
258261
"\n",
259-
"set_materials([slab_with_adatom_at_equidistant_position, slab_with_adatom_at_crystal_site])"
262+
"set_materials([slab_with_adatom])"
260263
],
261264
"metadata": {
262265
"collapsed": false
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Adatom Defect on Graphene surface\n",
7+
"\n",
8+
"## 0. Introduction\n",
9+
"\n",
10+
"This tutorial demonstrates creation of metal adatom on graphene hollow site.\n",
11+
"\n",
12+
"> **Chan, K. T., Neaton, J. B., & Cohen, M. L. (2008).** \n",
13+
"> First-principles study of metal adatom adsorption on graphene. Physical Review B, 77(23). \n",
14+
"> [DOI:10.1103/physrevb.77.235430 ](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.77.235430)\n",
15+
" \n",
16+
"\n",
17+
"Below is the figure 1 from the manuscript that shows the adsorption of metal adatom on graphene hollow site.\n",
18+
"\n",
19+
"\n",
20+
"![Fig 1.](https://i.imgur.com/EByeJg5.png)\n",
21+
"\n"
22+
],
23+
"metadata": {
24+
"collapsed": false
25+
},
26+
"id": "c62d2c5007947f56"
27+
},
28+
{
29+
"cell_type": "markdown",
30+
"source": [
31+
"## 1. Prepare the Environment\n",
32+
"### 1.1. Set up defects parameters \n",
33+
"Adatom Defect Configuration parameters are described in [Adatom Defect Configuration](https://github.com/Exabyte-io/made/blob/8196b759242551c77d1791bf5bd2f4150763cfef/src/py/mat3ra/made/tools/build/defect/configuration.py#L141).\n"
34+
],
35+
"metadata": {
36+
"collapsed": false
37+
},
38+
"id": "4d0772a456c9952c"
39+
},
40+
{
41+
"cell_type": "code",
42+
"outputs": [],
43+
"source": [
44+
"# Name of material to find in Standata\n",
45+
"MATERIAL_NAME = \"Graphene\"\n",
46+
"SUPERCELL_MATRIX = [[4, 0, 0], [0, 4, 0], [0, 0, 1]]\n",
47+
"\n",
48+
"# Defect parameters\n",
49+
"DEFECT_TYPE = \"adatom\"\n",
50+
"PLACEMENT_METHOD = \"coordinate\"\n",
51+
"# Using crystal coordinates for the defect placement\n",
52+
"USE_CARTESIAN_COORDINATES = False \n",
53+
"HOLLOW_SITE_COORDINATE = [1/2, 1/2] # in crystal coordinates\n",
54+
"BRIDGE_SITE_COORDINATE = [3/8, 1/2] # in crystal coordinates\n",
55+
"TOP_SITE_COORDINATE = [7/12, 5/12] # in crystal coordinates\n",
56+
"\n",
57+
"# Setting data according to Table 1 in the manuscript, distance_z is the `h` from the table.\n",
58+
"# Uncomment the lines to create the defect for the desired adatom.\n",
59+
"ADATOM_PARAMETERS = [\n",
60+
" {\"chemical_element\": \"Li\", \"distance_z\": 1.71, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
61+
" {\"chemical_element\": \"Na\", \"distance_z\": 2.28, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
62+
" {\"chemical_element\": \"K\", \"distance_z\": 2.60, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
63+
" # {\"chemical_element\": \"Ca\", \"distance_z\": 2.29, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
64+
" # {\"chemical_element\": \"Al\", \"distance_z\": 2.13, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
65+
" # {\"chemical_element\": \"Ga\", \"distance_z\": 2.20, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
66+
" # {\"chemical_element\": \"In\", \"distance_z\": 2.45, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
67+
" {\"chemical_element\": \"Sn\", \"distance_z\": 2.82, \"position_on_surface\": TOP_SITE_COORDINATE},\n",
68+
" # {\"chemical_element\": \"Ti\", \"distance_z\": 1.80, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
69+
" # {\"chemical_element\": \"Fe\", \"distance_z\": 1.53, \"position_on_surface\": HOLLOW_SITE_COORDINATE},\n",
70+
" {\"chemical_element\": \"Pd\", \"distance_z\": 2.21, \"position_on_surface\": BRIDGE_SITE_COORDINATE},\n",
71+
" # {\"chemical_element\": \"Au\", \"distance_z\": 2.69, \"position_on_surface\": TOP_SITE_COORDINATE},\n",
72+
"]"
73+
],
74+
"metadata": {
75+
"collapsed": false
76+
},
77+
"id": "b5459bac655071be",
78+
"execution_count": null
79+
},
80+
{
81+
"cell_type": "markdown",
82+
"source": [
83+
"### 1.2. Install Packages\n",
84+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
85+
],
86+
"metadata": {
87+
"collapsed": false
88+
},
89+
"id": "d572e8697122fef5"
90+
},
91+
{
92+
"cell_type": "code",
93+
"outputs": [],
94+
"source": [
95+
"import sys\n",
96+
"\n",
97+
"if sys.platform == \"emscripten\":\n",
98+
" import micropip\n",
99+
"\n",
100+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
101+
" from utils.jupyterlite import install_packages\n",
102+
"\n",
103+
" await install_packages(\"create_point_defect.ipynb\", \"../../../config.yml\")"
104+
],
105+
"metadata": {
106+
"collapsed": false
107+
},
108+
"id": "58b0da5bbc87efc6",
109+
"execution_count": null
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"source": [
114+
"### 1.3. Load input material"
115+
],
116+
"metadata": {
117+
"collapsed": false
118+
},
119+
"id": "b342c025f3e369d4"
120+
},
121+
{
122+
"cell_type": "code",
123+
"outputs": [],
124+
"source": [
125+
"from mat3ra.standata.materials import Materials\n",
126+
"from mat3ra.made.material import Material\n",
127+
"\n",
128+
"material = Material(Materials.get_by_name_first_match(MATERIAL_NAME))"
129+
],
130+
"metadata": {
131+
"collapsed": false
132+
},
133+
"id": "7ebdb82cd32c735c",
134+
"execution_count": null
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"source": [
139+
"### 1.4. Create and preview Supercell"
140+
],
141+
"metadata": {
142+
"collapsed": false
143+
},
144+
"id": "8f459296488702b1"
145+
},
146+
{
147+
"cell_type": "code",
148+
"outputs": [],
149+
"source": [
150+
"from utils.visualize import visualize_materials as visualize\n",
151+
"from mat3ra.made.tools.build.supercell import create_supercell\n",
152+
"\n",
153+
"supercell = create_supercell(material, supercell_matrix=SUPERCELL_MATRIX)\n",
154+
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")"
155+
],
156+
"metadata": {
157+
"collapsed": false
158+
},
159+
"id": "926503f431d18cad",
160+
"execution_count": null
161+
},
162+
{
163+
"cell_type": "markdown",
164+
"source": [
165+
"## 2. Create the Defect\n",
166+
"### 2.1. Initialize Configuration and Builder parameters"
167+
],
168+
"metadata": {
169+
"collapsed": false
170+
},
171+
"id": "2de6554d42e97c9d"
172+
},
173+
{
174+
"cell_type": "code",
175+
"outputs": [],
176+
"source": [
177+
"from mat3ra.made.tools.build.defect import AdatomSlabPointDefectConfiguration\n",
178+
"from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n",
179+
"\n",
180+
"configurations = [AdatomSlabPointDefectConfiguration(crystal=supercell,\n",
181+
" defect_type=DEFECT_TYPE,\n",
182+
" placement_method=PLACEMENT_METHOD,\n",
183+
" chemical_element=adatom_parameters[\"chemical_element\"],\n",
184+
" distance_z=adatom_parameters[\"distance_z\"],\n",
185+
" position_on_surface=adatom_parameters[\"position_on_surface\"],\n",
186+
" use_cartesian_coordinates=USE_CARTESIAN_COORDINATES\n",
187+
" ) for adatom_parameters in ADATOM_PARAMETERS]\n",
188+
"\n",
189+
"defect_builder_parameters = PointDefectBuilderParameters()"
190+
],
191+
"metadata": {
192+
"collapsed": false
193+
},
194+
"id": "74bee7e5ba62200a",
195+
"execution_count": null
196+
},
197+
{
198+
"cell_type": "markdown",
199+
"source": [
200+
"### 2.2. Create the defects"
201+
],
202+
"metadata": {
203+
"collapsed": false
204+
},
205+
"id": "a0f09aafb5d9f4d1"
206+
},
207+
{
208+
"cell_type": "code",
209+
"outputs": [],
210+
"source": [
211+
"from mat3ra.made.tools.build.defect import create_slab_defect\n",
212+
"\n",
213+
"materials_with_adatom = [create_slab_defect(config) for config in configurations]"
214+
],
215+
"metadata": {
216+
"collapsed": false
217+
},
218+
"id": "6fc8ad13e12845f",
219+
"execution_count": null
220+
},
221+
{
222+
"cell_type": "markdown",
223+
"source": [
224+
"## 3. Visualize Result(s)"
225+
],
226+
"metadata": {
227+
"collapsed": false
228+
},
229+
"id": "5ebf2d6bb1a82b9a"
230+
},
231+
{
232+
"cell_type": "code",
233+
"outputs": [],
234+
"source": [
235+
"from utils.visualize import visualize_materials as visualize\n",
236+
"\n",
237+
"for material_with_defect in materials_with_adatom:\n",
238+
" title = f\"{material_with_defect.metadata['build']['configuration']['chemical_element']} adatom\"\n",
239+
" visualize([{\"material\": material_with_defect, \"title\": title}, {\"material\": material_with_defect, \"title\":title, \"rotation\": \"-90x\"}])"
240+
],
241+
"metadata": {
242+
"collapsed": false
243+
},
244+
"id": "93a18e3e1d6e3e6e",
245+
"execution_count": null
246+
},
247+
{
248+
"cell_type": "markdown",
249+
"source": [
250+
"## 4. Download the Results"
251+
],
252+
"metadata": {
253+
"collapsed": false
254+
},
255+
"id": "61176790d8d979e0"
256+
},
257+
{
258+
"cell_type": "code",
259+
"outputs": [],
260+
"source": [
261+
"from utils.jupyterlite import download_content_to_file\n",
262+
"\n",
263+
"for material_with_defect in materials_with_adatom:\n",
264+
" download_content_to_file(material_with_defect.to_json(), f\"{material_with_defect.metadata['build']['configuration']['chemical_element']}_adatom.json\")"
265+
],
266+
"metadata": {
267+
"collapsed": false
268+
},
269+
"id": "20ab1b4be207428c",
270+
"execution_count": null
271+
}
272+
],
273+
"metadata": {
274+
"kernelspec": {
275+
"display_name": "Python 3",
276+
"language": "python",
277+
"name": "python3"
278+
},
279+
"language_info": {
280+
"codemirror_mode": {
281+
"name": "ipython",
282+
"version": 2
283+
},
284+
"file_extension": ".py",
285+
"mimetype": "text/x-python",
286+
"name": "python",
287+
"nbconvert_exporter": "python",
288+
"pygments_lexer": "ipython2",
289+
"version": "2.7.6"
290+
}
291+
},
292+
"nbformat": 4,
293+
"nbformat_minor": 5
294+
}

0 commit comments

Comments
 (0)