Skip to content

Slightly relax the constraint satisfy condition of get_primitive_structure() - #3285

Merged
janosh merged 4 commits into
materialsproject:masterfrom
fyalcin:master
Aug 31, 2023
Merged

Slightly relax the constraint satisfy condition of get_primitive_structure()#3285
janosh merged 4 commits into
materialsproject:masterfrom
fyalcin:master

Conversation

@fyalcin

@fyalcin fyalcin commented Aug 31, 2023

Copy link
Copy Markdown
Contributor

Summary

Context here. I finally took some time to figure out why this was happening and it turned out to be the check that compares the lattice parameters of the primitive structures found against the constraints. The equivalency check in the current implementation is too strict to account for small changes in the constraints, which is why I went with np.isclose() with its default atol and rtol parameters which should still be strict enough.

I also include two unit tests, one for a general get_primitive_structure() call with constrain_latt which was missing, and #another to ensure two very similar constraints result in the same primitive structure.

fyalcin and others added 4 commits August 31, 2023 11:03
…traint condition has been adjusted to a more flexible criterion. Instead of requiring an exact match, the evaluation now utilizes np.isclose() for comparison, which should still be strict enough with the default atol and rtol values.
…n the Structure class. The first test focuses on evaluating the method with a constrain_latt parameter, while the second ensures the consistency of the primitive structure when two very similar constraints are used.
…traint perturbations test_primitive_with_similar_constraints()

@janosh janosh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks @fyalcin! 👍

I added the test file you linked in https://matsci.org/t/41663 but forgot to upload and improved the tests slightly.

@janosh
janosh enabled auto-merge (squash) August 31, 2023 12:49
@janosh
janosh merged commit faa42db into materialsproject:master Aug 31, 2023
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