Skip to content

Commit 3f6fb9c

Browse files
authored
Merge pull request #199 from Exabyte-io/update/SOF-7544
update/SOF-7544 various cleanups for tutorials
2 parents 11ed434 + 315238a commit 3f6fb9c

32 files changed

+288
-289
lines changed

config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ default:
99
- pandas==1.5.3
1010
- ase==3.22.1
1111
- ipywidgets
12-
- plotly==5.18
12+
- plotly>=5.18
13+
- nbformat>=4.2.0
1314
packages_python:
1415
- pymatgen==2024.4.13
1516
packages_pyodide:
@@ -33,7 +34,7 @@ default:
3334
notebooks:
3435
- name: create_interface_with_min_strain_zsl.ipynb
3536
packages_common:
36-
- plotly==5.18
37+
- plotly>=5.18
3738
- nbformat>=4.2.0
3839
packages_python:
3940
packages_pyodide:

other/materials_designer/Introduction.ipynb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@
9797
"\n",
9898
"This notebook demonstrates a workflow for converting materials data from the [JARVIS](https://jarvis.nist.gov/) database into ESSE format for use with the Mat3ra.com platform.\n",
9999
"\n",
100-
"#### [6.1.4. Optimize film position on interface](optimize_film_position.ipynb).\n",
100+
"## 6.2. Optimize.\n",
101+
"\n",
102+
"#### [6.2.1. Optimize film position on interface](optimize_film_position.ipynb).\n",
103+
"\n",
104+
"## 6.3. Development.\n",
105+
"\n",
106+
"#### [6.3.1. Custom Transformation](custom_transformation.ipynb). Notebook setup for development of custom transformations on materials.\n",
101107
"\n",
102108
"## 7. Read more\n",
103109
"\n",
@@ -112,7 +118,8 @@
112118
"source": [],
113119
"metadata": {
114120
"collapsed": false
115-
}
121+
},
122+
"execution_count": null
116123
}
117124
],
118125
"metadata": {

other/materials_designer/create_interface_with_relaxation_ase_emt.ipynb

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"cell_type": "code",
4343
"outputs": [],
4444
"source": [
45+
"MATERIAL_INDEX = 0 # Index of the material in the list of materials\n",
4546
"# Maximum force tolerance for the relaxation to stop, in eV/Å\n",
4647
"FMAX = 0.05"
4748
],
@@ -96,7 +97,7 @@
9697
"from utils.jupyterlite import get_materials\n",
9798
"\n",
9899
"materials = get_materials(globals())\n",
99-
"interface = materials[0]"
100+
"interface = materials[MATERIAL_INDEX]"
100101
]
101102
},
102103
{
@@ -160,22 +161,38 @@
160161
"cell_type": "code",
161162
"outputs": [],
162163
"source": [
163-
"from utils.plot import create_realtime_plot, plot_update_callback\n",
164+
"from mat3ra.utils.jupyterlite.plot import create_realtime_plot, create_update_callback\n",
164165
"from mat3ra.made.tools.convert import from_ase\n",
165166
"from mat3ra.made.material import Material\n",
166167
"\n",
167168
"# Add calculator to the interface for relaxation\n",
168169
"ase_interface = to_ase(interface)\n",
169-
"ase_interface.set_calculator(calculator)\n",
170+
"ase_interface.calc = calculator\n",
170171
"\n",
171172
"dyn = optimizer(ase_interface)\n",
173+
"\n",
174+
"\n",
175+
"# Create the real-time plot\n",
176+
"fig = create_realtime_plot(\n",
177+
" title=\"Optimization Progress\",\n",
178+
" x_label=\"Step\",\n",
179+
" y_label=\"Energy (eV)\"\n",
180+
")\n",
181+
"\n",
172182
"steps = []\n",
173183
"energies = []\n",
174184
"\n",
175-
"fig = create_realtime_plot()\n",
176-
"\n",
177185
"# Run the relaxation\n",
178-
"dyn.attach(plot_update_callback(dyn, ase_interface, fig, steps, energies), interval=1)\n",
186+
"dyn.attach(\n",
187+
" create_update_callback(\n",
188+
" dynamic_object=dyn,\n",
189+
" value_getter= ase_interface.get_potential_energy,\n",
190+
" figure=fig,\n",
191+
" steps=steps,\n",
192+
" values=energies\n",
193+
" ),\n",
194+
" interval=1\n",
195+
")\n",
179196
"dyn.run(fmax=OPTIMIZATION_PARAMETERS[\"FMAX\"])\n",
180197
"\n",
181198
"ase_final_interface = ase_interface\n",

other/materials_designer/create_terrace_defect.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"## 1. Prepare the Environment\n",
3131
"### 1.1. Set up the notebook\n",
3232
"The cut direction, pivot coordinate, and number of added layers define the terrace defect, shown in the image below.\n",
33-
"<img src=\"https://i.imgur.com/XA2F55Q.png\" alt=\"Terrace parameters visualized\" width=\"400\"/>"
33+
"\n",
34+
"<img src=\"https://github.com/Exabyte-io/documentation/raw/88451ce38b0f57f804dcb5010a1a95bb9b9e50bc/images/notebooks/terrace_settings.webp\" alt=\"Terrace parameters visualized\" width=\"400\"/>"
3435
],
3536
"metadata": {
3637
"collapsed": false
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"source": [
6+
"# Development Notebook\n",
7+
"\n",
8+
"This notebook enables loading materials and performing custom transformations with Python. The transformed materials can then be passed to the Materials Designer or saved to a folder. Necessary packages are installed and imported below.\n",
9+
"## 1. Setup Notebook\n",
10+
"### 1.1 Install packages"
11+
],
12+
"metadata": {
13+
"collapsed": false
14+
},
15+
"id": "36708f17f40b64cb"
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": null,
20+
"id": "initial_id",
21+
"metadata": {
22+
"collapsed": true
23+
},
24+
"outputs": [],
25+
"source": [
26+
"# Install packages for JupyterLite\n",
27+
"from mat3ra.utils.jupyterlite.packages import install_packages\n",
28+
"import sys\n",
29+
"\n",
30+
"if sys.platform == \"emscripten\":\n",
31+
" import micropip\n",
32+
"\n",
33+
" # Import the mat3ra api-examples package to allow for relative imports\n",
34+
" await micropip.install('mat3ra-api-examples', deps=False)\n",
35+
"\n",
36+
"await install_packages(\"\")"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"source": [
42+
"### 1.2 Import necessary packages"
43+
],
44+
"metadata": {
45+
"collapsed": false
46+
},
47+
"id": "8185aca94726dc8f"
48+
},
49+
{
50+
"cell_type": "code",
51+
"outputs": [],
52+
"source": [
53+
"# Material class to hold structural data\n",
54+
"from mat3ra.made.material import Material\n",
55+
"# Materials class with JSONs of selected materials\n",
56+
"from mat3ra.standata.materials import Materials"
57+
],
58+
"metadata": {
59+
"collapsed": false
60+
},
61+
"id": "b2fa69b96b195d30"
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"source": [
66+
"## 2. Load materials"
67+
],
68+
"metadata": {
69+
"collapsed": false
70+
},
71+
"id": "c783d38d94a627e4"
72+
},
73+
{
74+
"cell_type": "code",
75+
"outputs": [],
76+
"source": [
77+
"from utils.jupyterlite import get_materials\n",
78+
"materials = get_materials(globals())"
79+
],
80+
"metadata": {
81+
"collapsed": false
82+
},
83+
"id": "54e68de6c6cc3e03"
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"source": [
88+
"## 3. Transform materials"
89+
],
90+
"metadata": {
91+
"collapsed": false
92+
},
93+
"id": "6ca73dec2609be4a"
94+
},
95+
{
96+
"cell_type": "code",
97+
"outputs": [],
98+
"source": [
99+
"new_materials = ..."
100+
],
101+
"metadata": {
102+
"collapsed": false
103+
},
104+
"id": "91069f5712a65dbb"
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"source": [
109+
"## 4. Save transformed materials"
110+
],
111+
"metadata": {
112+
"collapsed": false
113+
},
114+
"id": "296f89e8dde270ed"
115+
},
116+
{
117+
"cell_type": "code",
118+
"outputs": [],
119+
"source": [
120+
"from utils.jupyterlite import set_materials, download_content_to_file\n",
121+
"\n",
122+
"set_materials(new_materials)\n",
123+
"# for idx, material in enumerate(new_materials):\n",
124+
"# download_content_to_file(new_materials, f\"new_material_{idx}.json\")"
125+
],
126+
"metadata": {
127+
"collapsed": false
128+
},
129+
"id": "7973f7ee67bdc42a"
130+
}
131+
],
132+
"metadata": {
133+
"kernelspec": {
134+
"display_name": "Python 3",
135+
"language": "python",
136+
"name": "python3"
137+
},
138+
"language_info": {
139+
"codemirror_mode": {
140+
"name": "ipython",
141+
"version": 2
142+
},
143+
"file_extension": ".py",
144+
"mimetype": "text/x-python",
145+
"name": "python",
146+
"nbconvert_exporter": "python",
147+
"pygments_lexer": "ipython2",
148+
"version": "2.7.6"
149+
}
150+
},
151+
"nbformat": 4,
152+
"nbformat_minor": 5
153+
}

other/materials_designer/mat3ra.ipynb

Lines changed: 0 additions & 37 deletions
This file was deleted.

other/materials_designer/optimize_film_position.ipynb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
"metadata": {
104104
"collapsed": false
105105
},
106-
"id": "3d982a1ca641f0d8"
106+
"id": "3d982a1ca641f0d8",
107+
"execution_count": null
107108
},
108109
{
109110
"cell_type": "markdown",
@@ -127,7 +128,8 @@
127128
"metadata": {
128129
"collapsed": false
129130
},
130-
"id": "5f4afdb7ac0c865b"
131+
"id": "5f4afdb7ac0c865b",
132+
"execution_count": null
131133
},
132134
{
133135
"cell_type": "markdown",
@@ -147,6 +149,7 @@
147149
"from mat3ra.made.tools.modify import interface_displace_part\n",
148150
"from mat3ra.made.tools.calculate.calculators import InterfaceMaterialCalculator\n",
149151
"from mat3ra.made.tools.optimize import evaluate_calculator_on_xy_grid\n",
152+
"\n",
150153
"calculator = InterfaceMaterialCalculator()\n",
151154
"\n",
152155
"# Calculate energy landscape\n",
@@ -175,7 +178,8 @@
175178
"metadata": {
176179
"collapsed": false
177180
},
178-
"id": "eb0b6e59c24dda4"
181+
"id": "eb0b6e59c24dda4",
182+
"execution_count": null
179183
},
180184
{
181185
"cell_type": "markdown",
@@ -192,12 +196,14 @@
192196
"cell_type": "code",
193197
"outputs": [],
194198
"source": [
195-
"from utils.plot import plot_energy_heatmap, plot_energy_landscape\n",
199+
"from mat3ra.utils.jupyterlite.plot import plot_2d_heatmap, plot_3d_surface\n",
200+
"\n",
196201
"# Plot energy landscape\n",
197-
"plot_energy_heatmap(xy_matrix, energy_matrix, optimal_position=optimal_displacement[:2])\n",
202+
"x_values, y_values = xy_matrix\n",
203+
"plot_2d_heatmap(x_values, y_values, energy_matrix, optimal_displacement[:2])\n",
198204
"\n",
199205
"if SHOW_3D_LANDSCAPE:\n",
200-
" plot_energy_landscape(xy_matrix, energy_matrix, optimal_position=optimal_displacement[:2])\n",
206+
" plot_3d_surface(x_values, y_values, energy_matrix, optimal_displacement[:2])\n",
201207
"\n",
202208
"# Create optimized material\n",
203209
"optimized_material = interface_displace_part(\n",

0 commit comments

Comments
 (0)