|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | | - "source": [], |
| 5 | + "id": "759c70b8d39addc3", |
6 | 6 | "metadata": { |
7 | 7 | "collapsed": false |
8 | 8 | }, |
9 | | - "id": "759c70b8d39addc3" |
| 9 | + "source": [] |
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "markdown", |
| 13 | + "id": "4f5cab1ebbbe954", |
| 14 | + "metadata": { |
| 15 | + "collapsed": false |
| 16 | + }, |
13 | 17 | "source": [ |
14 | 18 | "# Create Edge Passivation\n", |
15 | 19 | "Passivate material edges by detecting and adding passivants to undercoordinated atoms (atoms with fewer neighbors than bulk).\n", |
|
27 | 31 | "1. Coordination-based passivation finds atoms with fewer neighbors than expected\n", |
28 | 32 | "2. Coordination threshold below which passivation is applied, must be set depending on the material\n", |
29 | 33 | "3. Passivant atoms are placed along the direction away from existing bonds\n" |
30 | | - ], |
31 | | - "metadata": { |
32 | | - "collapsed": false |
33 | | - }, |
34 | | - "id": "4f5cab1ebbbe954" |
| 34 | + ] |
35 | 35 | }, |
36 | 36 | { |
37 | 37 | "metadata": {}, |
|
44 | 44 | "\n", |
45 | 45 | "<img src=\"https://github.com/Exabyte-io/documentation/raw/88451ce38b0f57f804dcb5010a1a95bb9b9e50bc/images/notebooks/coordination_based_passivation_settings.webp\" alt=\"Coordination search radius\" width=\"400\"/>" |
46 | 46 | ], |
47 | | - "id": "b25b42e8d3da9789" |
| 47 | + "id": "f63b28f159207878" |
48 | 48 | }, |
49 | 49 | { |
50 | 50 | "metadata": {}, |
51 | 51 | "cell_type": "code", |
| 52 | + "outputs": [], |
| 53 | + "execution_count": null, |
52 | 54 | "source": [ |
53 | 55 | "# Enable interactive selection of coordination threshold\n", |
54 | 56 | "IS_COORDINATION_SELECTION_INTERACTIVE = False\n", |
|
71 | 73 | "SHOW_INTERMEDIATE_STEPS = True\n", |
72 | 74 | "CELL_REPETITIONS_FOR_VISUALIZATION = [1, 1, 1] # Structure repeat in view" |
73 | 75 | ], |
74 | | - "id": "3b94d4e8623dd44f", |
75 | | - "outputs": [], |
76 | | - "execution_count": null |
| 76 | + "id": "7e8d8696bb1035e5" |
77 | 77 | }, |
78 | 78 | { |
79 | 79 | "cell_type": "markdown", |
80 | | - "source": [ |
81 | | - "### 1.2. Install packages\n", |
82 | | - "The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install`.\n" |
83 | | - ], |
| 80 | + "id": "975da798561ccde8", |
84 | 81 | "metadata": { |
85 | 82 | "collapsed": false |
86 | 83 | }, |
87 | | - "id": "975da798561ccde8" |
| 84 | + "source": [ |
| 85 | + "### 1.2. Install packages\n", |
| 86 | + "The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install`.\n" |
| 87 | + ] |
88 | 88 | }, |
89 | 89 | { |
90 | 90 | "cell_type": "code", |
| 91 | + "id": "4b010bef5b031158", |
| 92 | + "metadata": { |
| 93 | + "collapsed": false |
| 94 | + }, |
91 | 95 | "source": [ |
92 | 96 | "import sys\n", |
93 | 97 | "\n", |
|
99 | 103 | "\n", |
100 | 104 | " await install_packages(\"\")" |
101 | 105 | ], |
102 | | - "metadata": { |
103 | | - "collapsed": false |
104 | | - }, |
105 | | - "id": "4b010bef5b031158", |
106 | 106 | "outputs": [], |
107 | 107 | "execution_count": null |
108 | 108 | }, |
109 | 109 | { |
110 | 110 | "cell_type": "markdown", |
111 | | - "source": [ |
112 | | - "### 1.3. Load and preview input material\n" |
113 | | - ], |
| 111 | + "id": "7df321ca07e11daa", |
114 | 112 | "metadata": { |
115 | 113 | "collapsed": false |
116 | 114 | }, |
117 | | - "id": "7df321ca07e11daa" |
| 115 | + "source": [ |
| 116 | + "### 1.3. Load and preview input material\n" |
| 117 | + ] |
118 | 118 | }, |
119 | 119 | { |
120 | 120 | "cell_type": "code", |
| 121 | + "id": "3a53ff74253cb09a", |
| 122 | + "metadata": { |
| 123 | + "collapsed": false |
| 124 | + }, |
121 | 125 | "source": [ |
122 | 126 | "from utils.jupyterlite import get_materials\n", |
123 | 127 | "from utils.visualize import visualize_materials\n", |
|
130 | 134 | " visualize_materials(nanoribbon, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION)\n", |
131 | 135 | " visualize_materials(nanoribbon, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION, rotation=\"-90x\")" |
132 | 136 | ], |
133 | | - "metadata": { |
134 | | - "collapsed": false |
135 | | - }, |
136 | | - "id": "3a53ff74253cb09a", |
137 | 137 | "outputs": [], |
138 | 138 | "execution_count": null |
139 | 139 | }, |
140 | 140 | { |
141 | 141 | "cell_type": "markdown", |
142 | | - "source": [ |
143 | | - "## 2. Analyze Coordination Numbers and Select Threshold\n", |
144 | | - "### 2.1. Plot RDF to estimate coordination search radius" |
145 | | - ], |
| 142 | + "id": "b5940fc50c11c7b8", |
146 | 143 | "metadata": { |
147 | 144 | "collapsed": false |
148 | 145 | }, |
149 | | - "id": "b5940fc50c11c7b8" |
| 146 | + "source": [ |
| 147 | + "## 2. Analyze Coordination Numbers and Select Threshold\n", |
| 148 | + "### 2.1. Plot RDF to estimate coordination search radius" |
| 149 | + ] |
150 | 150 | }, |
151 | 151 | { |
152 | 152 | "cell_type": "code", |
| 153 | + "id": "575e8fba623c06e4", |
| 154 | + "metadata": { |
| 155 | + "collapsed": false |
| 156 | + }, |
153 | 157 | "source": [ |
154 | 158 | "from utils.plot import plot_rdf\n", |
155 | 159 | "\n", |
156 | 160 | "plot_rdf(nanoribbon, cutoff=10.0)" |
157 | 161 | ], |
158 | | - "metadata": { |
159 | | - "collapsed": false |
160 | | - }, |
161 | | - "id": "575e8fba623c06e4", |
162 | 162 | "outputs": [], |
163 | 163 | "execution_count": null |
164 | 164 | }, |
165 | 165 | { |
166 | 166 | "cell_type": "markdown", |
167 | | - "source": [ |
168 | | - "### 2.2. GEt coordination numbers and set coordination threshold" |
169 | | - ], |
| 167 | + "id": "b89dc754926f1ce4", |
170 | 168 | "metadata": { |
171 | 169 | "collapsed": false |
172 | 170 | }, |
173 | | - "id": "b89dc754926f1ce4" |
| 171 | + "source": [ |
| 172 | + "### 2.2. Get coordination numbers and set coordination threshold" |
| 173 | + ] |
174 | 174 | }, |
175 | 175 | { |
176 | 176 | "cell_type": "code", |
| 177 | + "id": "54c265d8ca9408af", |
| 178 | + "metadata": { |
| 179 | + "collapsed": false |
| 180 | + }, |
177 | 181 | "source": [ |
178 | 182 | "from utils.io import select_coordination_threshold\n", |
179 | | - "from mat3ra.made.tools.build.passivation import get_unique_coordination_numbers, PassivationConfiguration\n", |
| 183 | + "from mat3ra.made.tools.build.passivation import get_unique_coordination_numbers, PassivationConfiguration, \\\n", |
| 184 | + " get_coordination_numbers_distribution\n", |
180 | 185 | "\n", |
| 186 | + "coordination_search_radius = None # Change this value according to the RDF plot if needed, Angstroms.\n", |
181 | 187 | "config = PassivationConfiguration(\n", |
182 | 188 | " slab=nanoribbon,\n", |
183 | 189 | " passivant=PASSIVANT,\n", |
184 | 190 | " bond_length=BOND_LENGTH\n", |
185 | 191 | ")\n", |
186 | | - "coordination_numbers = get_unique_coordination_numbers(config, cutoff=COORDINATION_SEARCH_RADIUS)\n", |
| 192 | + "coordination_numbers = get_unique_coordination_numbers(\n", |
| 193 | + " configuration=config,\n", |
| 194 | + " cutoff=coordination_search_radius or COORDINATION_SEARCH_RADIUS\n", |
| 195 | + ")\n", |
187 | 196 | "print(f\"Unique coordination numbers: {coordination_numbers}\")\n", |
188 | 197 | "\n", |
| 198 | + "cn_distribution = get_coordination_numbers_distribution(\n", |
| 199 | + " configuration=config,\n", |
| 200 | + " cutoff=coordination_search_radius or COORDINATION_SEARCH_RADIUS\n", |
| 201 | + ")\n", |
| 202 | + "print(f\"Coordination numbers distribution: {cn_distribution}\")\n", |
189 | 203 | "coordination_threshold = COORDINATION_THRESHOLD\n", |
190 | 204 | "if IS_COORDINATION_SELECTION_INTERACTIVE:\n", |
191 | 205 | " coordination_threshold = await select_coordination_threshold(\n", |
192 | | - " coordination_numbers, COORDINATION_THRESHOLD\n", |
| 206 | + " cn_distribution, COORDINATION_THRESHOLD\n", |
193 | 207 | " )\n", |
194 | 208 | "\n", |
195 | 209 | "print(f\"\\nSelected coordination threshold: {coordination_threshold}\")\n", |
196 | | - "print(f\"Atoms with coordination < {coordination_threshold} will be passivated\")" |
| 210 | + "print(f\"Atoms with coordination <= {coordination_threshold} will be passivated\")" |
197 | 211 | ], |
198 | | - "metadata": { |
199 | | - "collapsed": false |
200 | | - }, |
201 | | - "id": "54c265d8ca9408af", |
202 | 212 | "outputs": [], |
203 | 213 | "execution_count": null |
204 | 214 | }, |
205 | 215 | { |
206 | 216 | "cell_type": "markdown", |
207 | | - "source": [ |
208 | | - "## 3. Create target material\n", |
209 | | - "### 3.1. Set up passivation configuration and builder\n" |
210 | | - ], |
| 217 | + "id": "b873d2cb6eaa2bdb", |
211 | 218 | "metadata": { |
212 | 219 | "collapsed": false |
213 | 220 | }, |
214 | | - "id": "b873d2cb6eaa2bdb" |
| 221 | + "source": [ |
| 222 | + "## 3. Create target material\n", |
| 223 | + "### 3.1. Set up passivation configuration and builder\n" |
| 224 | + ] |
215 | 225 | }, |
216 | 226 | { |
217 | 227 | "cell_type": "code", |
| 228 | + "id": "aca1c76a52e5376a", |
| 229 | + "metadata": { |
| 230 | + "collapsed": false |
| 231 | + }, |
218 | 232 | "source": [ |
219 | 233 | "from mat3ra.made.tools.build.passivation.builders import CoordinationBasedPassivationBuilder, \\\n", |
220 | 234 | " CoordinationBasedPassivationBuilderParameters\n", |
|
228 | 242 | "\n", |
229 | 243 | "builder = CoordinationBasedPassivationBuilder(build_parameters=builder_params)" |
230 | 244 | ], |
231 | | - "metadata": { |
232 | | - "collapsed": false |
233 | | - }, |
234 | | - "id": "aca1c76a52e5376a", |
235 | 245 | "outputs": [], |
236 | 246 | "execution_count": null |
237 | 247 | }, |
238 | 248 | { |
239 | 249 | "cell_type": "markdown", |
240 | | - "source": [ |
241 | | - "### 3.2. Generate passivated structure\n" |
242 | | - ], |
| 250 | + "id": "e40b5f67ef5b54aa", |
243 | 251 | "metadata": { |
244 | 252 | "collapsed": false |
245 | 253 | }, |
246 | | - "id": "e40b5f67ef5b54aa" |
| 254 | + "source": [ |
| 255 | + "### 3.2. Generate passivated structure\n" |
| 256 | + ] |
247 | 257 | }, |
248 | 258 | { |
249 | 259 | "cell_type": "code", |
| 260 | + "id": "3c36dc3654f544c1", |
| 261 | + "metadata": { |
| 262 | + "collapsed": false |
| 263 | + }, |
250 | 264 | "source": [ |
251 | 265 | "from mat3ra.made.tools.build.passivation import create_passivation\n", |
252 | 266 | "\n", |
|
258 | 272 | "print(f\"Original atoms: {len(nanoribbon.basis.elements.ids)}\")\n", |
259 | 273 | "print(f\"Final atoms: {len(passivated_nanoribbon.basis.elements.ids)}\")" |
260 | 274 | ], |
261 | | - "metadata": { |
262 | | - "collapsed": false |
263 | | - }, |
264 | | - "id": "3c36dc3654f544c1", |
265 | 275 | "outputs": [], |
266 | 276 | "execution_count": null |
267 | 277 | }, |
268 | 278 | { |
269 | 279 | "cell_type": "markdown", |
270 | | - "source": [ |
271 | | - "## 4. Visualize the result" |
272 | | - ], |
| 280 | + "id": "ad96b86aef8b28f5", |
273 | 281 | "metadata": { |
274 | 282 | "collapsed": false |
275 | 283 | }, |
276 | | - "id": "ad96b86aef8b28f5" |
| 284 | + "source": [ |
| 285 | + "## 4. Visualize the result" |
| 286 | + ] |
277 | 287 | }, |
278 | 288 | { |
279 | 289 | "cell_type": "code", |
| 290 | + "id": "d08ff21e3650ba5d", |
| 291 | + "metadata": { |
| 292 | + "collapsed": false |
| 293 | + }, |
280 | 294 | "source": [ |
281 | 295 | "print(\"Final passivated structure:\")\n", |
282 | 296 | "visualize_materials(passivated_nanoribbon, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION)\n", |
283 | 297 | "visualize_materials(passivated_nanoribbon, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION, rotation=\"-90x\")" |
284 | 298 | ], |
285 | | - "metadata": { |
286 | | - "collapsed": false |
287 | | - }, |
288 | | - "id": "d08ff21e3650ba5d", |
289 | 299 | "outputs": [], |
290 | 300 | "execution_count": null |
291 | 301 | }, |
292 | 302 | { |
293 | 303 | "cell_type": "markdown", |
294 | | - "source": [ |
295 | | - "## 5. Pass data to the outside runtime\n" |
296 | | - ], |
| 304 | + "id": "7151e48eae3b1886", |
297 | 305 | "metadata": { |
298 | 306 | "collapsed": false |
299 | 307 | }, |
300 | | - "id": "7151e48eae3b1886" |
| 308 | + "source": [ |
| 309 | + "## 5. Pass data to the outside runtime\n" |
| 310 | + ] |
301 | 311 | }, |
302 | 312 | { |
303 | 313 | "cell_type": "code", |
| 314 | + "id": "2d69736d0c71858c", |
| 315 | + "metadata": { |
| 316 | + "collapsed": false |
| 317 | + }, |
304 | 318 | "source": [ |
305 | 319 | "from utils.jupyterlite import set_materials\n", |
306 | 320 | "\n", |
307 | 321 | "passivated_nanoribbon.name = f\"{nanoribbon.name} passivated\"\n", |
308 | 322 | "set_materials(passivated_nanoribbon)" |
309 | 323 | ], |
310 | | - "metadata": { |
311 | | - "collapsed": false |
312 | | - }, |
313 | | - "id": "2d69736d0c71858c", |
314 | 324 | "outputs": [], |
315 | 325 | "execution_count": null |
316 | 326 | } |
|
0 commit comments