Skip to content

Commit b13cabd

Browse files
authored
Merge pull request #159 from Exabyte-io/feature/SOF-7489
feature/SOF-7489 supercell nb
2 parents 0c601c1 + 69255a4 commit b13cabd

File tree

3 files changed

+229
-2
lines changed

3 files changed

+229
-2
lines changed

other/materials_designer/Introduction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"## 1. Single-Material Structures.\n",
1616
"\n",
1717
"### 1.1. 3D Structures.\n",
18-
"#### [1.1.1. Supercells. Create supercells from 3D crystals.](create_supercell.ipynb)(COMING SOON)\n",
18+
"#### [1.1.1. Supercells. Create supercells from 3D crystals.](create_supercell.ipynb)\n",
1919
"\n",
2020
"### 1.2. 2D Structures.\n",
2121
"#### [1.2.1. Slabs. Create slabs from bulk materials.](create_slab.ipynb)\n",

other/materials_designer/create_slab.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"from utils.jupyterlite import get_materials\n",
109109
"\n",
110110
"materials = get_materials(globals())\n",
111-
"material = materials[26]"
111+
"material = materials[0]"
112112
],
113113
"metadata": {
114114
"collapsed": false
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Create a supercell\n",
7+
"\n",
8+
"Create a supercell of the original structure. The supercell is set either with the supercell matrix or the number of repetitions in each direction.\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": "bfcbf5c3f9adb668"
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": "e3702ff2a5270ce6"
32+
},
33+
{
34+
"cell_type": "code",
35+
"outputs": [],
36+
"source": [
37+
"SUPERCELL_MATRIX = [\n",
38+
" [3, 0, 0], \n",
39+
" [0, 3, 0], \n",
40+
" [0, 0, 1]\n",
41+
"] \n",
42+
"\n",
43+
"# or use the scaling factor\n",
44+
"SCALING_FACTOR = None # [3, 3, 1]"
45+
],
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"id": "e93f72e7c37dea10",
50+
"execution_count": 0
51+
},
52+
{
53+
"cell_type": "markdown",
54+
"source": [
55+
"### 1.2. Install Packages\n",
56+
"The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))."
57+
],
58+
"metadata": {
59+
"collapsed": false
60+
},
61+
"id": "9f3ffe460d75942f"
62+
},
63+
{
64+
"cell_type": "code",
65+
"outputs": [],
66+
"source": [
67+
"import sys\n",
68+
"\n",
69+
"if sys.platform == \"emscripten\":\n",
70+
" import micropip\n",
71+
" \n",
72+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
73+
" from utils.jupyterlite import install_packages\n",
74+
" await install_packages(\"\", \"../../config.yml\")"
75+
],
76+
"metadata": {
77+
"collapsed": false
78+
},
79+
"id": "9eb0650f7183279c",
80+
"execution_count": 0
81+
},
82+
{
83+
"cell_type": "markdown",
84+
"source": [
85+
"### 1.3. Get input materials"
86+
],
87+
"metadata": {
88+
"collapsed": false
89+
},
90+
"id": "f348991bf39a14e7"
91+
},
92+
{
93+
"cell_type": "code",
94+
"outputs": [],
95+
"source": [
96+
"from utils.jupyterlite import get_materials\n",
97+
"\n",
98+
"materials = get_materials(globals())\n",
99+
"material = materials[0]"
100+
],
101+
"metadata": {
102+
"collapsed": false
103+
},
104+
"id": "4b72580121ca40d0",
105+
"execution_count": 0
106+
},
107+
{
108+
"cell_type": "markdown",
109+
"source": [
110+
"### 1.4. Preview the material"
111+
],
112+
"metadata": {
113+
"collapsed": false
114+
},
115+
"id": "aa183a2ac1a6993"
116+
},
117+
{
118+
"cell_type": "code",
119+
"outputs": [],
120+
"source": [
121+
"from utils.visualize import visualize_materials as visualize\n",
122+
"repetitions = SCALING_FACTOR if SCALING_FACTOR else [3, 3, 1]\n",
123+
"visualize(material, repetitions=repetitions, rotation=\"0x\")\n",
124+
"visualize(material, repetitions=repetitions, rotation=\"-90x\")"
125+
],
126+
"metadata": {
127+
"collapsed": false
128+
},
129+
"id": "d3cba46f185c1a1b",
130+
"execution_count": 0
131+
},
132+
{
133+
"cell_type": "markdown",
134+
"source": [
135+
"## 2. Create supercell"
136+
],
137+
"metadata": {
138+
"collapsed": false
139+
},
140+
"id": "ba9e20ebe63ffda7"
141+
},
142+
{
143+
"cell_type": "code",
144+
"outputs": [],
145+
"source": [
146+
"from mat3ra.made.tools.build.supercell import create_supercell\n",
147+
"\n",
148+
"if SUPERCELL_MATRIX:\n",
149+
" supercell = create_supercell(material, supercell_matrix=SUPERCELL_MATRIX)\n",
150+
"elif SCALING_FACTOR:\n",
151+
" supercell = create_supercell(material, scaling_factor=SCALING_FACTOR)"
152+
],
153+
"metadata": {
154+
"collapsed": false
155+
},
156+
"id": "2795d5bdbbaafbe6",
157+
"execution_count": 0
158+
},
159+
{
160+
"cell_type": "markdown",
161+
"source": [
162+
"## 3. Visualize the result"
163+
],
164+
"metadata": {
165+
"collapsed": false
166+
},
167+
"id": "d8f41816d0b48edc"
168+
},
169+
{
170+
"cell_type": "code",
171+
"outputs": [],
172+
"source": [
173+
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")\n",
174+
"visualize(supercell, repetitions=[1, 1, 1], rotation=\"-90x\")"
175+
],
176+
"metadata": {
177+
"collapsed": false
178+
},
179+
"id": "aea078560283ca95",
180+
"execution_count": 0
181+
},
182+
{
183+
"cell_type": "markdown",
184+
"source": [
185+
"# 4. Pass material to the outside runtime"
186+
],
187+
"metadata": {
188+
"collapsed": false
189+
},
190+
"id": "a212abe25bf59b4f"
191+
},
192+
{
193+
"cell_type": "code",
194+
"outputs": [],
195+
"source": [
196+
"from utils.jupyterlite import set_materials\n",
197+
"set_materials(supercell)"
198+
],
199+
"metadata": {
200+
"collapsed": false
201+
},
202+
"id": "cdaf612bc6198546",
203+
"execution_count": 0
204+
}
205+
],
206+
"metadata": {
207+
"kernelspec": {
208+
"display_name": "Python 3",
209+
"language": "python",
210+
"name": "python3"
211+
},
212+
"language_info": {
213+
"codemirror_mode": {
214+
"name": "ipython",
215+
"version": 2
216+
},
217+
"file_extension": ".py",
218+
"mimetype": "text/x-python",
219+
"name": "python",
220+
"nbconvert_exporter": "python",
221+
"pygments_lexer": "ipython2",
222+
"version": "2.7.6"
223+
}
224+
},
225+
"nbformat": 4,
226+
"nbformat_minor": 5
227+
}

0 commit comments

Comments
 (0)