Skip to content

Conversation

jinlhr542
Copy link
Contributor

@jinlhr542 jinlhr542 commented Sep 16, 2025

Summary

This pull request is to alllow for setting termination_ftol for film and substrate slabs separately.

The original CoherentInterfaceBuilder of the pymatgen.analysis.interface module has a parameter termination_ftol specifying the tolerance distance clustering different termination atomic planes according to their off-plane position. This value is applied for both the film and substrate slabs. However, since film and substrate have different structures, it is useful to allow for setting this value separately for film and substrate.

The test script is also updated.

@jinlhr542
Copy link
Contributor Author

@DanielYang59 Dear Daniel, could you please have a look at this PR?

Copy link
Contributor

@DanielYang59 DanielYang59 left a comment

Choose a reason for hiding this comment

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

Hi thanks for asking me, I'm not a maintainer so here is my personal opinions and you could decide on your own

@@ -43,7 +43,7 @@ def __init__(
film_miller (tuple[int, int, int]): miller index for the film layer
substrate_miller (tuple[int, int, int]): miller index for the substrate layer
zslgen (ZSLGenerator | None): BiDirectionalZSL if you want custom lattice matching tolerances for coherency.
termination_ftol (float): tolerance to distinguish different terminating atomic planes.
termination_ftol (float): tolerances (film, substrate) to distinguish different terminating atomic planes.
Copy link
Contributor

@DanielYang59 DanielYang59 Sep 17, 2025

Choose a reason for hiding this comment

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

I'm not very familiar with the use case of CoherentInterfaceBuilder but I assume it's reasonable to allow more fine-grained control over the film and substrate. In this case I guess: either you allow termination_ftol to be float | tuple[float, float] but you should update the docstring accordingly (currently it's still float), or you could deprecate this arg with two args like film/substrate_termination_tol.

@@ -133,24 +133,29 @@ def _find_terminations(self):
reorient_lattice=False, # This is necessary to not screw up the lattice
)

film_slabs = film_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs)
sub_slabs = sub_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs)
if type(self.termination_ftol) is not tuple:
Copy link
Contributor

Choose a reason for hiding this comment

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

should use isinstance here as type() is would only allow exact tuple but not subclasses

film_slabs = film_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs)
sub_slabs = sub_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs)
if type(self.termination_ftol) is not tuple:
self.termination_ftol = (self.termination_ftol, self.termination_ftol)
Copy link
Contributor

@DanielYang59 DanielYang59 Sep 17, 2025

Choose a reason for hiding this comment

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

I guess it's more readable to unpack within __init__ instead of accessing with index, something like:

if isinstance(termination_ftol, tuple):
    self.film_termination_ftol, self.substrate_termination_ftol = termination_ftol
else:
    self.film_termination_ftol = self.substrate_termination_ftol = termination_ftol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Daniel, many thanks for these helpful suggestions. I have commited these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants