|
7 | 7 | "source": [ |
8 | 8 | "# Create a slab with specified termination\n", |
9 | 9 | "\n", |
10 | | - "Create a slab with a specified termination from a bulk material. \n", |
| 10 | + "Create one or multiple slabs with a specified termination and thickness from a bulk material.\n", |
11 | 11 | "\n", |
12 | 12 | "<h2 style=\"color:green\">Usage</h2>\n", |
13 | 13 | "\n", |
|
46 | 46 | "\n", |
47 | 47 | "MILLER_INDICES = (0, 0, 1)\n", |
48 | 48 | "THICKNESS = 3 # in atomic layers\n", |
| 49 | + "THICKNESSES = [] # for multiple slabs with different thicknesses, e.g., [3, 5, 7]\n", |
49 | 50 | "VACUUM = 10.0 # in angstroms\n", |
50 | 51 | "XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", |
51 | 52 | "USE_ORTHOGONAL_C = True\n", |
|
257 | 258 | "source": [ |
258 | 259 | "from mat3ra.made.tools.helpers import create_slab\n", |
259 | 260 | "\n", |
260 | | - "slab = create_slab(crystal=material,\n", |
261 | | - " termination_top=termination,\n", |
262 | | - " use_conventional_cell=USE_CONVENTIONAL_CELL,\n", |
263 | | - " miller_indices=MILLER_INDICES,\n", |
264 | | - " number_of_layers= THICKNESS,\n", |
265 | | - " vacuum=VACUUM,\n", |
266 | | - " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", |
267 | | - " use_orthogonal_c=USE_ORTHOGONAL_C,\n", |
268 | | - " )\n" |
| 261 | + "slabs = []\n", |
| 262 | + "thicknesses = THICKNESSES if THICKNESSES else [THICKNESS]\n", |
| 263 | + "for thickness in thicknesses:\n", |
| 264 | + " slab = create_slab(crystal=material,\n", |
| 265 | + " termination_top=termination,\n", |
| 266 | + " use_conventional_cell=USE_CONVENTIONAL_CELL,\n", |
| 267 | + " miller_indices=MILLER_INDICES,\n", |
| 268 | + " number_of_layers=thickness,\n", |
| 269 | + " vacuum=VACUUM,\n", |
| 270 | + " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", |
| 271 | + " use_orthogonal_c=USE_ORTHOGONAL_C,\n", |
| 272 | + " )\n", |
| 273 | + " slab.name += f\" {thickness}L\"\n", |
| 274 | + " slabs.append(slab)" |
269 | 275 | ] |
270 | 276 | }, |
271 | 277 | { |
|
283 | 289 | "metadata": {}, |
284 | 290 | "outputs": [], |
285 | 291 | "source": [ |
286 | | - "visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\")" |
| 292 | + "visualize(slabs, repetitions=[1, 1, 1], rotation=\"0x\")" |
287 | 293 | ] |
288 | 294 | }, |
289 | 295 | { |
|
302 | 308 | "outputs": [], |
303 | 309 | "source": [ |
304 | 310 | "from utils.jupyterlite import set_materials\n", |
305 | | - "set_materials(slab)" |
| 311 | + "set_materials(slabs)" |
306 | 312 | ] |
307 | 313 | } |
308 | 314 | ], |
|
0 commit comments