-
Notifications
You must be signed in to change notification settings - Fork 4
SOF-7599 update: use new made for slab generation #227
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
Open
VsevolodX
wants to merge
1
commit into
dev
Choose a base branch
from
feature/SOF-7599-final-1
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,12 @@ | |
"cell_type": "code", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line #2. print("Available terminations:", [str(t) for t in terminations]) The numbering needs to be fixed, the logic should be:
2. Find possible terminations and select one
3. Create a slab for the selected termination Reply via ReviewNB |
||
"source": [ | ||
"# Enable interactive selection of terminations via UI prompt\n", | ||
"IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", | ||
"IS_TERMINATIONS_SELECTION_INTERACTIVE = False\n", | ||
"\n", | ||
"MILLER_INDICES = (0, 0, 1)\n", | ||
"MILLER_INDICES = (0, 1, 1)\n", | ||
"THICKNESS = 3 # in atomic layers\n", | ||
"VACUUM = 10.0 # in angstroms\n", | ||
"XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", | ||
"XY_SUPERCELL_MATRIX = [[2, 0], [0, 2]]\n", | ||
"USE_ORTHOGONAL_Z = True\n", | ||
"USE_CONVENTIONAL_CELL = True\n", | ||
"\n", | ||
|
@@ -79,10 +79,11 @@ | |
"\n", | ||
"if sys.platform == \"emscripten\":\n", | ||
" import micropip\n", | ||
" \n", | ||
"\n", | ||
" await micropip.install('mat3ra-api-examples', deps=False)\n", | ||
" await micropip.install('mat3ra-utils')\n", | ||
" from mat3ra.utils.jupyterlite.packages import install_packages\n", | ||
"\n", | ||
" await install_packages(\"\")" | ||
], | ||
"metadata": { | ||
|
@@ -108,6 +109,7 @@ | |
"from utils.jupyterlite import get_materials\n", | ||
"\n", | ||
"materials = get_materials(globals())\n", | ||
"print(globals()[\"materials_in\"][0])\n", | ||
"material = materials[0]" | ||
], | ||
"metadata": { | ||
|
@@ -131,6 +133,7 @@ | |
"cell_type": "code", | ||
"source": [ | ||
"from utils.visualize import visualize_materials as visualize\n", | ||
"\n", | ||
"visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")\n", | ||
"visualize(material, repetitions=[3, 3, 1], rotation=\"-90x\")" | ||
], | ||
|
@@ -155,47 +158,35 @@ | |
"id": "6634dae92a6c07b9" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import SlabConfiguration\n", | ||
"from mat3ra.made.tools.build.slab.configuration import CrystalLatticePlanes\n", | ||
"\n", | ||
"slab_configuration = SlabConfiguration(\n", | ||
" bulk=material,\n", | ||
"crystal_lattice_planes = CrystalLatticePlanes(\n", | ||
" crystal=material,\n", | ||
" miller_indices=MILLER_INDICES,\n", | ||
" number_of_layers=THICKNESS, # in atomic layers\n", | ||
" vacuum=VACUUM, # in angstroms\n", | ||
" xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", | ||
" use_orthogonal_z=USE_ORTHOGONAL_Z,\n", | ||
" use_conventional_cell=USE_CONVENTIONAL_CELL,\n", | ||
" use_conventional_cell=USE_CONVENTIONAL_CELL\n", | ||
")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "3ad6765249610aa4", | ||
"id": "ec30720293c64ecc", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.2. Get possible terminations for the slabs" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "afb4c9bb89c8690b" | ||
"source": "## 2.1. Get terminations", | ||
"id": "eb3aeb119d8726ba" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import get_terminations\n", | ||
"slab_terminations = get_terminations(slab_configuration)" | ||
"terminations = crystal_lattice_planes.get_terminations()\n", | ||
"print(\"Available terminations:\", [str(t) for t in terminations])" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "70bec9d69d58b28a", | ||
"id": "68bb05623903b05c", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
|
@@ -212,11 +203,12 @@ | |
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import create_slab\n", | ||
"\n", | ||
"slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n", | ||
"\n", | ||
"visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")" | ||
"# from mat3ra.made.tools.build.slab import create_slab\n", | ||
"#\n", | ||
"# slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n", | ||
"#\n", | ||
"# visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs], repetitions=[3, 3, 1],\n", | ||
"# rotation=\"-90x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
|
@@ -239,7 +231,7 @@ | |
"cell_type": "code", | ||
"source": [ | ||
"print(\"Terminations\")\n", | ||
"for idx, termination in enumerate(slab_terminations):\n", | ||
"for idx, termination in enumerate(terminations):\n", | ||
" print(f\" {idx}: {termination}\")" | ||
], | ||
"metadata": { | ||
|
@@ -266,12 +258,13 @@ | |
"\n", | ||
"termination_index = TERMINATION_INDEX\n", | ||
"\n", | ||
"termination = slab_terminations[termination_index]\n", | ||
"termination = terminations[termination_index]\n", | ||
"if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", | ||
" if sys.platform == \"emscripten\":\n", | ||
" termination = await ui_prompt_select_array_element_by_index_pyodide(slab_terminations, element_name=\"termination\")\n", | ||
" termination = await ui_prompt_select_array_element_by_index_pyodide(terminations,\n", | ||
" element_name=\"termination\")\n", | ||
" else:\n", | ||
" termination = ui_prompt_select_array_element_by_index(slab_terminations, element_name=\"termination\")" | ||
" termination = ui_prompt_select_array_element_by_index(terminations, element_name=\"termination\")\n" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
|
@@ -282,20 +275,84 @@ | |
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": "## 3. Create Atomic Layers", | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "143bc82b430b37d5" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"## 3. Create the slab with selected termination" | ||
"from mat3ra.made.tools.build.slab.configuration import AtomicLayersUniqueRepeated\n", | ||
"\n", | ||
"top_termination = termination\n", | ||
"# TODO: should use `from_parameters`\n", | ||
"atomic_layers = AtomicLayersUniqueRepeated(\n", | ||
" crystal=material,\n", | ||
" miller_indices=MILLER_INDICES,\n", | ||
" use_conventional_cell=True,\n", | ||
" number_of_repetitions=THICKNESS,\n", | ||
" termination_top=top_termination,\n", | ||
")" | ||
], | ||
"id": "f08dc6f4372930e4", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": "### 3.1. Specify vacuum", | ||
"id": "c483e6aae37766b1" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab.configuration import VacuumConfiguration, AxisEnum\n", | ||
"\n", | ||
"vacuum = VacuumConfiguration(direction=AxisEnum.z, size=VACUUM, is_orthogonal=True)" | ||
], | ||
"id": "ca440d1dad2061da", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": "### 3.2. Create slab configuration", | ||
"id": "41066bf389dfd216" | ||
}, | ||
{ | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "143bc82b430b37d5" | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import SlabConfiguration\n", | ||
"\n", | ||
"slab_configuration = SlabConfiguration(\n", | ||
" supercell_xy=XY_SUPERCELL_MATRIX, stack_components=[atomic_layers, vacuum], direction=AxisEnum.z\n", | ||
")" | ||
], | ||
"id": "ee1be3faa5341c70", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": "### 3.3. Create slab", | ||
"id": "7869f1b09ecd62c6" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import create_slab\n", | ||
"\n", | ||
"slab = create_slab(slab_configuration, termination)" | ||
"slab = create_slab(slab_configuration)" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
|
@@ -316,9 +373,7 @@ | |
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\")" | ||
], | ||
"source": "visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\", viewer=\"wave\")", | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
|
@@ -340,6 +395,7 @@ | |
"cell_type": "code", | ||
"source": [ | ||
"from utils.jupyterlite import set_materials\n", | ||
"\n", | ||
"set_materials(slab)" | ||
], | ||
"metadata": { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use
get_slabs
fromcrystal_lattice_planes
Reply via ReviewNB