Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Structure.interpolate to extrapolate #3467

Merged
merged 9 commits into from
Nov 29, 2023
7 changes: 5 additions & 2 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,7 @@ def interpolate(
interpolate_lattices: bool = False,
pbc: bool = True,
autosort_tol: float = 0,
extrapolation: float = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for this new keyword?

) -> list[IStructure | Structure]:
"""Interpolate between this structure and end_structure. Useful for
construction of NEB inputs.
Expand All @@ -2157,6 +2158,8 @@ def interpolate(
closest points in this particular structure. This is usually
what you want in a NEB calculation. 0 implies no sorting.
Otherwise, a 0.5 value usually works pretty well.
extrapolation (float): A fractional amount by which to extend the
interpolation beyond the end_structure

Returns:
List of interpolated structures. The starting and ending
Expand Down Expand Up @@ -2212,7 +2215,7 @@ def interpolate(

end_coords = sorted_end_coords

vec = end_coords - start_coords
vec = (1 + extrapolation) * (end_coords - start_coords)
if pbc:
vec[:, self.pbc] -= np.round(vec[:, self.pbc])
sp = self.species_and_occu
Expand All @@ -2222,7 +2225,7 @@ def interpolate(
# interpolate lattice matrices using polar decomposition
# u is a unitary rotation, p is stretch
u, p = polar(np.dot(end_structure.lattice.matrix.T, np.linalg.inv(self.lattice.matrix.T)))
lvec = p - np.identity(3)
lvec = (1 + extrapolation) * (p - np.identity(3))
lstart = self.lattice.matrix.T

for x in images:
Expand Down