From da3a7e0360dc3bddd3c84668315101e31c4104a9 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Sun, 22 Sep 2024 19:29:41 -0700 Subject: [PATCH] update: add test verified in nb --- tests/py/unit/test_tools_build_interface.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/py/unit/test_tools_build_interface.py b/tests/py/unit/test_tools_build_interface.py index 6cdabf81..c222f154 100644 --- a/tests/py/unit/test_tools_build_interface.py +++ b/tests/py/unit/test_tools_build_interface.py @@ -9,8 +9,11 @@ create_interfaces, ) from mat3ra.made.tools.build.interface.builders import ( + CommensurateLatticeInterfaceBuilder, + CommensurateLatticeInterfaceBuilderParameters, NanoRibbonTwistedInterfaceBuilder, NanoRibbonTwistedInterfaceConfiguration, + TwistedInterfaceConfiguration, ) from mat3ra.utils import assertion as assertion_utils @@ -63,3 +66,18 @@ def test_create_twisted_nanoribbon_interface(): expected_coordinate = [0.704207885, 0.522108183, 0.65] assertion_utils.assert_deep_almost_equal(exected_cell_vectors, interface.basis.cell.vectors_as_array) assertion_utils.assert_deep_almost_equal(expected_coordinate, interface.basis.coordinates.values[42]) + + +def test_create_commensurate_supercell_twisted_interface(): + film = Material(GRAPHENE) + substrate = Material(GRAPHENE) + config = TwistedInterfaceConfiguration(film=film, substrate=substrate, twist_angle=13, distance_z=3.0) + params = CommensurateLatticeInterfaceBuilderParameters(max_search=5, angle_tolerance=0.5, return_first_match=True) + builder = CommensurateLatticeInterfaceBuilder(build_parameters=params) + interfaces = builder.get_materials(config, post_process_parameters=config) + assert len(interfaces) == 1 + interface = interfaces[0] + print(interface.basis.cell.vectors_as_array) + expected_cell_vectors = [[10.754672133, 0.0, 0.0], [5.377336066500001, 9.313819276550575, 0.0], [0.0, 0.0, 20.0]] + + assertion_utils.assert_deep_almost_equal(expected_cell_vectors, interface.basis.cell.vectors_as_array)