Skip to content

Commit 634c54c

Browse files
authored
Merge pull request #147 from Exabyte-io/update/SOF-7469
update/SOF 7469
2 parents e868226 + 45f532c commit 634c54c

File tree

6 files changed

+558
-816
lines changed

6 files changed

+558
-816
lines changed

other/materials_designer/create_point_defect.ipynb

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@
99
"\n",
1010
"<h2 style=\"color:green\">Usage</h2>\n",
1111
"\n",
12-
"1. Make sure to select Input Materials (in the outer runtime) before running the notebook.\n",
13-
"1. Set notebook parameters in cell 1.1. below (or use the default values).\n",
14-
"1. Set defects parameters in cell 2.1. (or use default).\n",
12+
"1. Make sure to select Input Materials (in the outer runtime) before running the notebook. \n",
13+
"1. Set notebook parameters in cell 1.1. below (or use the default values) -- to create multiple defects, fill `DEFECT_CONFIGS` with a list of dictionaries. \n",
1514
"1. Click “Run” > “Run All” to run all cells. \n",
16-
"1. Wait for the run to complete (depending on the parameters can take a few min). \n",
1715
"1. Scroll down to view results. \n",
1816
"\n",
19-
"## Summary\n",
20-
"1. Prepare the Environment: Set up the notebook and install packages, preview the input materials\n",
21-
"1. Create the Defect: Add a vacancy defect to the bulk structure\n",
22-
"2. Visualize the Defect: Visualize the defect structure\n",
23-
"\n",
2417
"## Notes\n",
2518
"\n",
2619
"1. For more information, see [Introduction](Introduction.ipynb)\n",
@@ -35,7 +28,8 @@
3528
"cell_type": "markdown",
3629
"source": [
3730
"## 1. Prepare the Environment\n",
38-
"### 1.1. Set up defect parameters "
31+
"### 1.1. Set up defects parameters \n",
32+
"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)."
3933
],
4034
"metadata": {
4135
"collapsed": false
@@ -47,10 +41,28 @@
4741
"outputs": [],
4842
"source": [
4943
"DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
50-
"SITE_ID = 0 # Site index of the defect\n",
51-
"POSITION = [0, 0.0, 0.0] # Position of the defect in crystal coordinates\n",
52-
"CHEMICAL_ELEMENT = \"Cu\" # Element to be placed at the site (ignored for vacancy)\n",
53-
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]] "
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",
49+
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n",
50+
"\n",
51+
"# List of dictionaries with defect parameters\n",
52+
"DEFECT_CONFIGS = [\n",
53+
" {\n",
54+
" \"defect_type\": DEFECT_TYPE,\n",
55+
" \"approximate_coordinate\": [0.0, 0.0, 0.0],\n",
56+
" \"chemical_element\": \"C\",\n",
57+
" # \"site_id\": 0,\n",
58+
" # \"coordinate\": None,\n",
59+
" },\n",
60+
" # Uncomment the following to create multiple defects\n",
61+
" # {\n",
62+
" # \"defect_type\": \"vacancy\",\n",
63+
" # \"site_id\": 0,\n",
64+
" # },\n",
65+
"]"
5466
],
5567
"metadata": {
5668
"collapsed": false
@@ -77,8 +89,10 @@
7789
"\n",
7890
"if sys.platform == \"emscripten\":\n",
7991
" import micropip\n",
92+
"\n",
8093
" await micropip.install('mat3ra-api-examples', deps=False)\n",
8194
" from utils.jupyterlite import install_packages\n",
95+
"\n",
8296
" await install_packages(\"create_point_defect.ipynb\", \"../../config.yml\")"
8397
],
8498
"metadata": {
@@ -103,6 +117,7 @@
103117
"outputs": [],
104118
"source": [
105119
"from utils.jupyterlite import get_materials\n",
120+
"\n",
106121
"materials = get_materials(globals())"
107122
],
108123
"metadata": {
@@ -142,7 +157,7 @@
142157
"cell_type": "markdown",
143158
"source": [
144159
"## 2. Create the Defect\n",
145-
"### 2.1. Set defect parameters"
160+
"### 2.1. Initialize Configuration and Builder parameters"
146161
],
147162
"metadata": {
148163
"collapsed": false
@@ -156,8 +171,7 @@
156171
"from mat3ra.made.tools.build.defect import PointDefectConfiguration\n",
157172
"from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n",
158173
"\n",
159-
"defect_configuration_with_site_id = PointDefectConfiguration.from_site_id(crystal=supercell, defect_type=DEFECT_TYPE, site_id=SITE_ID, chemical_element=CHEMICAL_ELEMENT)\n",
160-
"defect_configuration_with_position = PointDefectConfiguration(crystal=supercell, defect_type=\"interstitial\", position=POSITION, chemical_element=CHEMICAL_ELEMENT)\n",
174+
"defect_configurations = [PointDefectConfiguration.from_dict(supercell, defect) for defect in DEFECT_CONFIGS]\n",
161175
"\n",
162176
"defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)"
163177
],
@@ -181,10 +195,9 @@
181195
"cell_type": "code",
182196
"outputs": [],
183197
"source": [
184-
"from mat3ra.made.tools.build.defect import create_defect\n",
198+
"from mat3ra.made.tools.build.defect import create_defects\n",
185199
"\n",
186-
"material_with_defect_at_site_id = create_defect(builder_parameters=defect_builder_parameters, configuration=defect_configuration_with_site_id)\n",
187-
"material_with_defect_at_position = create_defect(builder_parameters=defect_builder_parameters, configuration=defect_configuration_with_position)"
200+
"material_with_defect = create_defects(builder_parameters=defect_builder_parameters, configurations=defect_configurations)"
188201
],
189202
"metadata": {
190203
"collapsed": false
@@ -195,7 +208,7 @@
195208
{
196209
"cell_type": "markdown",
197210
"source": [
198-
"## 3. Visualize the Defects"
211+
"## 3. Visualize Result(s)"
199212
],
200213
"metadata": {
201214
"collapsed": false
@@ -209,9 +222,10 @@
209222
"from utils.visualize import visualize_materials as visualize\n",
210223
"\n",
211224
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
212-
" {\"material\": material_with_defect_at_site_id, \"title\": f\"Material with defect at site_id={SITE_ID}\"},\n",
213-
" {\"material\": material_with_defect_at_position, \"title\": f\"Material with defect at position={POSITION}\"}],\n",
214-
" rotation=\"-90x\")"
225+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n",
226+
" rotation=\"-90x\")\n",
227+
"visualize([{\"material\": supercell, \"title\": \"Original material\"},\n",
228+
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])"
215229
],
216230
"metadata": {
217231
"collapsed": false
@@ -235,7 +249,7 @@
235249
"source": [
236250
"from utils.jupyterlite import set_materials\n",
237251
"\n",
238-
"set_materials([material_with_defect_at_site_id, material_with_defect_at_position])"
252+
"set_materials([material_with_defect])"
239253
],
240254
"metadata": {
241255
"collapsed": false

0 commit comments

Comments
 (0)