Skip to content

Commit 9049fc9

Browse files
Merge pull request #161 from Exabyte-io/feature/SOF-7490
feature/SOF 7490
2 parents 806f64a + f208f5d commit 9049fc9

2 files changed

Lines changed: 284 additions & 1 deletion

File tree

other/materials_designer/Introduction.ipynb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"#### [1.1.1. Supercells. Create supercells from 3D crystals.](create_supercell.ipynb)\n",
1919
"\n",
2020
"### 1.2. 2D Structures.\n",
21-
"#### [1.2.1. Slabs. Create slabs from bulk materials.](create_slab.ipynb)\n",
21+
"#### [1.2.1. Slabs. Create a slab from a bulk material.](create_slab.ipynb)\n",
22+
"#### [1.2.2. Monolayers. Create a monolayer from a bulk material.](create_monolayer.ipynb)\n",
2223
"\n",
2324
"### 1.3. 1D Structures.\n",
2425
"#### [1.3.1. Nanoribbons. Create nanoribbons from 2D materials.](create_nanoribbon.ipynb)\n",
@@ -92,6 +93,14 @@
9293
"\n",
9394
"#### [7.1.1. More info about the conventions used](under_the_hood.ipynb)."
9495
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"outputs": [],
100+
"source": [],
101+
"metadata": {
102+
"collapsed": false
103+
}
95104
}
96105
],
97106
"metadata": {
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Create a Monolayer\n",
7+
"\n",
8+
"Create a Monolayer of the original structure. \n",
9+
"\n",
10+
"<h2 style=\"color:green\">Usage</h2>\n",
11+
"\n",
12+
"1. Make sure to select Input Materials (in the outer runtime) before running the notebook.\n",
13+
"1. Set notebook parameters in cell 1.1. below (or use the default values).\n",
14+
"1. Click “Run” > “Run All” to run all cells. \n",
15+
"1. Scroll down to view results. "
16+
],
17+
"metadata": {
18+
"collapsed": false
19+
},
20+
"id": "a79609c9bc772c5c"
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"source": [
25+
"## 1. Prepare the Environment\n",
26+
"### 1.1. Set up transformation parameters "
27+
],
28+
"metadata": {
29+
"collapsed": false
30+
},
31+
"id": "47d31d9834478007"
32+
},
33+
{
34+
"cell_type": "code",
35+
"outputs": [],
36+
"source": [
37+
"XY_SUPERCELL_MATRIX = [\n",
38+
" [3, 0],\n",
39+
" [0, 3],\n",
40+
"]\n",
41+
"\n",
42+
"VACUUM = 10.0 # Angstrom"
43+
],
44+
"metadata": {
45+
"collapsed": false
46+
},
47+
"id": "a2c8922a4e627887",
48+
"execution_count": null
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"source": [
53+
"### 1.2. Install Packages\n",
54+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
55+
],
56+
"metadata": {
57+
"collapsed": false
58+
},
59+
"id": "6fab076ea1d7a223"
60+
},
61+
{
62+
"cell_type": "code",
63+
"outputs": [],
64+
"source": [
65+
"import sys\n",
66+
"\n",
67+
"if sys.platform == \"emscripten\":\n",
68+
" import micropip\n",
69+
"\n",
70+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
71+
" from utils.jupyterlite import install_packages\n",
72+
"\n",
73+
" await install_packages(\"\", \"../../config.yml\")"
74+
],
75+
"metadata": {
76+
"collapsed": false
77+
},
78+
"id": "b0c332f1c1f451fd",
79+
"execution_count": null
80+
},
81+
{
82+
"cell_type": "markdown",
83+
"source": [
84+
"### 1.3. Get input materials"
85+
],
86+
"metadata": {
87+
"collapsed": false
88+
},
89+
"id": "3e9934b458d6cb4"
90+
},
91+
{
92+
"cell_type": "code",
93+
"outputs": [],
94+
"source": [
95+
"from utils.jupyterlite import get_materials\n",
96+
"\n",
97+
"materials = get_materials(globals())\n",
98+
"material = materials[0]"
99+
],
100+
"metadata": {
101+
"collapsed": false
102+
},
103+
"id": "74cd0d5a3881ab47",
104+
"execution_count": null
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"source": [
109+
"### 1.4. Preview the material"
110+
],
111+
"metadata": {
112+
"collapsed": false
113+
},
114+
"id": "d4535caf6debb8d4"
115+
},
116+
{
117+
"cell_type": "code",
118+
"outputs": [],
119+
"source": [
120+
"from utils.visualize import visualize_materials as visualize\n",
121+
"\n",
122+
"visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")\n",
123+
"visualize(material, repetitions=[3, 3, 1], rotation=\"-90x\")"
124+
],
125+
"metadata": {
126+
"collapsed": false
127+
},
128+
"id": "d6bea39864c23ab5",
129+
"execution_count": null
130+
},
131+
{
132+
"cell_type": "markdown",
133+
"source": [
134+
"## 2. Create Monolayer"
135+
],
136+
"metadata": {
137+
"collapsed": false
138+
},
139+
"id": "5473c36cd254aa89"
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"source": [
144+
"### 2.1. Create slab configuration\n",
145+
"Slab Configuration lets define the slab thickness, vacuum, and the Miller indices of the interfacial plane and get the slabs with possible terminations.\n"
146+
],
147+
"metadata": {
148+
"collapsed": false
149+
},
150+
"id": "ee17958872d03410"
151+
},
152+
{
153+
"cell_type": "code",
154+
"outputs": [],
155+
"source": [
156+
"from mat3ra.made.tools.build.slab import SlabConfiguration\n",
157+
"\n",
158+
"slab_configuration = SlabConfiguration(\n",
159+
" bulk=material,\n",
160+
" miller_indices=(0, 0, 1),\n",
161+
" thickness=1,\n",
162+
" vacuum=VACUUM,\n",
163+
" xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n",
164+
" use_orthogonal_z=True,\n",
165+
" use_conventional_cell=True,\n",
166+
")"
167+
],
168+
"metadata": {
169+
"collapsed": false
170+
},
171+
"id": "b8dc56881543c16c",
172+
"execution_count": null
173+
},
174+
{
175+
"cell_type": "markdown",
176+
"source": [
177+
"### 2.2 Create the slab of Single Layer"
178+
],
179+
"metadata": {
180+
"collapsed": false
181+
},
182+
"id": "661c76f9bab9f743"
183+
},
184+
{
185+
"cell_type": "code",
186+
"outputs": [],
187+
"source": [
188+
"from mat3ra.made.tools.modify import translate_to_z_level, filter_by_box\n",
189+
"from mat3ra.made.tools.build.slab import create_slab\n",
190+
"\n",
191+
"slab = create_slab(slab_configuration)\n",
192+
"\n",
193+
"# Get only the top layer of two -- for AB stacked bilayers forming a 3D bulk basis\n",
194+
"if any(substring in material.name for substring in [\"3D\", \"Bulk\"]):\n",
195+
" centered_slab = translate_to_z_level(slab, z_level=\"center\")\n",
196+
" half_filtered_slab = filter_by_box(centered_slab, [0, 0, 0.5], [1, 1, 1])\n",
197+
" monolayer = translate_to_z_level(half_filtered_slab, z_level=\"center\")"
198+
],
199+
"metadata": {
200+
"collapsed": false
201+
},
202+
"id": "cf27e53c85adc447",
203+
"execution_count": null
204+
},
205+
{
206+
"cell_type": "markdown",
207+
"source": [
208+
"## 3. Visualize the result"
209+
],
210+
"metadata": {
211+
"collapsed": false
212+
},
213+
"id": "527829d64a542d10"
214+
},
215+
{
216+
"cell_type": "code",
217+
"outputs": [],
218+
"source": [
219+
"visualize(monolayer, repetitions=[1, 1, 1], rotation=\"0x\")\n",
220+
"visualize(monolayer, repetitions=[1, 1, 1], rotation=\"-90x\")"
221+
],
222+
"metadata": {
223+
"collapsed": false
224+
},
225+
"id": "ee12ab13c210b953",
226+
"execution_count": null
227+
},
228+
{
229+
"cell_type": "markdown",
230+
"source": [
231+
"# 4. Pass material to the outside runtime"
232+
],
233+
"metadata": {
234+
"collapsed": false
235+
},
236+
"id": "6ce5f7dd9a919a08"
237+
},
238+
{
239+
"cell_type": "code",
240+
"outputs": [],
241+
"source": [
242+
"from utils.jupyterlite import set_materials\n",
243+
"\n",
244+
"set_materials(monolayer)"
245+
],
246+
"metadata": {
247+
"collapsed": false
248+
},
249+
"id": "865c71d008d87beb",
250+
"execution_count": null
251+
}
252+
],
253+
"metadata": {
254+
"kernelspec": {
255+
"display_name": "Python 3",
256+
"language": "python",
257+
"name": "python3"
258+
},
259+
"language_info": {
260+
"codemirror_mode": {
261+
"name": "ipython",
262+
"version": 2
263+
},
264+
"file_extension": ".py",
265+
"mimetype": "text/x-python",
266+
"name": "python",
267+
"nbconvert_exporter": "python",
268+
"pygments_lexer": "ipython2",
269+
"version": "2.7.6"
270+
}
271+
},
272+
"nbformat": 4,
273+
"nbformat_minor": 5
274+
}

0 commit comments

Comments
 (0)