Skip to content
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

feature/SOF-7347 update: use interface settings as class + add metadata to interface #124

Merged
merged 21 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
140 changes: 63 additions & 77 deletions other/materials_designer/create_interface_with_min_strain_zsl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"<h2 style=\"color:green\">Usage</h2>\n",
Copy link
Member

Choose a reason for hiding this comment

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

specify whether termination selection is done


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Smth like: Choose the termination selection mode: interactive with prompt or by index in the code ?

Copy link
Member

Choose a reason for hiding this comment

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

Line #5.        distance_z=3.0,                  # distance between two planes, in Angstroms

distance between substrate and layer


Reply via ReviewNB

"\n",
"1. Make sure to select Input Materials\n",
"2. Set Input Parameters (e.g. `MILLER_INDICES`, `THICKNESS`, `MAX_AREA`) below or use the default values\n",
"2. Set Interface Parameters (e.g. `distance_z`, `max_area`, `miller_indices`) below or use the default values\n",
"3. Click \"Run\" > \"Run All Cells\" to run all cells\n",
"4. Wait for the run to complete (depending on the area, it can take 1-2 min or more). Scroll down to view cell results.\n",
"5. Review the strain plot and modify its parameters as needed\n",
Expand All @@ -32,62 +32,40 @@
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Set Input Parameters\n",
"\n",
"### 1.1. Set Substrate and Layer Parameters \n",
"Additionally, specify if the termination selection is done using interactive prompt, or the via selecting the termination index in the code."
]
"## 1. Install Packages\n",
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` as directed in README."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"SUBSTRATE_PARAMETERS = {\n",
" \"MILLER_INDICES\": (1, 1, 1), # the miller indices of the interfacial plane\n",
" \"THICKNESS\": 3, # in layers\n",
"}\n",
"\n",
"LAYER_PARAMETERS = {\n",
" \"MILLER_INDICES\": (0, 0, 1), # the miller indices of the interfacial plane\n",
" \"THICKNESS\": 1, # in layers\n",
"}\n",
"\n",
"USE_CONVENTIONAL_CELL = True # if True, the surface plane is constructed using miller indices of the conventional cell\n",
"import sys\n",
"\n",
"IS_TERMINATION_SELECTION_INTERACTIVE = False # if True, the user can select the termination interactively\n",
"TERMINATION_INDEX = 0 # the default termination index that is used if no termination selected, ignored in interactive mode"
]
"if sys.platform == \"emscripten\":\n",
" import micropip\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\")"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2. Set Interface Parameters\n",
"## 2. Set Interface Parameters\n",
"\n",
"The distance between layer and substrate and maximum area to consider when matching.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"INTERFACE_PARAMETERS = {\n",
" \"DISTANCE_Z\": 3.0, # in Angstroms\n",
" \"MAX_AREA\": 400, # in Angstroms^2\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.3. Set Algorithm Parameters"
"### 2.1. Set Substrate and Layer Parameters \n",
"Imported `InterfaceSettings` is a class that specifies the parameters for the construction of the interface. The default values are assumed if properties are not set during the initialization.\n",
"Additionally, specify if the termination selection is done using interactive prompt, or the via selecting the termination index in the code."
]
},
{
Expand All @@ -96,46 +74,50 @@
"metadata": {},
"outputs": [],
"source": [
"ZSL_PARAMETERS = {\n",
" \"MAX_AREA\": INTERFACE_PARAMETERS[\"MAX_AREA\"], # The area to consider in Angstrom^2\n",
" \"MAX_AREA_TOL\": 0.09, # The area within this tolerance is considered equal\n",
" \"MAX_LENGTH_TOL\": 0.03, # supercell lattice vectors lengths within this tolerance are considered equal\n",
" \"MAX_ANGLE_TOL\": 0.01, # supercell lattice angles within this tolerance are considered equal\n",
" \"STRAIN_TOL\": 10e-6, # strains within this tolerance are considered equal\n",
"}\n",
"from mat3ra.made.tools.build.interface import InterfaceSettings\n",
"\n",
"# Parameters can be set during the class initialization:\n",
"interface_builder_settings = InterfaceSettings(\n",
" distance_z=3.0, # distance between two planes, in Angstroms\n",
" use_conventional_cell=True, # if True, the surface plane is constructed using miller indices of the conventional cell\n",
")\n",
"\n",
"# unify the parameters\n",
"interface_settings = {\n",
" \"SUBSTRATE_PARAMETERS\": SUBSTRATE_PARAMETERS,\n",
" \"LAYER_PARAMETERS\": LAYER_PARAMETERS,\n",
" \"USE_CONVENTIONAL_CELL\": USE_CONVENTIONAL_CELL,\n",
" \"ZSL_PARAMETERS\": ZSL_PARAMETERS,\n",
" \"INTERFACE_PARAMETERS\": INTERFACE_PARAMETERS,\n",
"}"
"# Parameters can be set after the initialization:\n",
"interface_builder_settings.SubstrateParameters.miller_indices = (1, 1, 1) # the Miller indices of the interfacial plane of the substrate\n",
"interface_builder_settings.SubstrateParameters.thickness = 3 # substrate thickness in layers\n",
"interface_builder_settings.LayerParameters.miller_indices = (0, 0, 1) # the Miller indices of the interfacial plane of the layer\n",
"interface_builder_settings.LayerParameters.thickness = 1 # layer thickness in layers\n",
"\n",
"IS_TERMINATION_SELECTION_INTERACTIVE = False # if True, the user can select the termination interactively\n",
"TERMINATION_INDEX = 0 # the default termination index that is used if no termination selected, ignored in interactive mode"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Install Packages\n",
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` as directed in README."
]
"### 2.2. Set Strain Matching Algorithm Parameters (Optional)\n",
"The search algorithm for supercells matching can be tuned by setting its parameters directly, otherwise the default values are used."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"\n",
"if sys.platform == \"emscripten\":\n",
" import micropip\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\")"
]
"from mat3ra.made.tools.build.interface import ZSLParameters\n",
"interface_builder_settings.ZSLParameters = ZSLParameters(\n",
" max_area=50, # maximum area of the generated interfaces, in Angstroms^2\n",
" max_area_tol=0.09, # maximum tolerance on ratio of super-lattices to consider equal\n",
" max_length_tol=0.03, # maximum length tolerance for two vectors to be considered equal\n",
" max_angle_tol=0.01, # maximum angle tolerance for two sets of vectors to have equal angles\n",
")"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -185,7 +167,7 @@
"interface_builder = init_interface_builder(\n",
" substrate=materials[0],\n",
" layer=materials[1],\n",
" settings=interface_settings\n",
" settings=interface_builder_settings\n",
")"
],
"metadata": {
Expand Down Expand Up @@ -239,7 +221,6 @@
"from mat3ra.made.tools.build import create_interfaces\n",
"\n",
"interface_data_holder = create_interfaces(\n",
" settings=interface_settings,\n",
" sort_by_strain_and_size=True,\n",
" remove_duplicates=True,\n",
" interface_builder=interface_builder,\n",
Expand All @@ -254,7 +235,7 @@
{
"cell_type": "markdown",
"source": [
"### 4.3. Print out interface with the lowest strain for selected termination"
"### 4.4. Print out interface with the lowest strain for selected termination"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -359,7 +340,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 6.3. Pass data to the outside runtime"
"### 6.3. Pass data to the outside runtime\n",
"Enrich the selected interfaces names with the strain values and pass them to the application runtime."
]
},
{
Expand All @@ -370,6 +352,10 @@
"source": [
"from utils.jupyterlite import set_data\n",
"\n",
"for interface in selected_interfaces:\n",
" if \"Interface, Strain:\" not in interface[\"name\"]:\n",
" interface[\"name\"] = f'{interface[\"name\"]}, Interface, Strain:{interface[\"metadata\"][\"interface_properties\"][\"mean_abs_strain\"]*100:.3f}%'\n",
"\n",
"set_data(\"materials\", selected_interfaces)"
]
}
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencies = [
"matplotlib>=3.4.1",
"pandas>=1.5.3",
"pymatgen>=2024.4.13",
"mat3ra-made>=2024.5.9.post0",
"mat3ra-utils"
"mat3ra-made>=2024.5.15.post1",
"mat3ra-utils>=2024.5.15.post0"
]

[project.optional-dependencies]
Expand Down