|
47 | 47 | "id": "5e43ff288847b784"
|
48 | 48 | },
|
49 | 49 | {
|
| 50 | + "metadata": {}, |
50 | 51 | "cell_type": "code",
|
51 | 52 | "source": [
|
| 53 | + "from mat3ra.made.tools.build.defect.enums import AdatomPlacementMethodEnum\n", |
| 54 | + "from mat3ra.made.tools.build.slab.termination_utils import select_slab_termination\n", |
| 55 | + "\n", |
| 56 | + "ELEMENT = \"Si\" # Chemical element of the adatom\n", |
52 | 57 | "DEFECT_CONFIGS = [\n",
|
53 | 58 | " {\n",
|
54 |
| - " \"defect_type\": \"adatom\",\n", |
55 |
| - " \"placement_method\": \"equidistant\",\n", |
56 |
| - " \"chemical_element\": \"Si\",\n", |
57 |
| - " \"position_on_surface\": [0.5, 0.5],\n", |
58 |
| - " \"distance_z\": 2.0,\n", |
59 |
| - " \"use_cartesian_coordinates\": False\n", |
60 |
| - " },\n", |
| 59 | + " \"type\": \"adatom\",\n", |
| 60 | + " \"coordinate\": [0.5, 0.5], # Crystal coordinates on the surface (x, y)\n", |
| 61 | + " \"distance_z\": 1.0, # Method to place the adatom\n", |
| 62 | + " \"element\": ELEMENT,\n", |
| 63 | + " }\n", |
61 | 64 | "]\n",
|
| 65 | + "PLACEMENT_METHOD = AdatomPlacementMethodEnum.NEW_CRYSTAL_SITE # Method to place the adatom, e.g., \"NEW_CRYSTAL_SITE\", \"EQUIDISTANT\", \"EXACT_COORDINATE\"\n", |
| 66 | + "\n", |
| 67 | + "\n", |
62 | 68 | "# Slab parameters\n",
|
63 | 69 | "MILLER_INDICES = (1, 1, 1) # Miller indices of the surface\n",
|
64 | 70 | "SLAB_THICKNESS = 3 # Thickness of the slab in unit cells\n",
|
65 |
| - "VACUUM = 6 # Vacuum thickness in Angstrom\n", |
66 |
| - "SUPERCELL_MATRIX = [[2, 0, 0], [0, 2, 0], [0, 0, 1]] # Supercell matrix for the slab" |
| 71 | + "VACUUM = 5.0 # Vacuum thickness in Angstrom\n", |
| 72 | + "XY_SUPERCELL_MATRIX = [[2, 0], [0, 2]] # Supercell matrix for the slab\n", |
| 73 | + "TERMINATION_FORMULA = None # Stoichiometric formula of the slab termination to be used." |
67 | 74 | ],
|
68 |
| - "metadata": { |
69 |
| - "collapsed": false |
70 |
| - }, |
71 |
| - "id": "9d8b1890b34d850a", |
| 75 | + "id": "b28e2fb6a4ea857f", |
72 | 76 | "outputs": [],
|
73 | 77 | "execution_count": null
|
74 | 78 | },
|
|
142 | 146 | "cell_type": "code",
|
143 | 147 | "source": [
|
144 | 148 | "from mat3ra.made.tools.analyze.lattice_planes import CrystalLatticePlanesMaterialAnalyzer\n",
|
145 |
| - "from mat3ra.made.tools.build.slab.helpers import create_slab\n", |
| 149 | + "from mat3ra.made.tools.build.slab.helpers import create_slab, get_slab_terminations\n", |
146 | 150 | "from utils.visualize import visualize_materials as visualize\n",
|
147 | 151 | "\n",
|
148 | 152 | "material = materials[0]\n",
|
149 | 153 | "# Create analyzer to get terminations\n",
|
150 | 154 | "analyzer = CrystalLatticePlanesMaterialAnalyzer(material=material, miller_indices=MILLER_INDICES)\n",
|
151 | 155 | "slab_terminations = analyzer.terminations\n",
|
152 | 156 | "# Get termination from analyzer\n",
|
153 |
| - "terminations = analyzer.terminations\n", |
154 |
| - "termination = terminations[0] # Use first termination\n", |
| 157 | + "terminations = get_slab_terminations(material, MILLER_INDICES)\n", |
| 158 | + "termination = select_slab_termination(terminations, TERMINATION_FORMULA)\n", |
155 | 159 | "\n",
|
156 | 160 | "slab = create_slab(\n",
|
157 | 161 | " crystal=material,\n",
|
158 | 162 | " termination=termination,\n",
|
159 | 163 | " miller_indices=MILLER_INDICES,\n",
|
160 |
| - " number_of_layers=1,\n", |
161 |
| - " vacuum=0,\n", |
162 |
| - " xy_supercell_matrix=[[1, 0], [0, 1]],\n", |
| 164 | + " number_of_layers=SLAB_THICKNESS,\n", |
| 165 | + " vacuum=VACUUM,\n", |
| 166 | + " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", |
163 | 167 | " use_orthogonal_c=True,\n",
|
164 | 168 | " use_conventional_cell=True\n",
|
165 | 169 | ")\n",
|
|
172 | 176 | {
|
173 | 177 | "metadata": {},
|
174 | 178 | "cell_type": "markdown",
|
175 |
| - "source": [ |
176 |
| - "## 2. Create the Defect\n", |
177 |
| - "### 2.1. Set adatom parameters" |
178 |
| - ], |
| 179 | + "source": "## 2. Create the Defect", |
179 | 180 | "id": "b386c06587b2f843"
|
180 | 181 | },
|
181 |
| - { |
182 |
| - "metadata": {}, |
183 |
| - "cell_type": "code", |
184 |
| - "source": [ |
185 |
| - "from mat3ra.made.tools.build.defect import AdatomSlabPointDefectConfiguration\n", |
186 |
| - "\n", |
187 |
| - "defect_configurations = [\n", |
188 |
| - " AdatomSlabPointDefectConfiguration(\n", |
189 |
| - " crystal=slab,\n", |
190 |
| - " defect_type=defect[\"defect_type\"],\n", |
191 |
| - " placement_method=defect[\"placement_method\"],\n", |
192 |
| - " chemical_element=defect[\"chemical_element\"],\n", |
193 |
| - " position_on_surface=defect[\"position_on_surface\"],\n", |
194 |
| - " distance_z=defect[\"distance_z\"],\n", |
195 |
| - " use_cartesian_coordinates=defect[\"use_cartesian_coordinates\"]\n", |
196 |
| - " ) for defect in DEFECT_CONFIGS\n", |
197 |
| - "]" |
198 |
| - ], |
199 |
| - "id": "3727ba76ad5101c0", |
200 |
| - "outputs": [], |
201 |
| - "execution_count": null |
202 |
| - }, |
203 |
| - { |
204 |
| - "cell_type": "markdown", |
205 |
| - "source": [ |
206 |
| - "### 2.2. Create the adatom" |
207 |
| - ], |
208 |
| - "metadata": { |
209 |
| - "collapsed": false |
210 |
| - }, |
211 |
| - "id": "489b51f0ee122c48" |
212 |
| - }, |
213 | 182 | {
|
214 | 183 | "cell_type": "code",
|
215 | 184 | "source": [
|
216 |
| - "from mat3ra.made.tools.build.defect import create_defects\n", |
| 185 | + "from mat3ra.made.tools.build.defect.adatom.helpers import create_multiple_adatom_defects\n", |
217 | 186 | "\n",
|
218 |
| - "slab_with_adatom = create_defects(defect_configurations)" |
| 187 | + "slab_with_adatom = create_multiple_adatom_defects(\n", |
| 188 | + " slab=slab,\n", |
| 189 | + " defect_dicts=DEFECT_CONFIGS,\n", |
| 190 | + " placement_method=PLACEMENT_METHOD.value,\n", |
| 191 | + ")" |
219 | 192 | ],
|
220 | 193 | "metadata": {
|
221 | 194 | "collapsed": false
|
|
226 | 199 | },
|
227 | 200 | {
|
228 | 201 | "cell_type": "markdown",
|
229 |
| - "source": [ |
230 |
| - "## 3. Visualize the Slabs with Adatom" |
231 |
| - ], |
| 202 | + "source": "## 3. Visualize the Slab with Adatom", |
232 | 203 | "metadata": {
|
233 | 204 | "collapsed": false
|
234 | 205 | },
|
|
240 | 211 | "source": [
|
241 | 212 | "from utils.visualize import visualize_materials as visualize\n",
|
242 | 213 | "\n",
|
243 |
| - "visualize([{\"material\": slab, \"title\": \"Original material\"},\n", |
244 |
| - " {\"material\": slab_with_adatom, \"title\": f\"Material with adatom defects\"}],\n", |
245 |
| - " viewer=\"wave\"\n", |
246 |
| - " )" |
| 214 | + "visualize([\n", |
| 215 | + " {\"material\": slab, \"title\": \"Original material\"},\n", |
| 216 | + " {\"material\": slab_with_adatom, \"title\": f\"Material with adatom defects\"}\n", |
| 217 | + "],\n", |
| 218 | + " viewer=\"wave\"\n", |
| 219 | + ")" |
247 | 220 | ],
|
248 | 221 | "id": "256b07fb2dd39ae2",
|
249 | 222 | "outputs": [],
|
|
0 commit comments