Skip to content

Commit

Permalink
revert shift to termination rename
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed May 18, 2024
1 parent e38efdb commit ba4f83a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
8 changes: 4 additions & 4 deletions pymatgen/analysis/interfaces/coherent_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def _find_matches(self) -> None:
reorient_lattice=False, # This is necessary to not screw up the lattice
)

film_slab = film_sg.get_slab(termination=0)
sub_slab = sub_sg.get_slab(termination=0)
film_slab = film_sg.get_slab(shift=0)
sub_slab = sub_sg.get_slab(shift=0)

film_vectors = film_slab.lattice.matrix
substrate_vectors = sub_slab.lattice.matrix
Expand Down Expand Up @@ -194,8 +194,8 @@ def get_interfaces(

film_shift, sub_shift = self._terminations[termination]

film_slab = film_sg.get_slab(termination=film_shift)
sub_slab = sub_sg.get_slab(termination=sub_shift)
film_slab = film_sg.get_slab(shift=film_shift)
sub_slab = sub_sg.get_slab(shift=sub_shift)

for match in self.zsl_matches:
# Build film superlattice
Expand Down
24 changes: 8 additions & 16 deletions pymatgen/core/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,32 +1068,24 @@ def calculate_scaling_factor() -> np.ndarray:

def get_slab(
self,
termination: float = 0,
shift: float = 0,
tol: float = 0.1,
energy: float | None = None,
shift: float | None = None, # TODO: remove after 2025-05-13
) -> Slab:
"""[Private method] Generate a slab based on a given termination coordinate
along the lattice c direction.
"""[Private method] Generate a slab based on a given termination
coordinate along the lattice c direction.
You should NOT use this method directly.
You should RARELY use this method directly.
Args:
termination (float): The coordinate along the lattice c
shift (float): The termination coordinate along the lattice c
direction in fractional coordinates.
tol (float): Tolerance to determine primitive cell.
energy (float): The energy to assign to the slab.
shift (float): Deprecated, confusing. The termination coordinate
along the lattice c direction in fractional coordinates.
Returns:
Slab: from a shifted oriented unit cell.
"""
# Check for usage of deprecated arg "shift"
if shift is not None:
termination = shift
warnings.warn("shift is deprecated in get_slab, please use termination.")

# Calculate total number of layers
height = self._proj_height
height_per_layer = round(height / self.parent.lattice.d_hkl(self.miller_index), 8)
Expand All @@ -1115,7 +1107,7 @@ def get_slab(

# Shift all atoms to the termination
frac_coords = self.oriented_unit_cell.frac_coords
frac_coords = np.array(frac_coords) + np.array([0, 0, -termination])[None, :]
frac_coords = np.array(frac_coords) + np.array([0, 0, -shift])[None, :]
frac_coords -= np.floor(frac_coords) # wrap to the [0, 1) range

# Scale down z-coordinate by the number of layers
Expand Down Expand Up @@ -1185,7 +1177,7 @@ def get_slab(
struct.frac_coords,
self.miller_index,
ouc,
termination,
shift,
scale_factor,
reorient_lattice=self.reorient_lattice,
site_properties=struct.site_properties,
Expand Down Expand Up @@ -1336,7 +1328,7 @@ def get_z_ranges(
# As per the docstring this is to sort final Slabs by number
# of bonds broken, but this may very likely lead to errors
# if the "energy" is used literally (Maybe reset energy to None?)
slab = self.get_slab(termination=termination, tol=tol, energy=bonds_broken)
slab = self.get_slab(shift=termination, tol=tol, energy=bonds_broken)

if bonds_broken <= max_broken_bonds:
slabs.append(slab)
Expand Down

0 comments on commit ba4f83a

Please sign in to comment.