@@ -317,33 +317,6 @@ def is_polar(self, tol_dipole_per_unit_area: float = 1e-3) -> bool:
317
317
dip_per_unit_area = self .dipole / self .surface_area
318
318
return np .linalg .norm (dip_per_unit_area ) > tol_dipole_per_unit_area
319
319
320
- def center_slab (self ) -> Slab :
321
- """Relocate the Slab region to the center.
322
-
323
- This makes it easier to find surface sites and apply
324
- operations like doping.
325
-
326
- TODO (@DanielYang59): need to check if the Slab is continuous
327
-
328
- Returns:
329
- Slab: The centered Slab.
330
- """
331
- # Calculate shift vector
332
- center_of_mass = np .average (
333
- self .frac_coords ,
334
- weights = [site .species .weight for site in self ],
335
- axis = 0 ,
336
- )
337
- shift = 0.5 - center_of_mass [2 ]
338
-
339
- # Move the slab to the center
340
- self .translate_sites (
341
- indices = list (range (len (self ))), # all sites
342
- vector = [0 , 0 , shift ],
343
- )
344
-
345
- return self
346
-
347
320
def get_slab_regions (
348
321
self ,
349
322
blength : float = 3.5 ,
@@ -826,23 +799,38 @@ def get_equi_sites(slab: Slab, sites: list[int]) -> list[int]:
826
799
warnings .warn ("Equivalent sites could not be found for some indices. Surface unchanged." )
827
800
828
801
829
- def center_slab (slab : Slab ) -> Slab :
802
+ def center_slab (slab : Structure ) -> Structure :
830
803
"""Relocate the Slab region to the center.
831
804
832
805
Deprecated, please use the center_slab method of Slab directly.
833
806
834
807
Args:
835
- slab (Slab ): The Slab to center.
808
+ slab (Structure ): The Slab to center.
836
809
837
810
Returns:
838
- Slab : The centered Slab.
811
+ Structure : The centered Slab.
839
812
"""
840
- warnings .warn ("Please use the center_slab method of Slab directly." , DeprecationWarning )
813
+ # Calculate shift vector
814
+ center_of_mass = np .average (
815
+ slab .frac_coords ,
816
+ weights = [site .species .weight for site in slab ],
817
+ axis = 0 ,
818
+ )
819
+ shift = 0.5 - center_of_mass [2 ]
820
+
821
+ # Move the slab to the center
822
+ slab .translate_sites (
823
+ indices = list (range (len (slab ))), # all sites
824
+ vector = [0 , 0 , shift ],
825
+ )
841
826
842
- return slab . center_slab ()
827
+ return slab
843
828
844
829
845
- def get_slab_regions (slab : Slab , blength : float = 3.5 ) -> list [tuple [float , float ]]:
830
+ def get_slab_regions (
831
+ slab : Slab ,
832
+ blength : float = 3.5 ,
833
+ ) -> list [tuple [float , float ]]:
846
834
"""Find the z-ranges for the slab region.
847
835
848
836
Deprecated, please use the get_slab_regions method of Slab directly.
0 commit comments