Skip to content

fix/SOF-7635 cartesian for point defects #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 38 additions & 148 deletions other/materials_designer/create_point_defect.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,40 +39,37 @@
{
"cell_type": "code",
"source": [
"DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
"SITE_ID = None # Site index of the defect\n",
"COORDINATE = None # Position of the defect in crystal coordinates\n",
"APPROXIMATE_COORDINATE = None # Approximate coordinates of the defect in crystal coordinates\n",
"CHEMICAL_ELEMENT = \"C\" # Element to be placed at the site (ignored for vacancy)\n",
"\n",
"# Selected material will be used as a unit cell to create a supercell first.\n",
"SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n",
"\n",
"# List of dictionaries with defect parameters\n",
"DEFECT_CONFIGS = [\n",
" {\n",
" \"defect_type\": DEFECT_TYPE,\n",
" \"approximate_coordinate\": [0.0, 0.0, 0.0],\n",
" \"chemical_element\": \"C\",\n",
" # \"site_id\": 0,\n",
" # \"coordinate\": None,\n",
" \"defect_type\": \"substitution\", # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n",
" \"chemical_element\": \"C\", # Substitution element\n",
" \"approximate_coordinate\": [0.0, 0.0, 0.0], # Approx. coord that will be resolved to the closest site\n",
" \"use_cartesian_coordinates\": True, # Use cartesian or crystal coordinates\n",
" },\n",
" # Uncomment the following to create multiple defects\n",
"\n",
" # Uncomment the next lines to create more defects\n",
" # {\n",
" # \"defect_type\": \"vacancy\",\n",
" # \"site_id\": 0,\n",
" # \"defect_type\": \"vacancy\", # Remove an atom at a specific site\n",
" # \"site_id\": 0, # Index of the atom in the host material\n",
" # },\n",
" # {\n",
" # \"defect_type\": \"interstitial\", # Add an atom at an interstitial site\n",
" # \"coordinate\": [0.25, 0.25, 0.25], # Exact position\n",
" # \"use_cartesian_coordinates\": False, # Use cartesian or crystal coordinates\n",
" # \"chemical_element\": \"N\", # Add interstitial atom\n",
" # }\n",
"]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:42.339489Z",
"start_time": "2025-05-13T22:53:42.334226Z"
}
"collapsed": false
},
"id": "9d8b1890b34d850a",
"outputs": [],
"execution_count": 1
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -100,15 +97,11 @@
" await install_packages(\"create_point_defect.ipynb\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:42.360804Z",
"start_time": "2025-05-13T22:53:42.358355Z"
}
"collapsed": false
},
"id": "ef664b14457530fd",
"outputs": [],
"execution_count": 2
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -129,28 +122,11 @@
"materials = get_materials(globals())"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:43.047946Z",
"start_time": "2025-05-13T22:53:42.474580Z"
}
"collapsed": false
},
"id": "be38fdda1984c654",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0: 0-Ni\n",
"1: 1-Graphene\n",
"2: C2(001)-Ni4(111), Interface\n",
"3: Ni4(001), termination Ni_P4:mmm_2, Slab\n",
"4: O8Zr4(011), termination O2_P2:m_1, Slab\n",
"Retrieved 5 materials.\n"
]
}
],
"execution_count": 3
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -173,30 +149,11 @@
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:45.847490Z",
"start_time": "2025-05-13T22:53:43.138551Z"
}
"collapsed": false
},
"id": "e2d24109d3068c9e",
"outputs": [
{
"data": {
"text/plain": [
"GridBox(children=(VBox(children=(Label(value='Ni27 - Material - rotation: 0x', layout=Layout(align_self='cente…"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "cdc432e2a99c46af8bad06e72d376c4a"
}
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": 4
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -220,15 +177,11 @@
"defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:45.909568Z",
"start_time": "2025-05-13T22:53:45.873079Z"
}
"collapsed": false
},
"id": "e385e50ae11ed2b9",
"outputs": [],
"execution_count": 5
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -245,33 +198,15 @@
"source": [
"from mat3ra.made.tools.build.defect import create_defects\n",
"\n",
"material_with_defect = create_defects(builder_parameters=defect_builder_parameters, configurations=defect_configurations)"
"material_with_defect = create_defects(builder_parameters=defect_builder_parameters,\n",
" configurations=defect_configurations)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:45.966908Z",
"start_time": "2025-05-13T22:53:45.916257Z"
}
"collapsed": false
},
"id": "a990fa35742d7269",
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/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",
" warnings.warn(\n",
"/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",
" warnings.warn(\n",
"/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",
" warnings.warn(\n",
"/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",
" warnings.warn(\n"
]
}
],
"execution_count": 6
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -295,44 +230,11 @@
" {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:46.124855Z",
"start_time": "2025-05-13T22:53:45.980978Z"
}
"collapsed": false
},
"id": "509b18661a069e42",
"outputs": [
{
"data": {
"text/plain": [
"GridBox(children=(VBox(children=(Label(value='Ni27 - Original material - rotation: -90x', layout=Layout(align_…"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "a8f71c9f02b54a9ab51c4e9e969e56a3"
}
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"GridBox(children=(VBox(children=(Label(value='Ni27 - Original material - rotation: 0x,0y,0z', layout=Layout(al…"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "3cd37b2b7bd646dd8922e0970a5bfe39"
}
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": 7
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -352,23 +254,11 @@
"set_materials([material_with_defect])"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-05-13T22:53:46.138694Z",
"start_time": "2025-05-13T22:53:46.134037Z"
}
"collapsed": false
},
"id": "61daa5afcbc078a9",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data for materials written to uploads/Ni26 C1, Substitution C Defect.json\n"
]
}
],
"execution_count": 8
"outputs": [],
"execution_count": null
}
],
"metadata": {
Expand Down
Loading