|
39 | 39 | "outputs": [], |
40 | 40 | "source": [ |
41 | 41 | "# Enable interactive selection of terminations via UI prompt\n", |
42 | | - "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", |
| 42 | + "IS_TERMINATIONS_SELECTION_INTERACTIVE = False\n", |
43 | 43 | "\n", |
44 | | - "FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n", |
| 44 | + "FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n", |
45 | 45 | "FILM_MILLER_INDICES = (0, 0, 1)\n", |
46 | 46 | "FILM_THICKNESS = 1 # in atomic layers\n", |
47 | 47 | "FILM_VACUUM = 0.0 # in angstroms\n", |
|
56 | 56 | "SUBSTRATE_USE_ORTHOGONAL_Z = True\n", |
57 | 57 | "\n", |
58 | 58 | "# Maximum area for the superlattice search algorithm\n", |
59 | | - "MAX_AREA = 50 # in Angstrom^2\n", |
| 59 | + "MAX_AREA = 50 # in Angstrom^2\n", |
60 | 60 | "# Set the termination pair indices\n", |
61 | | - "TERMINATION_PAIR_INDEX = 0 # Will be overridden in interactive selection is used\n", |
| 61 | + "TERMINATION_PAIR_INDEX = 0 # Will be overridden in interactive selection is used\n", |
62 | 62 | "INTERFACE_DISTANCE = 3.4 # in Angstrom\n", |
63 | 63 | "INTERFACE_VACUUM = 20.0 # in Angstrom" |
64 | 64 | ], |
|
85 | 85 | "\n", |
86 | 86 | "if sys.platform == \"emscripten\":\n", |
87 | 87 | " import micropip\n", |
88 | | - " \n", |
| 88 | + "\n", |
89 | 89 | " await micropip.install('mat3ra-api-examples', deps=False)\n", |
90 | 90 | " from utils.jupyterlite import install_packages\n", |
| 91 | + "\n", |
91 | 92 | " await install_packages(\"specific_examples|create_interface_with_min_strain_zsl.ipynb\")" |
92 | 93 | ], |
93 | 94 | "metadata": { |
|
109 | 110 | "source": [ |
110 | 111 | "from mat3ra.standata.materials import Materials\n", |
111 | 112 | "from mat3ra.made.material import Material\n", |
| 113 | + "\n", |
112 | 114 | "film = Material(Materials.get_by_name_first_match(\"Graphene\"))\n", |
113 | 115 | "substrate = Material(Materials.get_by_name_and_categories(\"BN\", \"2D\"))" |
114 | 116 | ], |
|
131 | 133 | "outputs": [], |
132 | 134 | "source": [ |
133 | 135 | "from utils.visualize import visualize_materials as visualize\n", |
| 136 | + "\n", |
134 | 137 | "visualize([substrate, film], repetitions=[3, 3, 1], rotation=\"0x\")" |
135 | 138 | ], |
136 | 139 | "metadata": { |
|
158 | 161 | "film_slab_configuration = SlabConfiguration(\n", |
159 | 162 | " bulk=film,\n", |
160 | 163 | " miller_indices=FILM_MILLER_INDICES,\n", |
161 | | - " thickness=FILM_THICKNESS, # in atomic layers\n", |
162 | | - " vacuum=FILM_VACUUM, # in angstroms\n", |
| 164 | + " thickness=FILM_THICKNESS, # in atomic layers\n", |
| 165 | + " vacuum=FILM_VACUUM, # in angstroms\n", |
163 | 166 | " xy_supercell_matrix=FILM_XY_SUPERCELL_MATRIX,\n", |
164 | 167 | " use_orthogonal_z=FILM_USE_ORTHOGONAL_Z\n", |
165 | 168 | ")\n", |
166 | 169 | "\n", |
167 | 170 | "substrate_slab_configuration = SlabConfiguration(\n", |
168 | 171 | " bulk=substrate,\n", |
169 | 172 | " miller_indices=SUBSTRATE_MILLER_INDICES,\n", |
170 | | - " thickness=SUBSTRATE_THICKNESS, # in atomic layers\n", |
171 | | - " vacuum=SUBSTRATE_VACUUM, # in angstroms\n", |
| 173 | + " thickness=SUBSTRATE_THICKNESS, # in atomic layers\n", |
| 174 | + " vacuum=SUBSTRATE_VACUUM, # in angstroms\n", |
172 | 175 | " xy_supercell_matrix=SUBSTRATE_XY_SUPERCELL_MATRIX,\n", |
173 | 176 | " use_orthogonal_z=SUBSTRATE_USE_ORTHOGONAL_Z\n", |
174 | 177 | ")" |
|
211 | 214 | "outputs": [], |
212 | 215 | "source": [ |
213 | 216 | "film_slabs = [create_slab(film_slab_configuration, termination) for termination in film_slab_terminations]\n", |
214 | | - "substrate_slabs = [create_slab(substrate_slab_configuration, termination) for termination in substrate_slab_terminations]\n", |
| 217 | + "substrate_slabs = [create_slab(substrate_slab_configuration, termination) for termination in\n", |
| 218 | + " substrate_slab_terminations]\n", |
215 | 219 | "\n", |
216 | | - "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in film_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")\n", |
217 | | - "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_slabs ], repetitions=[3, 3, 1], rotation=\"-90x\") " |
| 220 | + "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in film_slabs],\n", |
| 221 | + " repetitions=[3, 3, 1], rotation=\"-90x\")\n", |
| 222 | + "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_slabs],\n", |
| 223 | + " repetitions=[3, 3, 1], rotation=\"-90x\")" |
218 | 224 | ], |
219 | 225 | "metadata": { |
220 | 226 | "collapsed": false |
|
236 | 242 | "source": [ |
237 | 243 | "from itertools import product\n", |
238 | 244 | "\n", |
239 | | - "termination_pairs = list(product(film_slab_terminations, substrate_slab_terminations)) \n", |
| 245 | + "termination_pairs = list(product(film_slab_terminations, substrate_slab_terminations))\n", |
240 | 246 | "print(\"Termination Pairs (Film, Substrate)\")\n", |
241 | 247 | "for idx, termination_pair in enumerate(termination_pairs):\n", |
242 | 248 | " print(f\" {idx}: {termination_pair}\")" |
|
266 | 272 | "termination_pair = termination_pairs[termination_pair_index]\n", |
267 | 273 | "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", |
268 | 274 | " if sys.platform == \"emscripten\":\n", |
269 | | - " termination_pair = await ui_prompt_select_array_element_by_index_pyodide(termination_pairs, element_name=\"film/substrate termination pair\")\n", |
| 275 | + " termination_pair = await ui_prompt_select_array_element_by_index_pyodide(termination_pairs,\n", |
| 276 | + " element_name=\"film/substrate termination pair\")\n", |
270 | 277 | " else:\n", |
271 | | - " termination_pair = ui_prompt_select_array_element_by_index(termination_pairs, element_name=\"film/substrate termination pair\")" |
| 278 | + " termination_pair = ui_prompt_select_array_element_by_index(termination_pairs,\n", |
| 279 | + " element_name=\"film/substrate termination pair\")" |
272 | 280 | ], |
273 | 281 | "metadata": { |
274 | 282 | "collapsed": false |
|
299 | 307 | " film_termination=film_termination,\n", |
300 | 308 | " substrate_termination=substrate_termination,\n", |
301 | 309 | " distance=INTERFACE_DISTANCE,\n", |
302 | | - " vacuum= INTERFACE_VACUUM\n", |
| 310 | + " vacuum=INTERFACE_VACUUM\n", |
303 | 311 | ")" |
304 | 312 | ], |
305 | 313 | "metadata": { |
|
322 | 330 | "outputs": [], |
323 | 331 | "source": [ |
324 | 332 | "from mat3ra.made.tools.build.interface import ZSLStrainMatchingParameters\n", |
| 333 | + "\n", |
325 | 334 | "zsl_strain_matching_parameters = ZSLStrainMatchingParameters(\n", |
326 | 335 | " max_area=MAX_AREA\n", |
327 | 336 | ")" |
|
345 | 354 | "cell_type": "code", |
346 | 355 | "outputs": [], |
347 | 356 | "source": [ |
348 | | - "from mat3ra.made.tools.build.interface import ZSLStrainMatchingInterfaceBuilder, ZSLStrainMatchingInterfaceBuilderParameters\n", |
| 357 | + "from mat3ra.made.tools.build.interface import ZSLStrainMatchingInterfaceBuilder, \\\n", |
| 358 | + " ZSLStrainMatchingInterfaceBuilderParameters\n", |
349 | 359 | "\n", |
350 | | - "matched_interfaces_builder = ZSLStrainMatchingInterfaceBuilder(build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(strain_matching_parameters=zsl_strain_matching_parameters))\n", |
| 360 | + "matched_interfaces_builder = ZSLStrainMatchingInterfaceBuilder(\n", |
| 361 | + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", |
| 362 | + " strain_matching_parameters=zsl_strain_matching_parameters))\n", |
351 | 363 | "\n", |
352 | | - "interfaces_sorted_by_size_and_strain= matched_interfaces_builder.get_materials(configuration=interface_configuration)" |
| 364 | + "interfaces_sorted_by_size_and_strain = matched_interfaces_builder.get_materials(configuration=interface_configuration)" |
353 | 365 | ], |
354 | 366 | "metadata": { |
355 | 367 | "collapsed": false |
|
445 | 457 | "source": [ |
446 | 458 | "import numpy as np\n", |
447 | 459 | "from mat3ra.made.tools.modify import interface_displace_part\n", |
| 460 | + "\n", |
448 | 461 | "a = selected_interface.lattice.a\n", |
449 | 462 | "shifted_interfaces = []\n", |
450 | | - "for n in range(7):\n", |
451 | | - " shifted_interface= interface_displace_part(selected_interface, [0,n*a/np.sqrt(3)/2,0], use_cartesian_coordinates=True)\n", |
| 463 | + "for n in range(2, 9):\n", |
| 464 | + " shifted_interface = interface_displace_part(\n", |
| 465 | + " interface=selected_interface, \n", |
| 466 | + " displacement=[0, n * a / np.sqrt(3) / 2, 0],\n", |
| 467 | + " use_cartesian_coordinates=True)\n", |
452 | 468 | " shifted_interfaces.append(shifted_interface)" |
453 | 469 | ], |
454 | 470 | "metadata": { |
|
490 | 506 | "outputs": [], |
491 | 507 | "source": [ |
492 | 508 | "from utils.jupyterlite import download_content_to_file\n", |
| 509 | + "\n", |
493 | 510 | "for idx, interface in enumerate(shifted_interfaces):\n", |
494 | 511 | " download_content_to_file(interface, f\"interface_{idx}.json\")" |
495 | 512 | ] |
|
0 commit comments