Skip to content

Commit 4a2739a

Browse files
authored
Merge pull request #162 from Exabyte-io/feature/SOF-7491
feat: add nanowire nb
2 parents 9049fc9 + fd7af3d commit 4a2739a

File tree

3 files changed

+552
-0
lines changed

3 files changed

+552
-0
lines changed

other/materials_designer/Introduction.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"\n",
2424
"### 1.3. 1D Structures.\n",
2525
"#### [1.3.1. Nanoribbons. Create nanoribbons from 2D materials.](create_nanoribbon.ipynb)\n",
26+
"#### [1.3.2. Nanowires. Create a nanowire from a bulk material.](create_nanowire.ipynb)\n",
27+
"#### [1.3.3. Nanowires with custom shape. Create a nanowire with a custom cross-section.](create_nanowire_custom_shape.ipynb)\n",
2628
"\n",
2729
"### 1.4. 0D Structures.\n",
2830
"#### [1.4.1. Spherical. Create clusters or spherical structures.](create_cluster_sphere.ipynb)\n",
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Create a nanowire\n",
7+
"\n",
8+
"Create a nanowire from original material by creating a slab (with specific Miller indices) and cutting a cylinder along its Z axis, then, optionally, rotating to align along X axis.\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": "c9f342d4ac1988c6"
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"source": [
25+
"## 1. Prepare the Environment\n",
26+
"### 1.1. Set up nanowire parameters"
27+
],
28+
"metadata": {
29+
"collapsed": false
30+
},
31+
"id": "cbcd112c418fcaa4"
32+
},
33+
{
34+
"cell_type": "code",
35+
"outputs": [],
36+
"source": [
37+
"MILLER_INDICES= (0,0,1) # Miller indices of the nanowire direction\n",
38+
"RADIUS = 5.0 # Wire radius in Angstroms\n",
39+
"LENGTH = 30.0 # Wire length in Angstroms\n",
40+
"VACUUM = 10.0 # Vacuum thickness on the sides in Angstroms\n",
41+
"ALIGN_ALONG_X = True"
42+
],
43+
"metadata": {
44+
"collapsed": false
45+
},
46+
"id": "2269749714d81b93"
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"source": [
51+
"### 1.2. Install Packages\n",
52+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
53+
],
54+
"metadata": {
55+
"collapsed": false
56+
},
57+
"id": "65c906791f69bac9"
58+
},
59+
{
60+
"cell_type": "code",
61+
"outputs": [],
62+
"source": [
63+
"import sys\n",
64+
"\n",
65+
"if sys.platform == \"emscripten\":\n",
66+
" import micropip\n",
67+
" \n",
68+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
69+
" from utils.jupyterlite import install_packages\n",
70+
" await install_packages(\"\", \"../../config.yml\")"
71+
],
72+
"metadata": {
73+
"collapsed": false
74+
},
75+
"id": "6dac92b719d539ec"
76+
},
77+
{
78+
"cell_type": "markdown",
79+
"source": [
80+
"### 1.3. Get input materials"
81+
],
82+
"metadata": {
83+
"collapsed": false
84+
},
85+
"id": "2fe1d71e1b02aed9"
86+
},
87+
{
88+
"cell_type": "code",
89+
"outputs": [],
90+
"source": [
91+
"from utils.jupyterlite import get_materials\n",
92+
"\n",
93+
"materials = get_materials(globals())\n",
94+
"material = materials[0] "
95+
],
96+
"metadata": {
97+
"collapsed": false
98+
},
99+
"id": "b95701d7a0e593fe"
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"source": [
104+
"### 1.4. Preview the material"
105+
],
106+
"metadata": {
107+
"collapsed": false
108+
},
109+
"id": "a8ebe61794b2e803"
110+
},
111+
{
112+
"cell_type": "code",
113+
"outputs": [],
114+
"source": [
115+
"from utils.visualize import visualize_materials as visualize\n",
116+
"visualize(material, repetitions=[3,3,3], rotation=\"0x\")\n",
117+
"visualize(material, repetitions=[3,3,3], rotation=\"-90x\")"
118+
],
119+
"metadata": {
120+
"collapsed": false
121+
},
122+
"id": "c98ec170f3ee6d24"
123+
},
124+
{
125+
"cell_type": "markdown",
126+
"source": [
127+
"## 2. Create nanowire\n",
128+
"### 2.1. Create a slab and cut a cylinder"
129+
],
130+
"metadata": {
131+
"collapsed": false
132+
},
133+
"id": "38ecf94e650e268d"
134+
},
135+
{
136+
"cell_type": "code",
137+
"outputs": [],
138+
"source": [
139+
"import math\n",
140+
"from mat3ra.made.tools.build.supercell import create_supercell\n",
141+
"from mat3ra.made.tools.modify import filter_by_cylinder, add_vacuum_sides\n",
142+
"from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n",
143+
"\n",
144+
"slab_config = SlabConfiguration(\n",
145+
" bulk=material,\n",
146+
" miller_indices=MILLER_INDICES,\n",
147+
" thickness=1,\n",
148+
" vacuum=0,\n",
149+
" use_orthogonal_z=True,\n",
150+
")\n",
151+
"\n",
152+
"slab_unit_cell = create_slab(slab_config)\n",
153+
"n_for_x = math.ceil(int(2*RADIUS / slab_unit_cell.lattice.a)) + 1\n",
154+
"n_for_y = math.ceil(int(2*RADIUS / slab_unit_cell.lattice.b)) + 1\n",
155+
"n_for_z = int(LENGTH / slab_unit_cell.lattice.c)\n",
156+
"supercell = create_supercell(slab_unit_cell, supercell_matrix=[[n_for_x, 0, 0], [0, n_for_y, 0], [0, 0, n_for_z]])\n",
157+
"nanowire_z = filter_by_cylinder(supercell, radius=RADIUS, use_cartesian_coordinates=True)\n",
158+
"nanowire_z = add_vacuum_sides(nanowire_z, vacuum=VACUUM, on_x=True, on_y=True) "
159+
],
160+
"metadata": {
161+
"collapsed": false
162+
},
163+
"id": "c4b34b3287960dcc"
164+
},
165+
{
166+
"cell_type": "markdown",
167+
"source": [
168+
"### 2.2. Rotate to align along X axis (optional)"
169+
],
170+
"metadata": {
171+
"collapsed": false
172+
},
173+
"id": "ae940638396f93a6"
174+
},
175+
{
176+
"cell_type": "code",
177+
"outputs": [],
178+
"source": [
179+
"rotate_90_degree_matrix = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]\n",
180+
"nanowire_x = create_supercell(nanowire_z, supercell_matrix=rotate_90_degree_matrix)\n",
181+
"nanowire = nanowire_x if ALIGN_ALONG_X else nanowire_z"
182+
],
183+
"metadata": {
184+
"collapsed": false
185+
},
186+
"id": "7401ab24726bf4e5"
187+
},
188+
{
189+
"cell_type": "markdown",
190+
"source": [
191+
"## 3. Visualize the result"
192+
],
193+
"metadata": {
194+
"collapsed": false
195+
},
196+
"id": "d8f41816d0b48edc"
197+
},
198+
{
199+
"cell_type": "code",
200+
"outputs": [],
201+
"source": [
202+
"visualize(nanowire, repetitions=[1, 1, 1], rotation=\"0x\")\n",
203+
"visualize(nanowire, repetitions=[1, 1, 1], rotation=\"-90x\")\n",
204+
"visualize(nanowire, repetitions=[1, 1, 1], rotation=\"-90y\")"
205+
],
206+
"metadata": {
207+
"collapsed": false
208+
},
209+
"id": "aea078560283ca95",
210+
"execution_count": null
211+
},
212+
{
213+
"cell_type": "markdown",
214+
"source": [
215+
"# 4. Pass material to the outside runtime"
216+
],
217+
"metadata": {
218+
"collapsed": false
219+
},
220+
"id": "a212abe25bf59b4f"
221+
},
222+
{
223+
"cell_type": "code",
224+
"outputs": [],
225+
"source": [
226+
"from utils.jupyterlite import set_materials\n",
227+
"set_materials(nanowire)"
228+
],
229+
"metadata": {
230+
"collapsed": false
231+
},
232+
"id": "cdaf612bc6198546",
233+
"execution_count": null
234+
}
235+
],
236+
"metadata": {
237+
"kernelspec": {
238+
"display_name": "Python 3",
239+
"language": "python",
240+
"name": "python3"
241+
},
242+
"language_info": {
243+
"codemirror_mode": {
244+
"name": "ipython",
245+
"version": 2
246+
},
247+
"file_extension": ".py",
248+
"mimetype": "text/x-python",
249+
"name": "python",
250+
"nbconvert_exporter": "python",
251+
"pygments_lexer": "ipython2",
252+
"version": "2.7.6"
253+
}
254+
},
255+
"nbformat": 4,
256+
"nbformat_minor": 5
257+
}

0 commit comments

Comments
 (0)