Skip to content

Commit 2dde34d

Browse files
authored
Merge pull request #140 from Exabyte-io/feature/SOF-7412
feature/SOF 7412
2 parents fe60c46 + 5f68908 commit 2dde34d

File tree

2 files changed

+272
-1
lines changed

2 files changed

+272
-1
lines changed

other/materials_designer/Introduction.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
"\n",
3434
"This notebook lets user create a slab and place an adatom at specified location. [Click here to open the notebook](create_adatom_defect.ipynb).\n",
3535
"\n",
36-
"#### [1.6. Slab Perturbation](create_perturbation.ipynb)\n",
36+
"#### [1.6. Nanoribbon creation](create_nanoribbon.ipynb)\n",
37+
"\n",
38+
"This notebook lets user create a nanoribbon from a bulk 2D material. [Click here to open the notebook](create_nanoribbon.ipynb).\n",
39+
"\n",
40+
"#### [1.7. Slab Perturbation](create_perturbation.ipynb)\n",
3741
"\n",
3842
"This notebook lets user add a perturbation to a slab by moving atoms according to a specified function. [Click here to open the notebook](create_perturbation.ipynb).\n",
3943
"\n",
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Create a Nanoribbon of a 2D material\n",
7+
"\n",
8+
"Create a nanoribbon of a 2D material with Hexagonal lattice using the `NanoribbonBuilder` tool. \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 nanoribbon 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. \n",
16+
"\n",
17+
"## Summary\n",
18+
"1. Prepare the Environment: Set up the notebook and install packages, preview the input materials\n",
19+
"1. Create the Nanoribbon: Set nanoribbon parameters and create the nanoribbon\n",
20+
"2. Visualize the Perturbed Material\n",
21+
"\n",
22+
"## Notes\n",
23+
"\n",
24+
"1. For more information, see [Introduction](Introduction.ipynb)\n"
25+
],
26+
"metadata": {
27+
"collapsed": false
28+
},
29+
"id": "367a698b29e22bd7"
30+
},
31+
{
32+
"cell_type": "markdown",
33+
"source": [
34+
"## 1. Prepare the Environment\n",
35+
"### 1.1. Set up nanoribbon parameters "
36+
],
37+
"metadata": {
38+
"collapsed": false
39+
},
40+
"id": "193a4e6a78fd5bd7"
41+
},
42+
{
43+
"cell_type": "code",
44+
"outputs": [],
45+
"source": [
46+
"# Widths and lengths are in number of unit cells\n",
47+
"WIDTH = 3\n",
48+
"VACUUM_WIDTH = 2\n",
49+
"LENGTH = 10\n",
50+
"VACUUM_LENGTH = 0\n",
51+
"EDGE_TYPE = \"zigzag\" # \"zigzag\" or \"armchair\""
52+
],
53+
"metadata": {
54+
"collapsed": false
55+
},
56+
"id": "a40d7b697c413113",
57+
"execution_count": null
58+
},
59+
{
60+
"cell_type": "markdown",
61+
"source": [
62+
"### 1.2. Install Packages\n",
63+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
64+
],
65+
"metadata": {
66+
"collapsed": false
67+
},
68+
"id": "49c9f5022d50517e"
69+
},
70+
{
71+
"cell_type": "code",
72+
"outputs": [],
73+
"source": [
74+
"import sys\n",
75+
"\n",
76+
"if sys.platform == \"emscripten\":\n",
77+
" import micropip\n",
78+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
79+
" from utils.jupyterlite import install_packages\n",
80+
" await install_packages(\"\", \"../../config.yml\")"
81+
],
82+
"metadata": {
83+
"collapsed": false
84+
},
85+
"id": "c6d9f8e57bef2f91",
86+
"execution_count": null
87+
},
88+
{
89+
"cell_type": "markdown",
90+
"source": [
91+
"### 1.3. Get input materials\n",
92+
"Materials are loaded with `get_data()`. The first material is assigned as substrate and the second as film."
93+
],
94+
"metadata": {
95+
"collapsed": false
96+
},
97+
"id": "edf02101e27a2742"
98+
},
99+
{
100+
"cell_type": "code",
101+
"outputs": [],
102+
"source": [
103+
"from mat3ra.made.material import Material\n",
104+
"from utils.jupyterlite import get_data\n",
105+
"\n",
106+
"# Get the list of input materials and load them into `materials_in` variable\n",
107+
"get_data(\"materials_in\", globals())\n",
108+
"materials = list(map(Material, globals()[\"materials_in\"]))"
109+
],
110+
"metadata": {
111+
"collapsed": false
112+
},
113+
"id": "e0c53233ce728cc1",
114+
"execution_count": null
115+
},
116+
{
117+
"cell_type": "markdown",
118+
"source": [
119+
"### 1.4. Preview Material"
120+
],
121+
"metadata": {
122+
"collapsed": false
123+
},
124+
"id": "cf29b7f6fe114d8f"
125+
},
126+
{
127+
"cell_type": "code",
128+
"outputs": [],
129+
"source": [
130+
"from utils.visualize import visualize_materials as visualize\n",
131+
"\n",
132+
"material = materials[2]\n",
133+
"visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")"
134+
],
135+
"metadata": {
136+
"collapsed": false
137+
},
138+
"id": "897ba7aa4e402d24",
139+
"execution_count": null
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"source": [
144+
"## 2. Create the Nanoribbon\n",
145+
"### 2.1. Set nanoribbon parameters"
146+
],
147+
"metadata": {
148+
"collapsed": false
149+
},
150+
"id": "39a93c4635762a83"
151+
},
152+
{
153+
"cell_type": "code",
154+
"outputs": [],
155+
"source": [
156+
"from mat3ra.made.tools.build.nanoribbon import NanoribbonBuilder, NanoribbonConfiguration\n",
157+
"\n",
158+
"nanoribbon_configuration = NanoribbonConfiguration(\n",
159+
" material=material,\n",
160+
" width=WIDTH,\n",
161+
" vacuum_width=VACUUM_WIDTH,\n",
162+
" length=LENGTH,\n",
163+
" vacuum_length=VACUUM_LENGTH,\n",
164+
" edge_type=EDGE_TYPE\n",
165+
")\n",
166+
"\n",
167+
"\n",
168+
"builder = NanoribbonBuilder()"
169+
],
170+
"metadata": {
171+
"collapsed": false
172+
},
173+
"id": "1991efeeebe39db4",
174+
"execution_count": null
175+
},
176+
{
177+
"cell_type": "markdown",
178+
"source": [
179+
"### 2.2. Create the Nanoribbon"
180+
],
181+
"metadata": {
182+
"collapsed": false
183+
},
184+
"id": "d296d7287618dc0b"
185+
},
186+
{
187+
"cell_type": "code",
188+
"outputs": [],
189+
"source": [
190+
"nanoribbon = builder.get_material(nanoribbon_configuration)"
191+
],
192+
"metadata": {
193+
"collapsed": false
194+
},
195+
"id": "302f417828a8fc9c",
196+
"execution_count": null
197+
},
198+
{
199+
"cell_type": "markdown",
200+
"source": [
201+
"## 3. Visualize the Nanoribbon"
202+
],
203+
"metadata": {
204+
"collapsed": false
205+
},
206+
"id": "eecd561cd92fb18a"
207+
},
208+
{
209+
"cell_type": "code",
210+
"outputs": [],
211+
"source": [
212+
"from utils.visualize import visualize_materials as visualize\n",
213+
"visualize([{\"material\": nanoribbon, \"title\": \"Nanoribbon\"}])"
214+
],
215+
"metadata": {
216+
"collapsed": false
217+
},
218+
"id": "1ee393a7f2ec3bc8",
219+
"execution_count": null
220+
},
221+
{
222+
"cell_type": "markdown",
223+
"source": [
224+
"## 4. Pass data to the outside runtime"
225+
],
226+
"metadata": {
227+
"collapsed": false
228+
},
229+
"id": "9e0b241366592109"
230+
},
231+
{
232+
"cell_type": "code",
233+
"outputs": [],
234+
"source": [
235+
"from utils.jupyterlite import set_data\n",
236+
"\n",
237+
"set_data(\"materials\", [nanoribbon.to_json()])"
238+
],
239+
"metadata": {
240+
"collapsed": false
241+
},
242+
"id": "29dfa0a329cca2fa",
243+
"execution_count": null
244+
}
245+
],
246+
"metadata": {
247+
"kernelspec": {
248+
"display_name": "Python 3",
249+
"language": "python",
250+
"name": "python3"
251+
},
252+
"language_info": {
253+
"codemirror_mode": {
254+
"name": "ipython",
255+
"version": 2
256+
},
257+
"file_extension": ".py",
258+
"mimetype": "text/x-python",
259+
"name": "python",
260+
"nbconvert_exporter": "python",
261+
"pygments_lexer": "ipython2",
262+
"version": "2.7.6"
263+
}
264+
},
265+
"nbformat": 4,
266+
"nbformat_minor": 5
267+
}

0 commit comments

Comments
 (0)