Skip to content

Commit

Permalink
Merge branch 'feature/SOF-7426' into feature/SOF-7427
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Sep 2, 2024
2 parents cf6244c + 5758116 commit 51e3e87
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/py/unit/test_tools_modify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ase.build import bulk
from mat3ra.made.material import Material
from mat3ra.made.tools.analyze import get_optimal_displacements
from mat3ra.made.tools.convert import from_ase
from mat3ra.made.tools.convert.utils import InterfacePartsEnum
from mat3ra.made.tools.modify import (
Expand Down Expand Up @@ -187,3 +188,21 @@ def test_displace_interface():
displaced_material = displace_interface(material, [0.1, 0.2, 0.3], InterfacePartsEnum.FILM)
assertion_utils.assert_deep_almost_equal(expected_coordinates, displaced_material.basis.coordinates.to_dict())
assertion_utils.assert_deep_almost_equal(expected_labels, displaced_material.basis.labels.to_dict())


def test_displace_interface_optimized():
material = Material(GRAPHENE_NICKEL_INTERFACE)
expected_coordinates = [
{"id": 0, "value": [0.666666667, 0.666666667, 0.350869517]},
{"id": 1, "value": [0.0, 0.0, 0.425701769]},
{"id": 2, "value": [0.333333333, 0.333333333, 0.500534021]},
{"id": 3, "value": [0.186859257, 0.17806738, 0.611447347]},
{"id": 4, "value": [0.520192591, 0.511400714, 0.611447347]},
]
expected_labels = GRAPHENE_NICKEL_INTERFACE["basis"]["labels"]

minima = get_optimal_displacements(material, grid_size=(10, 10), search_range=(-1.0, 1.0))
optimal_displacement = minima[0]
displaced_material = displace_interface(material, optimal_displacement, use_cartesian_coordinates=True)
assertion_utils.assert_deep_almost_equal(expected_coordinates, displaced_material.basis.coordinates.to_dict())
assertion_utils.assert_deep_almost_equal(expected_labels, displaced_material.basis.labels.to_dict())

0 comments on commit 51e3e87

Please sign in to comment.