diff --git a/tests/py/unit/fixtures.py b/tests/py/unit/fixtures.py index 34883958..aa7ba5b3 100644 --- a/tests/py/unit/fixtures.py +++ b/tests/py/unit/fixtures.py @@ -492,6 +492,99 @@ "isUpdated": True, } +GRAPHENE_ZIGZAG_NANORIBBON_PASSIVATED = { + "name": "Graphene (Zigzag nanoribbon) H-passivated", + "basis": { + "elements": [ + {"id": 0, "value": "C"}, + {"id": 1, "value": "C"}, + {"id": 2, "value": "C"}, + {"id": 3, "value": "C"}, + {"id": 4, "value": "C"}, + {"id": 5, "value": "C"}, + {"id": 6, "value": "C"}, + {"id": 7, "value": "C"}, + {"id": 8, "value": "C"}, + {"id": 9, "value": "C"}, + {"id": 10, "value": "C"}, + {"id": 11, "value": "C"}, + {"id": 12, "value": "C"}, + {"id": 13, "value": "C"}, + {"id": 14, "value": "C"}, + {"id": 15, "value": "C"}, + {"id": 16, "value": "H"}, + {"id": 17, "value": "H"}, + {"id": 18, "value": "H"}, + {"id": 19, "value": "H"}, + {"id": 20, "value": "H"}, + {"id": 21, "value": "H"}, + {"id": 22, "value": "H"}, + {"id": 23, "value": "H"}, + ], + "coordinates": [ + {"id": 0, "value": [0.062499937, 0.366666681, 0.5]}, + {"id": 1, "value": [0.312499937, 0.366666681, 0.5]}, + {"id": 2, "value": [0.187500062, 0.433333286, 0.5]}, + {"id": 3, "value": [0.187499937, 0.566666695, 0.5]}, + {"id": 4, "value": [0.062500062, 0.6333333, 0.5]}, + {"id": 5, "value": [0.562499937, 0.366666681, 0.5]}, + {"id": 6, "value": [0.437500062, 0.433333286, 0.5]}, + {"id": 7, "value": [0.437499937, 0.566666695, 0.5]}, + {"id": 8, "value": [0.312500062, 0.6333333, 0.5]}, + {"id": 9, "value": [0.812499938, 0.366666681, 0.5]}, + {"id": 10, "value": [0.687500062, 0.433333286, 0.5]}, + {"id": 11, "value": [0.687499937, 0.566666695, 0.5]}, + {"id": 12, "value": [0.562500062, 0.6333333, 0.5]}, + {"id": 13, "value": [0.937500063, 0.433333286, 0.5]}, + {"id": 14, "value": [0.937499937, 0.566666695, 0.5]}, + {"id": 15, "value": [0.812500063, 0.6333333, 0.5]}, + {"id": 16, "value": [0.062500067, 0.228137674, 0.5]}, + {"id": 17, "value": [0.312500067, 0.228137674, 0.5]}, + {"id": 18, "value": [0.062499932, 0.771862307, 0.5]}, + {"id": 19, "value": [0.562500067, 0.228137674, 0.5]}, + {"id": 20, "value": [0.312499932, 0.771862307, 0.5]}, + {"id": 21, "value": [0.812500068, 0.228137674, 0.5]}, + {"id": 22, "value": [0.562499932, 0.771862307, 0.5]}, + {"id": 23, "value": [0.812499933, 0.771862307, 0.5]}, + ], + "units": "crystal", + "cell": [[9.869164, 0.0, 0.0], [-0.0, 10.683683, 0.0], [0.0, 0.0, 20.0]], + "labels": [], + }, + "lattice": { + "a": 9.869164, + "b": 10.683683422, + "c": 20.0, + "alpha": 90.0, + "beta": 90.0, + "gamma": 90.0, + "units": {"length": "angstrom", "angle": "degree"}, + "type": "TRI", + "vectors": { + "a": [9.869164, 0.0, 0.0], + "b": [-0.0, 10.683683422, 0.0], + "c": [0.0, 0.0, 20.0], + "alat": 1, + "units": "angstrom", + }, + }, + "isNonPeriodic": False, + "_id": "", + "metadata": { + "boundaryConditions": {"type": "pbc", "offset": 0}, + "build": { + "configuration": { + "type": "PassivationConfiguration", + "slab": GRAPHENE_ZIGZAG_NANORIBBON, + "passivant": "H", + "bond_length": 1.48, + "surface": "both", + } + }, + }, + "isUpdated": True, +} + GRAPHENE_NICKEL_INTERFACE = { "name": "C2(001)-Ni4(111), Interface, Strain 0.105pct", diff --git a/tests/py/unit/test_tools_build_passivation.py b/tests/py/unit/test_tools_build_passivation.py index 469b73cc..8b9c38e6 100644 --- a/tests/py/unit/test_tools_build_passivation.py +++ b/tests/py/unit/test_tools_build_passivation.py @@ -1,9 +1,15 @@ from mat3ra.made.material import Material -from mat3ra.made.tools.build.passivation.builders import SurfacePassivationBuilder, SurfacePassivationBuilderParameters +from mat3ra.made.tools.build.passivation import get_unique_coordination_numbers +from mat3ra.made.tools.build.passivation.builders import ( + CoordinationBasedPassivationBuilder, + CoordinationBasedPassivationBuilderParameters, + SurfacePassivationBuilder, + SurfacePassivationBuilderParameters, +) from mat3ra.made.tools.build.passivation.configuration import PassivationConfiguration from mat3ra.utils import assertion as assertion_utils -from .fixtures import SI_SLAB, SI_SLAB_PASSIVATED +from .fixtures import GRAPHENE_ZIGZAG_NANORIBBON, GRAPHENE_ZIGZAG_NANORIBBON_PASSIVATED, SI_SLAB, SI_SLAB_PASSIVATED def test_passivate_surface(): @@ -13,3 +19,21 @@ def test_passivate_surface(): ) passivated_material = builder.get_material(config) assertion_utils.assert_deep_almost_equal(SI_SLAB_PASSIVATED, passivated_material.to_json()) + + +def test_get_unique_coordination_numbers(): + config = PassivationConfiguration( + slab=Material(GRAPHENE_ZIGZAG_NANORIBBON), passivant="H", bond_length=1.48, surface="both" + ) + unique_coordination_numbers = get_unique_coordination_numbers(config, cutoff=3.0) + assert unique_coordination_numbers == [2, 3] + + +def test_passivate_edge(): + config = PassivationConfiguration(slab=Material(GRAPHENE_ZIGZAG_NANORIBBON), passivant="H", bond_length=1.48) + params = CoordinationBasedPassivationBuilderParameters( + shadowing_radius=2.5, coordination_threshold=2, bonds_to_passivate=1 + ) + builder = CoordinationBasedPassivationBuilder(build_parameters=params) + passivated_material = builder.get_material(config) + assertion_utils.assert_deep_almost_equal(GRAPHENE_ZIGZAG_NANORIBBON_PASSIVATED, passivated_material.to_json())