Skip to content

Commit ac9eee3

Browse files
authored
Merge pull request #233 from Exabyte-io/feature/SOF-7676
feature/SOF-7676
2 parents 217d20f + c09a222 commit ac9eee3

30 files changed

+1508
-2183
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ celerybeat-schedule
8383

8484
# Environments
8585
.env
86-
.venv
86+
.venv*
8787
env/
8888
venv/
8989
ENV/

other/materials_designer/create_adatom_defect.ipynb

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,32 @@
4747
"id": "5e43ff288847b784"
4848
},
4949
{
50+
"metadata": {},
5051
"cell_type": "code",
5152
"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",
5257
"DEFECT_CONFIGS = [\n",
5358
" {\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",
6164
"]\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",
6268
"# Slab parameters\n",
6369
"MILLER_INDICES = (1, 1, 1) # Miller indices of the surface\n",
6470
"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."
6774
],
68-
"metadata": {
69-
"collapsed": false
70-
},
71-
"id": "9d8b1890b34d850a",
75+
"id": "b28e2fb6a4ea857f",
7276
"outputs": [],
7377
"execution_count": null
7478
},
@@ -142,24 +146,24 @@
142146
"cell_type": "code",
143147
"source": [
144148
"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",
146150
"from utils.visualize import visualize_materials as visualize\n",
147151
"\n",
148152
"material = materials[0]\n",
149153
"# Create analyzer to get terminations\n",
150154
"analyzer = CrystalLatticePlanesMaterialAnalyzer(material=material, miller_indices=MILLER_INDICES)\n",
151155
"slab_terminations = analyzer.terminations\n",
152156
"# 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",
155159
"\n",
156160
"slab = create_slab(\n",
157161
" crystal=material,\n",
158162
" termination=termination,\n",
159163
" 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",
163167
" use_orthogonal_c=True,\n",
164168
" use_conventional_cell=True\n",
165169
")\n",
@@ -172,50 +176,19 @@
172176
{
173177
"metadata": {},
174178
"cell_type": "markdown",
175-
"source": [
176-
"## 2. Create the Defect\n",
177-
"### 2.1. Set adatom parameters"
178-
],
179+
"source": "## 2. Create the Defect",
179180
"id": "b386c06587b2f843"
180181
},
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-
},
213182
{
214183
"cell_type": "code",
215184
"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",
217186
"\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+
")"
219192
],
220193
"metadata": {
221194
"collapsed": false
@@ -226,9 +199,7 @@
226199
},
227200
{
228201
"cell_type": "markdown",
229-
"source": [
230-
"## 3. Visualize the Slabs with Adatom"
231-
],
202+
"source": "## 3. Visualize the Slab with Adatom",
232203
"metadata": {
233204
"collapsed": false
234205
},
@@ -240,10 +211,12 @@
240211
"source": [
241212
"from utils.visualize import visualize_materials as visualize\n",
242213
"\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+
")"
247220
],
248221
"id": "256b07fb2dd39ae2",
249222
"outputs": [],

other/materials_designer/create_cluster_custom_shape.ipynb

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
"source": [
8383
"RADIUS = 0.3 # in crystal units\n",
8484
"VACUUM = 10.0 # in Angstroms on each side\n",
85-
"SUPERCELL_SIZE = 10 # in crystal units\n",
8685
"Z_ORIENTATION = (0, 0, 1) # Miller indices of the slab orientation along the z-axis for the cluster\n",
86+
"USE_CARTESIAN_COORDINATES = False\n",
8787
"NAME = \"Icosahedron\" # Name of the cluster"
8888
],
8989
"metadata": {
@@ -115,7 +115,7 @@
115115
"class CustomCoordinateCondition(CoordinateCondition):\n",
116116
" \"\"\"Creates a regular polyhedron shape using SciPy's ConvexHull\"\"\"\n",
117117
" radius: float = 1\n",
118-
" center: List[float] = [0.5, 0.5, 0.5]\n",
118+
" center_coordinate: List[float] = [0.5, 0.5, 0.5]\n",
119119
"\n",
120120
" @property\n",
121121
" def _hull_planes(self):\n",
@@ -129,12 +129,12 @@
129129
"\n",
130130
" def condition(self, coordinate: List[float]) -> bool:\n",
131131
" \"\"\"Returns True if point is inside the polyhedron\"\"\"\n",
132-
" point = np.array(coordinate) - self.center\n",
132+
" point = np.array(coordinate) - self.center_coordinate\n",
133133
" return all(np.dot(plane[:3], point) + plane[3] <= 0\n",
134134
" for plane in self._hull_planes)\n",
135135
"\n",
136136
" \n",
137-
"condition = CustomCoordinateCondition(radius=RADIUS).condition"
137+
"condition = CustomCoordinateCondition(radius=RADIUS)"
138138
],
139139
"metadata": {
140140
"collapsed": false
@@ -181,13 +181,9 @@
181181
{
182182
"cell_type": "code",
183183
"source": [
184-
"from mat3ra.made.tools.build.nanoparticle import SlabBasedNanoparticleConfiguration\n",
185-
"\n",
186-
"config = SlabBasedNanoparticleConfiguration(\n",
187-
" material=materials[0],\n",
188-
" condition_builder=condition,\n",
189-
" supercell_size=SUPERCELL_SIZE,\n",
190-
")"
184+
"from mat3ra.made.tools.build.nanoparticle.helpers import create_nanoparticle_from_material\n",
185+
"material = materials[0]\n",
186+
"cluster = create_nanoparticle_from_material(material=material,condition=condition, orientation_z=Z_ORIENTATION, vacuum_padding=VACUUM, use_cartesian_coordinates=USE_CARTESIAN_COORDINATES)"
191187
],
192188
"metadata": {
193189
"collapsed": false
@@ -196,58 +192,6 @@
196192
"outputs": [],
197193
"execution_count": null
198194
},
199-
{
200-
"cell_type": "markdown",
201-
"source": [
202-
"#### 2.2. Create the cluster"
203-
],
204-
"metadata": {
205-
"collapsed": false
206-
},
207-
"id": "10799f3efede924d"
208-
},
209-
{
210-
"cell_type": "code",
211-
"source": [
212-
"from mat3ra.made.tools.build.nanoparticle import create_nanoparticle\n",
213-
"\n",
214-
"cluster = create_nanoparticle(config)"
215-
],
216-
"metadata": {
217-
"collapsed": false
218-
},
219-
"id": "a990fa35742d7269",
220-
"outputs": [],
221-
"execution_count": null
222-
},
223-
{
224-
"cell_type": "markdown",
225-
"source": [
226-
"### 2.2. Set lattice to Cubic"
227-
],
228-
"metadata": {
229-
"collapsed": false
230-
},
231-
"id": "a01018588e6e55fc"
232-
},
233-
{
234-
"cell_type": "code",
235-
"source": [
236-
"from mat3ra.made.lattice import Lattice\n",
237-
"\n",
238-
"current_vector_1, current_vector_2, current_vector_3 = cluster.lattice.vectors\n",
239-
"cubic_vector_1 = [current_vector_1[0], 0, 0]\n",
240-
"cubic_vector_2 = [0, current_vector_2[1], 0]\n",
241-
"cubic_vector_3 = [0, 0, current_vector_3[2]]\n",
242-
"cluster.lattice = Lattice.from_vectors_array([cubic_vector_1, cubic_vector_2, cubic_vector_3], type=\"CUB\")"
243-
],
244-
"metadata": {
245-
"collapsed": false
246-
},
247-
"id": "4f78c4743b370c3b",
248-
"outputs": [],
249-
"execution_count": null
250-
},
251195
{
252196
"cell_type": "markdown",
253197
"source": [

0 commit comments

Comments
 (0)