From e7ed5d2c96cf45fd32ba553cab1d891b015044a9 Mon Sep 17 00:00:00 2001 From: Minye Zhang Date: Sun, 15 Dec 2024 11:29:22 +0100 Subject: [PATCH] add MX2 factory method --- mushroom/core/cell.py | 26 ++++++++++++++++++++++++++ mushroom/core/test/test_cell.py | 1 + 2 files changed, 27 insertions(+) diff --git a/mushroom/core/cell.py b/mushroom/core/cell.py index c2fa966..37958bd 100644 --- a/mushroom/core/cell.py +++ b/mushroom/core/cell.py @@ -1862,6 +1862,32 @@ def marcasite(cls, atom1: str = "Fe", atom2: str = "S", kwargs.update({"comment": "Marcasite {}{}2".format(atom1, atom2)}) return cls(latt, atms, posi, **kwargs) + @classmethod + def MX2(cls, atom1: str = "Mo", atom2: str = "S", + a: float = 3.22, c: float = 12.36, d: float = 2.31, kind: str = "2H", + **kwargs): + '''Generate a standardized lattice (space group 58). + + Args: + atom1 (str): symbol of the M atom + atom2 (str): symbol of the X atom + a, c (float): the lattice constants of the cell. + d (float): bond length of M-X + kwargs: keyword argument for ``Cell`` except ``coord_sys`` + ''' + if kind == "2H": + d_frac = np.sqrt(d ** 2 - a ** 2 / 3.0e0) / c + ha = 0.5e0 * a + latt = [[a, 0.0, 0.0], [-ha, ha * SQRT3, 0], [0.0, 0.0, c]] + atms = [str(atom1),] * 1 + [str(atom2),] * 2 + posi = [[0.0, 0.0, 0.5], + [1 / 3, 2 / 3, 0.5 - d_frac], + [1 / 3, 2 / 3, 0.5 + d_frac],] + else: + raise NotImplementedError("kind {}".format(kind)) + _logger.debug("creating MX2: latt %r, posi %r, atms %r", latt, posi, atms) + return cls(latt, atms, posi, **kwargs) + def latt_equal(cell1: Cell, cell2: Cell) -> bool: """compare the lattice vectors of two cell""" diff --git a/mushroom/core/test/test_cell.py b/mushroom/core/test/test_cell.py index 7f24f47..2e9e2a7 100644 --- a/mushroom/core/test/test_cell.py +++ b/mushroom/core/test/test_cell.py @@ -191,6 +191,7 @@ def test_typical_systems(self): Cell.wurtzite("Zn", "O") Cell.pyrite() Cell.marcasite() + Cell.MX2() class cell_reader(ut.TestCase):