Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
16 changes: 6 additions & 10 deletions other/materials_designer/create_adatom_defect.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
{
"cell_type": "markdown",
"source": [
"### 1.3. Get input material and \n",
"Materials are loaded with `get_data()`. The first material is assigned as substrate and the second as film."
"### 1.3. Get input material\n",
"Materials are loaded with `get_materials()`."
],
"metadata": {
"collapsed": false
Expand All @@ -107,12 +107,8 @@
"cell_type": "code",
"outputs": [],
"source": [
"from mat3ra.made.material import Material\n",
"from utils.jupyterlite import get_data\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"materials = list(map(Material, globals()[\"materials_in\"]))"
"from utils.jupyterlite import get_materials\n",
"materials = get_materials(globals())"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -258,9 +254,9 @@
"cell_type": "code",
"outputs": [],
"source": [
"from utils.jupyterlite import set_data\n",
"from utils.jupyterlite import set_materials\n",
"\n",
"set_data(\"materials\", [slab_with_adatom_at_equidistant_position.to_json(), slab_with_adatom_at_crystal_site.to_json()])"
"set_materials([slab_with_adatom_at_equidistant_position, slab_with_adatom_at_crystal_site])"
],
"metadata": {
"collapsed": false
Expand Down
72 changes: 45 additions & 27 deletions other/materials_designer/create_interface_with_min_strain_zsl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,27 @@
"source": [
Copy link
Member

@timurbazhirov timurbazhirov Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #4.    FILM_INDEX = 1

FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

@timurbazhirov timurbazhirov Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #8.        print("Please select a film material. Film is set to substrate.")

Film material not found. Re-using substrate material as film.


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

"# Enable interactive selection of terminations via UI prompt\n",
"IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n",
"\n",
"FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n",
"FILM_MILLER_INDICES = (0, 0, 1)\n",
"FILM_THICKNESS = 1 # in atomic layers\n",
"FILM_VACUUM = 0.0 # in angstroms\n",
"FILM_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
"FILM_USE_ORTHOGONAL_Z = True\n",
"\n",
"SUBSTRATE_INDEX = 0\n",
"SUBSTRATE_MILLER_INDICES = (1, 1, 1)\n",
"SUBSTRATE_THICKNESS = 3 # in atomic layers\n",
"SUBSTRATE_VACUUM = 3.0 # in angstroms\n",
"SUBSTRATE_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
"SUBSTRATE_USE_ORTHOGONAL_Z = True\n",
"\n",
"# Maximum area for the superlattice search algorithm\n",
"MAX_AREA = 50"
"MAX_AREA = 50 # in Angstrom^2\n",
"# Set the termination pair indices\n",
"TERMINATION_PAIR_INDEX = 0 # Will be overridden in interactive selection is used\n",
"INTERFACE_DISTANCE = 3.0 # in Angstrom\n",
"INTERFACE_VACUUM = 20.0 # in Angstrom"
],
"metadata": {
"collapsed": false
Expand All @@ -76,6 +95,7 @@
"\n",
"if sys.platform == \"emscripten\":\n",
" import micropip\n",
" \n",
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
" await install_packages(\"create_interface_with_min_strain_zsl.ipynb\", \"../../config.yml\")"
Expand All @@ -97,14 +117,15 @@
"cell_type": "code",
"outputs": [],
"source": [
"from mat3ra.made.material import Material\n",
"from utils.jupyterlite import get_data\n",
"from utils.jupyterlite import get_materials\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"materials = list(map(Material, globals()[\"materials_in\"]))\n",
"substrate = materials[0]\n",
"film = materials[1]"
"materials = get_materials(globals())\n",
"substrate = materials[SUBSTRATE_INDEX]\n",
"try: \n",
" film = materials[FILM_INDEX]\n",
"except IndexError:\n",
" print(\"Film material not found. Re-using substrate material as film.\")\n",
" film = substrate"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -151,20 +172,20 @@
"\n",
"film_slab_configuration = SlabConfiguration(\n",
" bulk=film,\n",
" miller_indices=(0, 0, 1),\n",
" thickness=1, # in atomic layers\n",
" vacuum=0, # in atomic layers\n",
" xy_supercell_matrix=[[1, 0], [0, 1]],\n",
" use_orthogonal_z=True\n",
" miller_indices=FILM_MILLER_INDICES,\n",
" thickness=FILM_THICKNESS, # in atomic layers\n",
" vacuum=FILM_VACUUM, # in angstroms\n",
" xy_supercell_matrix=FILM_XY_SUPERCELL_MATRIX,\n",
" use_orthogonal_z=FILM_USE_ORTHOGONAL_Z\n",
")\n",
"\n",
"substrate_slab_configuration = SlabConfiguration(\n",
" bulk=substrate,\n",
" miller_indices=(1,1,1),\n",
" thickness=3, # in atomic layers\n",
" vacuum=3, # in atomic layers\n",
" xy_supercell_matrix=[[1, 0], [0, 1]],\n",
" use_orthogonal_z=True\n",
" miller_indices=SUBSTRATE_MILLER_INDICES,\n",
" thickness=SUBSTRATE_THICKNESS, # in atomic layers\n",
" vacuum=SUBSTRATE_VACUUM, # in angstroms\n",
" xy_supercell_matrix=SUBSTRATE_XY_SUPERCELL_MATRIX,\n",
" use_orthogonal_z=SUBSTRATE_USE_ORTHOGONAL_Z\n",
")"
],
"metadata": {},
Expand Down Expand Up @@ -255,10 +276,9 @@
"source": [
"from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n",
"\n",
"# Set the termination pair indices\n",
"TERMINATION_PAIR_INDEX = 0\n",
"termination_pair_index = TERMINATION_PAIR_INDEX\n",
"\n",
"termination_pair = termination_pairs[TERMINATION_PAIR_INDEX]\n",
"termination_pair = termination_pairs[termination_pair_index]\n",
"if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n",
" if sys.platform == \"emscripten\":\n",
" termination_pair = await ui_prompt_select_array_element_by_index_pyodide(termination_pairs, element_name=\"film/substrate termination pair\")\n",
Expand Down Expand Up @@ -293,8 +313,8 @@
" substrate_configuration=substrate_slab_configuration,\n",
" film_termination=film_termination,\n",
" substrate_termination=substrate_termination,\n",
" distance=3.0, # in Angstrom\n",
" vacuum=20.0 # in Angstrom\n",
" distance=INTERFACE_DISTANCE,\n",
" vacuum= INTERFACE_VACUUM\n",
")"
],
"metadata": {
Expand Down Expand Up @@ -437,10 +457,8 @@
"metadata": {},
"outputs": [],
"source": [
"from utils.jupyterlite import set_data\n",
"\n",
"materials_as_json = [selected_interface.to_json() for selected_interface in selected_interfaces]\n",
"set_data(\"materials\", materials_as_json)"
"from utils.jupyterlite import set_materials\n",
"set_materials(selected_interfaces)"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@
"# Enable interactive selection of terminations via UI prompt\n",
Copy link
Member

@timurbazhirov timurbazhirov Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #21.    TERMINATION_PAIR_INDEX = 0

TERMINATION_PAIR_INDEX # Will be overriden in interactive selection is used


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

"IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n",
"# Enable scaling of the film slab atomic coordinates to match the substrate lattice (preserve coordinates in crystal units).\n",
"ENABLE_FILM_SCALING = True"
"ENABLE_FILM_SCALING = True\n",
"\n",
"FILM_INDEX = 1\n",
"FILM_MILLER_INDICES = (0, 0, 1)\n",
"FILM_THICKNESS = 1 # in atomic layers\n",
"FILM_VACUUM = 0.0 # in angstroms\n",
"FILM_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
"FILM_USE_ORTHOGONAL_Z = True\n",
"\n",
"SUBSTRATE_INDEX = 0\n",
"SUBSTRATE_MILLER_INDICES = (1, 1, 1)\n",
"SUBSTRATE_THICKNESS = 3 # in atomic layers\n",
"SUBSTRATE_VACUUM = 3.0 # in angstroms\n",
"SUBSTRATE_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
"SUBSTRATE_USE_ORTHOGONAL_Z = True\n",
"\n",
"# Set the termination pair indices\n",
"TERMINATION_PAIR_INDEX = 0 # Will be overridden in interactive selection is used\n",
"INTERFACE_DISTANCE = 3.0 # in Angstrom\n",
"INTERFACE_VACUUM = 20.0 # in Angstrom"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -92,14 +111,15 @@
"cell_type": "code",
"outputs": [],
"source": [
"from mat3ra.made.material import Material\n",
"from utils.jupyterlite import get_data\n",
"from utils.jupyterlite import get_materials\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"materials = list(map(Material, globals()[\"materials_in\"]))\n",
"substrate = materials[0]\n",
"film = materials[1]"
"materials = get_materials(globals())\n",
"substrate = materials[SUBSTRATE_INDEX]\n",
"try: \n",
" film = materials[FILM_INDEX]\n",
"except IndexError:\n",
" print(\"Please select a film material. Film is set to substrate.\")\n",
" film = substrate"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -148,20 +168,20 @@
"\n",
"film_slab_configuration = SlabConfiguration(\n",
" bulk=film,\n",
" miller_indices=(0, 0, 1),\n",
" thickness=1, # in atomic layers\n",
" vacuum=0, # in atomic layers\n",
" xy_supercell_matrix=[[1, 0], [0, 1]],\n",
" use_orthogonal_z=True\n",
" miller_indices=FILM_MILLER_INDICES,\n",
" thickness=FILM_THICKNESS, # in atomic layers\n",
" vacuum=FILM_VACUUM, # in angstroms\n",
" xy_supercell_matrix=FILM_XY_SUPERCELL_MATRIX,\n",
" use_orthogonal_z=FILM_USE_ORTHOGONAL_Z\n",
")\n",
"\n",
"substrate_slab_configuration = SlabConfiguration(\n",
" bulk=substrate,\n",
" miller_indices=(1,1,1),\n",
" thickness=3, # in atomic layers\n",
" vacuum=3, # in atomic layers\n",
" xy_supercell_matrix=[[1, 0], [0, 1]],\n",
" use_orthogonal_z=True\n",
" miller_indices=SUBSTRATE_MILLER_INDICES,\n",
" thickness=SUBSTRATE_THICKNESS, # in atomic layers\n",
" vacuum=SUBSTRATE_VACUUM, # in angstroms\n",
" xy_supercell_matrix=SUBSTRATE_XY_SUPERCELL_MATRIX,\n",
" use_orthogonal_z=SUBSTRATE_USE_ORTHOGONAL_Z\n",
")"
],
"metadata": {
Expand Down Expand Up @@ -206,8 +226,8 @@
"film_slabs = [create_slab(film_slab_configuration, termination) for termination in film_slab_terminations]\n",
"substrate_slabs = [create_slab(substrate_slab_configuration, termination) for termination in substrate_slab_terminations]\n",
"\n",
"visualize([{\"material\":slab, \"title\": slab.metadata[\"termination\"]} for slab in film_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")\n",
"visualize([{\"material\":slab, \"title\": slab.metadata[\"termination\"]} for slab in substrate_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\") "
"visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in film_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")\n",
"visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\") "
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -255,10 +275,9 @@
"source": [
"from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n",
"\n",
"# Set the termination pair indices\n",
"TERMINATION_PAIR_INDEX = 0\n",
"termination_pair_index = TERMINATION_PAIR_INDEX\n",
"\n",
"termination_pair = termination_pairs[TERMINATION_PAIR_INDEX]\n",
"termination_pair = termination_pairs[termination_pair_index]\n",
"if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n",
" if sys.platform == \"emscripten\":\n",
" termination_pair = await ui_prompt_select_array_element_by_index_pyodide(termination_pairs, element_name=\"film/substrate termination pair\")\n",
Expand Down Expand Up @@ -293,6 +312,8 @@
" substrate_configuration=substrate_slab_configuration,\n",
" film_termination=film_termination,\n",
" substrate_termination=substrate_termination,\n",
" interface_distance=INTERFACE_DISTANCE, # in Angstrom\n",
" interface_vacuum=INTERFACE_VACUUM # in Angstrom\n",
")\n",
"\n",
"interface = create_interface(interface_configuration)"
Expand Down Expand Up @@ -355,9 +376,8 @@
"metadata": {},
"outputs": [],
"source": [
"from utils.jupyterlite import set_data\n",
"\n",
"set_data(\"materials\", [interface.to_json()])"
"from utils.jupyterlite import set_materials\n",
"set_materials(interface)"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@
"metadata": {},
"outputs": [],
"source": [
"from mat3ra.made.material import Material\n",
"from utils.jupyterlite import get_data\n",
"from utils.jupyterlite import get_materials\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"materials = list(map(Material, globals()[\"materials_in\"]))\n",
"interface = materials[2]"
"materials = get_materials(globals())\n",
"interface = materials[0]"
]
},
{
Expand Down Expand Up @@ -165,6 +162,7 @@
"source": [
"from utils.plot import create_realtime_plot, plot_update_callback\n",
"from mat3ra.made.tools.convert import from_ase\n",
"from mat3ra.made.material import Material\n",
"\n",
"# Add calculator to the interface for relaxation\n",
"ase_interface = to_ase(interface)\n",
Expand Down Expand Up @@ -243,9 +241,9 @@
"cell_type": "code",
"outputs": [],
"source": [
"from utils.jupyterlite import set_data\n",
"from utils.jupyterlite import set_materials\n",
"final_interface.name = f\"{interface.name}, Relaxed with EMT\" if \"Relaxed\" not in interface.name else interface.name\n",
"set_data(\"materials\", [final_interface.to_json()])"
"set_materials(final_interface)"
],
"metadata": {
"collapsed": false
Expand Down
17 changes: 6 additions & 11 deletions other/materials_designer/create_nanoribbon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"cell_type": "markdown",
"source": [
"### 1.3. Get input materials\n",
"Materials are loaded with `get_data()`. The first material is assigned as substrate and the second as film."
"Materials are loaded with `get_materials()`."
],
"metadata": {
"collapsed": false
Expand All @@ -100,12 +100,8 @@
"cell_type": "code",
"outputs": [],
"source": [
"from mat3ra.made.material import Material\n",
"from utils.jupyterlite import get_data\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"materials = list(map(Material, globals()[\"materials_in\"]))"
"from utils.jupyterlite import get_materials\n",
"materials = get_materials(globals())"
],
"metadata": {
"collapsed": false
Expand All @@ -129,7 +125,7 @@
"source": [
"from utils.visualize import visualize_materials as visualize\n",
"\n",
"material = materials[2]\n",
"material = materials[0]\n",
"visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")"
],
"metadata": {
Expand Down Expand Up @@ -232,9 +228,8 @@
"cell_type": "code",
"outputs": [],
"source": [
"from utils.jupyterlite import set_data\n",
"\n",
"set_data(\"materials\", [nanoribbon.to_json()])"
"from utils.jupyterlite import set_materials\n",
"set_materials(nanoribbon)"
],
"metadata": {
"collapsed": false
Expand Down
Loading