Skip to content

Commit fa70d51

Browse files
authored
Merge pull request #228 from Exabyte-io/fix/SOF-7635
fix/SOF-7635 cartesian for point defects
2 parents a673f50 + 97f91ed commit fa70d51

File tree

2 files changed

+50
-158
lines changed

2 files changed

+50
-158
lines changed

other/materials_designer/create_point_defect.ipynb

Lines changed: 38 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,37 @@
3939
{
4040
"cell_type": "code",
4141
"source": [
42-
"DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
43-
"SITE_ID = None # Site index of the defect\n",
44-
"COORDINATE = None # Position of the defect in crystal coordinates\n",
45-
"APPROXIMATE_COORDINATE = None # Approximate coordinates of the defect in crystal coordinates\n",
46-
"CHEMICAL_ELEMENT = \"C\" # Element to be placed at the site (ignored for vacancy)\n",
47-
"\n",
42+
"# Selected material will be used as a unit cell to create a supercell first.\n",
4843
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n",
4944
"\n",
5045
"# List of dictionaries with defect parameters\n",
5146
"DEFECT_CONFIGS = [\n",
5247
" {\n",
53-
" \"defect_type\": DEFECT_TYPE,\n",
54-
" \"approximate_coordinate\": [0.0, 0.0, 0.0],\n",
55-
" \"chemical_element\": \"C\",\n",
56-
" # \"site_id\": 0,\n",
57-
" # \"coordinate\": None,\n",
48+
" \"defect_type\": \"substitution\", # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
49+
" \"chemical_element\": \"C\", # Substitution element\n",
50+
" \"approximate_coordinate\": [0.0, 0.0, 0.0], # Approx. coord that will be resolved to the closest site\n",
51+
" \"use_cartesian_coordinates\": True, # Use cartesian or crystal coordinates\n",
5852
" },\n",
59-
" # Uncomment the following to create multiple defects\n",
53+
"\n",
54+
" # Uncomment the next lines to create more defects\n",
6055
" # {\n",
61-
" # \"defect_type\": \"vacancy\",\n",
62-
" # \"site_id\": 0,\n",
56+
" # \"defect_type\": \"vacancy\", # Remove an atom at a specific site\n",
57+
" # \"site_id\": 0, # Index of the atom in the host material\n",
6358
" # },\n",
59+
" # {\n",
60+
" # \"defect_type\": \"interstitial\", # Add an atom at an interstitial site\n",
61+
" # \"coordinate\": [0.25, 0.25, 0.25], # Exact position\n",
62+
" # \"use_cartesian_coordinates\": False, # Use cartesian or crystal coordinates\n",
63+
" # \"chemical_element\": \"N\", # Add interstitial atom\n",
64+
" # }\n",
6465
"]"
6566
],
6667
"metadata": {
67-
"collapsed": false,
68-
"ExecuteTime": {
69-
"end_time": "2025-05-13T22:53:42.339489Z",
70-
"start_time": "2025-05-13T22:53:42.334226Z"
71-
}
68+
"collapsed": false
7269
},
7370
"id": "9d8b1890b34d850a",
7471
"outputs": [],
75-
"execution_count": 1
72+
"execution_count": null
7673
},
7774
{
7875
"cell_type": "markdown",
@@ -100,15 +97,11 @@
10097
" await install_packages(\"create_point_defect.ipynb\")"
10198
],
10299
"metadata": {
103-
"collapsed": false,
104-
"ExecuteTime": {
105-
"end_time": "2025-05-13T22:53:42.360804Z",
106-
"start_time": "2025-05-13T22:53:42.358355Z"
107-
}
100+
"collapsed": false
108101
},
109102
"id": "ef664b14457530fd",
110103
"outputs": [],
111-
"execution_count": 2
104+
"execution_count": null
112105
},
113106
{
114107
"cell_type": "markdown",
@@ -129,28 +122,11 @@
129122
"materials = get_materials(globals())"
130123
],
131124
"metadata": {
132-
"collapsed": false,
133-
"ExecuteTime": {
134-
"end_time": "2025-05-13T22:53:43.047946Z",
135-
"start_time": "2025-05-13T22:53:42.474580Z"
136-
}
125+
"collapsed": false
137126
},
138127
"id": "be38fdda1984c654",
139-
"outputs": [
140-
{
141-
"name": "stdout",
142-
"output_type": "stream",
143-
"text": [
144-
"0: 0-Ni\n",
145-
"1: 1-Graphene\n",
146-
"2: C2(001)-Ni4(111), Interface\n",
147-
"3: Ni4(001), termination Ni_P4:mmm_2, Slab\n",
148-
"4: O8Zr4(011), termination O2_P2:m_1, Slab\n",
149-
"Retrieved 5 materials.\n"
150-
]
151-
}
152-
],
153-
"execution_count": 3
128+
"outputs": [],
129+
"execution_count": null
154130
},
155131
{
156132
"cell_type": "markdown",
@@ -173,30 +149,11 @@
173149
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")"
174150
],
175151
"metadata": {
176-
"collapsed": false,
177-
"ExecuteTime": {
178-
"end_time": "2025-05-13T22:53:45.847490Z",
179-
"start_time": "2025-05-13T22:53:43.138551Z"
180-
}
152+
"collapsed": false
181153
},
182154
"id": "e2d24109d3068c9e",
183-
"outputs": [
184-
{
185-
"data": {
186-
"text/plain": [
187-
"GridBox(children=(VBox(children=(Label(value='Ni27 - Material - rotation: 0x', layout=Layout(align_self='cente…"
188-
],
189-
"application/vnd.jupyter.widget-view+json": {
190-
"version_major": 2,
191-
"version_minor": 0,
192-
"model_id": "cdc432e2a99c46af8bad06e72d376c4a"
193-
}
194-
},
195-
"metadata": {},
196-
"output_type": "display_data"
197-
}
198-
],
199-
"execution_count": 4
155+
"outputs": [],
156+
"execution_count": null
200157
},
201158
{
202159
"cell_type": "markdown",
@@ -220,15 +177,11 @@
220177
"defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)"
221178
],
222179
"metadata": {
223-
"collapsed": false,
224-
"ExecuteTime": {
225-
"end_time": "2025-05-13T22:53:45.909568Z",
226-
"start_time": "2025-05-13T22:53:45.873079Z"
227-
}
180+
"collapsed": false
228181
},
229182
"id": "e385e50ae11ed2b9",
230183
"outputs": [],
231-
"execution_count": 5
184+
"execution_count": null
232185
},
233186
{
234187
"cell_type": "markdown",
@@ -245,33 +198,15 @@
245198
"source": [
246199
"from mat3ra.made.tools.build.defect import create_defects\n",
247200
"\n",
248-
"material_with_defect = create_defects(builder_parameters=defect_builder_parameters, configurations=defect_configurations)"
201+
"material_with_defect = create_defects(builder_parameters=defect_builder_parameters,\n",
202+
" configurations=defect_configurations)"
249203
],
250204
"metadata": {
251-
"collapsed": false,
252-
"ExecuteTime": {
253-
"end_time": "2025-05-13T22:53:45.966908Z",
254-
"start_time": "2025-05-13T22:53:45.916257Z"
255-
}
205+
"collapsed": false
256206
},
257207
"id": "a990fa35742d7269",
258-
"outputs": [
259-
{
260-
"name": "stderr",
261-
"output_type": "stream",
262-
"text": [
263-
"/Users/mat3ra/code/GREEN/api-examples/.venv-3.11.2/lib/python3.11/site-packages/spglib/spglib.py:115: DeprecationWarning: dict interface (SpglibDataset['international']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead\n",
264-
" warnings.warn(\n",
265-
"/Users/mat3ra/code/GREEN/api-examples/.venv-3.11.2/lib/python3.11/site-packages/spglib/spglib.py:115: DeprecationWarning: dict interface (SpglibDataset['number']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead\n",
266-
" warnings.warn(\n",
267-
"/Users/mat3ra/code/GREEN/api-examples/.venv-3.11.2/lib/python3.11/site-packages/spglib/spglib.py:115: DeprecationWarning: dict interface (SpglibDataset['equivalent_atoms']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead\n",
268-
" warnings.warn(\n",
269-
"/Users/mat3ra/code/GREEN/api-examples/.venv-3.11.2/lib/python3.11/site-packages/spglib/spglib.py:115: DeprecationWarning: dict interface (SpglibDataset['wyckoffs']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead\n",
270-
" warnings.warn(\n"
271-
]
272-
}
273-
],
274-
"execution_count": 6
208+
"outputs": [],
209+
"execution_count": null
275210
},
276211
{
277212
"cell_type": "markdown",
@@ -295,44 +230,11 @@
295230
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])"
296231
],
297232
"metadata": {
298-
"collapsed": false,
299-
"ExecuteTime": {
300-
"end_time": "2025-05-13T22:53:46.124855Z",
301-
"start_time": "2025-05-13T22:53:45.980978Z"
302-
}
233+
"collapsed": false
303234
},
304235
"id": "509b18661a069e42",
305-
"outputs": [
306-
{
307-
"data": {
308-
"text/plain": [
309-
"GridBox(children=(VBox(children=(Label(value='Ni27 - Original material - rotation: -90x', layout=Layout(align_…"
310-
],
311-
"application/vnd.jupyter.widget-view+json": {
312-
"version_major": 2,
313-
"version_minor": 0,
314-
"model_id": "a8f71c9f02b54a9ab51c4e9e969e56a3"
315-
}
316-
},
317-
"metadata": {},
318-
"output_type": "display_data"
319-
},
320-
{
321-
"data": {
322-
"text/plain": [
323-
"GridBox(children=(VBox(children=(Label(value='Ni27 - Original material - rotation: 0x,0y,0z', layout=Layout(al…"
324-
],
325-
"application/vnd.jupyter.widget-view+json": {
326-
"version_major": 2,
327-
"version_minor": 0,
328-
"model_id": "3cd37b2b7bd646dd8922e0970a5bfe39"
329-
}
330-
},
331-
"metadata": {},
332-
"output_type": "display_data"
333-
}
334-
],
335-
"execution_count": 7
236+
"outputs": [],
237+
"execution_count": null
336238
},
337239
{
338240
"cell_type": "markdown",
@@ -352,23 +254,11 @@
352254
"set_materials([material_with_defect])"
353255
],
354256
"metadata": {
355-
"collapsed": false,
356-
"ExecuteTime": {
357-
"end_time": "2025-05-13T22:53:46.138694Z",
358-
"start_time": "2025-05-13T22:53:46.134037Z"
359-
}
257+
"collapsed": false
360258
},
361259
"id": "61daa5afcbc078a9",
362-
"outputs": [
363-
{
364-
"name": "stdout",
365-
"output_type": "stream",
366-
"text": [
367-
"Data for materials written to uploads/Ni26 C1, Substitution C Defect.json\n"
368-
]
369-
}
370-
],
371-
"execution_count": 8
260+
"outputs": [],
261+
"execution_count": null
372262
}
373263
],
374264
"metadata": {

0 commit comments

Comments
 (0)