|
9 | 9 | "\n", |
10 | 10 | "<h2 style=\"color:green\">Usage</h2>\n", |
11 | 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. Set defects parameters in cell 2.1. (or use default).\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) -- to create multiple defects, fill `DEFECT_CONFIGS` with a list of dictionaries. \n", |
15 | 14 | "1. Click “Run” > “Run All” to run all cells. \n", |
16 | | - "1. Wait for the run to complete (depending on the parameters can take a few min). \n", |
17 | 15 | "1. Scroll down to view results. \n", |
18 | 16 | "\n", |
19 | | - "## Summary\n", |
20 | | - "1. Prepare the Environment: Set up the notebook and install packages, preview the input materials\n", |
21 | | - "1. Create the Defect: Add a vacancy defect to the bulk structure\n", |
22 | | - "2. Visualize the Defect: Visualize the defect structure\n", |
23 | | - "\n", |
24 | 17 | "## Notes\n", |
25 | 18 | "\n", |
26 | 19 | "1. For more information, see [Introduction](Introduction.ipynb)\n", |
|
35 | 28 | "cell_type": "markdown", |
36 | 29 | "source": [ |
37 | 30 | "## 1. Prepare the Environment\n", |
38 | | - "### 1.1. Set up defect parameters " |
| 31 | + "### 1.1. Set up defects parameters \n", |
| 32 | + "Defect Configuration parameters are described in [Defect Configuration](https://github.com/Exabyte-io/made/blob/8196b759242551c77d1791bf5bd2f4150763cfef/src/py/mat3ra/made/tools/build/defect/configuration.py#L102)." |
39 | 33 | ], |
40 | 34 | "metadata": { |
41 | 35 | "collapsed": false |
|
47 | 41 | "outputs": [], |
48 | 42 | "source": [ |
49 | 43 | "DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n", |
50 | | - "SITE_ID = 0 # Site index of the defect\n", |
51 | | - "POSITION = [0, 0.0, 0.0] # Position of the defect in crystal coordinates\n", |
52 | | - "CHEMICAL_ELEMENT = \"Cu\" # Element to be placed at the site (ignored for vacancy)\n", |
53 | | - "SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]] " |
| 44 | + "SITE_ID = None # Site index of the defect\n", |
| 45 | + "COORDINATE = None # Position of the defect in crystal coordinates\n", |
| 46 | + "APPROXIMATE_COORDINATE = None # Approximate coordinates of the defect in crystal coordinates\n", |
| 47 | + "CHEMICAL_ELEMENT = \"C\" # Element to be placed at the site (ignored for vacancy)\n", |
| 48 | + "\n", |
| 49 | + "SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n", |
| 50 | + "\n", |
| 51 | + "# List of dictionaries with defect parameters\n", |
| 52 | + "DEFECT_CONFIGS = [\n", |
| 53 | + " {\n", |
| 54 | + " \"defect_type\": DEFECT_TYPE,\n", |
| 55 | + " \"approximate_coordinate\": [0.0, 0.0, 0.0],\n", |
| 56 | + " \"chemical_element\": \"C\",\n", |
| 57 | + " # \"site_id\": 0,\n", |
| 58 | + " # \"coordinate\": None,\n", |
| 59 | + " },\n", |
| 60 | + " # Uncomment the following to create multiple defects\n", |
| 61 | + " # {\n", |
| 62 | + " # \"defect_type\": \"vacancy\",\n", |
| 63 | + " # \"site_id\": 0,\n", |
| 64 | + " # },\n", |
| 65 | + "]" |
54 | 66 | ], |
55 | 67 | "metadata": { |
56 | 68 | "collapsed": false |
|
77 | 89 | "\n", |
78 | 90 | "if sys.platform == \"emscripten\":\n", |
79 | 91 | " import micropip\n", |
| 92 | + "\n", |
80 | 93 | " await micropip.install('mat3ra-api-examples', deps=False)\n", |
81 | 94 | " from utils.jupyterlite import install_packages\n", |
| 95 | + "\n", |
82 | 96 | " await install_packages(\"create_point_defect.ipynb\", \"../../config.yml\")" |
83 | 97 | ], |
84 | 98 | "metadata": { |
|
103 | 117 | "outputs": [], |
104 | 118 | "source": [ |
105 | 119 | "from utils.jupyterlite import get_materials\n", |
| 120 | + "\n", |
106 | 121 | "materials = get_materials(globals())" |
107 | 122 | ], |
108 | 123 | "metadata": { |
|
142 | 157 | "cell_type": "markdown", |
143 | 158 | "source": [ |
144 | 159 | "## 2. Create the Defect\n", |
145 | | - "### 2.1. Set defect parameters" |
| 160 | + "### 2.1. Initialize Configuration and Builder parameters" |
146 | 161 | ], |
147 | 162 | "metadata": { |
148 | 163 | "collapsed": false |
|
156 | 171 | "from mat3ra.made.tools.build.defect import PointDefectConfiguration\n", |
157 | 172 | "from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n", |
158 | 173 | "\n", |
159 | | - "defect_configuration_with_site_id = PointDefectConfiguration.from_site_id(crystal=supercell, defect_type=DEFECT_TYPE, site_id=SITE_ID, chemical_element=CHEMICAL_ELEMENT)\n", |
160 | | - "defect_configuration_with_position = PointDefectConfiguration(crystal=supercell, defect_type=\"interstitial\", position=POSITION, chemical_element=CHEMICAL_ELEMENT)\n", |
| 174 | + "defect_configurations = [PointDefectConfiguration.from_dict(supercell, defect) for defect in DEFECT_CONFIGS]\n", |
161 | 175 | "\n", |
162 | 176 | "defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)" |
163 | 177 | ], |
|
181 | 195 | "cell_type": "code", |
182 | 196 | "outputs": [], |
183 | 197 | "source": [ |
184 | | - "from mat3ra.made.tools.build.defect import create_defect\n", |
| 198 | + "from mat3ra.made.tools.build.defect import create_defects\n", |
185 | 199 | "\n", |
186 | | - "material_with_defect_at_site_id = create_defect(builder_parameters=defect_builder_parameters, configuration=defect_configuration_with_site_id)\n", |
187 | | - "material_with_defect_at_position = create_defect(builder_parameters=defect_builder_parameters, configuration=defect_configuration_with_position)" |
| 200 | + "material_with_defect = create_defects(builder_parameters=defect_builder_parameters, configurations=defect_configurations)" |
188 | 201 | ], |
189 | 202 | "metadata": { |
190 | 203 | "collapsed": false |
|
195 | 208 | { |
196 | 209 | "cell_type": "markdown", |
197 | 210 | "source": [ |
198 | | - "## 3. Visualize the Defects" |
| 211 | + "## 3. Visualize Result(s)" |
199 | 212 | ], |
200 | 213 | "metadata": { |
201 | 214 | "collapsed": false |
|
209 | 222 | "from utils.visualize import visualize_materials as visualize\n", |
210 | 223 | "\n", |
211 | 224 | "visualize([{\"material\": supercell, \"title\": \"Original material\"},\n", |
212 | | - " {\"material\": material_with_defect_at_site_id, \"title\": f\"Material with defect at site_id={SITE_ID}\"},\n", |
213 | | - " {\"material\": material_with_defect_at_position, \"title\": f\"Material with defect at position={POSITION}\"}],\n", |
214 | | - " rotation=\"-90x\")" |
| 225 | + " {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n", |
| 226 | + " rotation=\"-90x\")\n", |
| 227 | + "visualize([{\"material\": supercell, \"title\": \"Original material\"},\n", |
| 228 | + " {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])" |
215 | 229 | ], |
216 | 230 | "metadata": { |
217 | 231 | "collapsed": false |
|
235 | 249 | "source": [ |
236 | 250 | "from utils.jupyterlite import set_materials\n", |
237 | 251 | "\n", |
238 | | - "set_materials([material_with_defect_at_site_id, material_with_defect_at_position])" |
| 252 | + "set_materials([material_with_defect])" |
239 | 253 | ], |
240 | 254 | "metadata": { |
241 | 255 | "collapsed": false |
|
0 commit comments