# Path: mpinterfaces/transformations.py
# def reduced_supercell_vectors(ab, n):
#     """
#     Returns all possible reduced in-plane lattice vectors and
#     transition matrices for the given starting unit cell lattice
#     vectors(ab) and the supercell size n
#     """
#     uv_list = []
#     tm_list = []
#     for r_tm in get_trans_matrices(n):
#         uv = get_uv(ab, r_tm)
#         uv_r, tm0 = get_reduced_uv(uv, r_tm)
#         uv_list.append(uv_r)
#         tm_list.append(tm0)
#     return uv_list, tm_list
# 
# Path: mpinterfaces/utils.py
# def get_ase_slab(pmg_struct, hkl=(1, 1, 1), min_thick=10, min_vac=10):
#     """
#     takes in the intial structure as pymatgen Structure object
#     uses ase to generate the slab
#     returns pymatgen Slab object
# 
#     Args:
#         pmg_struct: pymatgen structure object
#         hkl: hkl index of surface of slab to be created
#         min_thick: minimum thickness of slab in Angstroms
#         min_vac: minimum vacuum spacing
#     """
#     ase_atoms = AseAtomsAdaptor().get_atoms(pmg_struct)
#     pmg_slab_gen = SlabGenerator(pmg_struct, hkl, min_thick, min_vac)
#     h = pmg_slab_gen._proj_height
#     nlayers = int(math.ceil(pmg_slab_gen.min_slab_size / h))
#     ase_slab = surface(ase_atoms, hkl, nlayers)
#     ase_slab.center(vacuum=min_vac / 2, axis=2)
#     pmg_slab_structure = AseAtomsAdaptor().get_structure(ase_slab)
#     return Slab(lattice=pmg_slab_structure.lattice,
#                 species=pmg_slab_structure.species_and_occu,
#                 coords=pmg_slab_structure.frac_coords,
#                 site_properties=pmg_slab_structure.site_properties,
#                 miller_index=hkl, oriented_unit_cell=pmg_slab_structure,
#                 shift=0., scale_factor=None, energy=None)
# 
# Path: mpinterfaces/default_logger.py
# def get_default_logger(name, output_stream=sys.stdout):
#     logger = logging.getLogger(name)
#     logger.setLevel(logging.DEBUG)
#     logger.propagate = False
#     formatter = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
#     sh = logging.StreamHandler(stream=output_stream)
#     sh.setFormatter(formatter)
#     logger.addHandler(sh)
#     return logger


from six.moves import range
from pymatgen.core.structure import Structure, Molecule
from pymatgen.core.lattice import Lattice
from pymatgen.core.surface import Slab, SlabGenerator
from pymatgen.core.operations import SymmOp
from pymatgen.util.coord import get_angle
from mpinterfaces.transformations import reduced_supercell_vectors
from mpinterfaces.utils import get_ase_slab
from mpinterfaces.default_logger import get_default_logger
import sys
import math
import copy
import numpy as np
    import os
                'requested surface coverage exceeds the max possible coverage. exiting.')
            sys.exit()
        else:
            for scell in range(1, self.scell_nmax):
                for nlig in range(1, scell * n_top_atoms + 1):
                    surface_area = scell * surface_area_orig
                    surface_coverage = nlig / surface_area
                    diff_coverage = np.abs(
                        surface_coverage - self.surface_coverage)
                    if diff_coverage <= self.surface_coverage * self.coverage_tol:
                        logger.info(
                            'tolerance limit = {}'.format(self.coverage_tol))
                        logger.info(
                            'possible coverage within the tolerance limit = {}'.format(
                                nlig / surface_area))
                        logger.info('supercell size = {}'.format(scell))
                        logger.info('number of ligands = {}'.format(nlig))
                        return scell, nlig
        return None, None

    def get_reduced_scell(self):
        """
        enforces the surface coverage criterion and generates
        the list all reduced lattice vectors that correspond to
        the computed supercell size and returns the one with similar
        lattice vector norms
        """
        scell, nlig = self.enforce_coverage()
        if scell and nlig:
            ab = [self.lattice.matrix[0, :], self.lattice.matrix[1, :]]

# Path: mpinterfaces/transformations.py
# def reduced_supercell_vectors(ab, n):
#     """
#     Returns all possible reduced in-plane lattice vectors and
#     transition matrices for the given starting unit cell lattice
#     vectors(ab) and the supercell size n
#     """
#     uv_list = []
#     tm_list = []
#     for r_tm in get_trans_matrices(n):
#         uv = get_uv(ab, r_tm)
#         uv_r, tm0 = get_reduced_uv(uv, r_tm)
#         uv_list.append(uv_r)
#         tm_list.append(tm0)
#     return uv_list, tm_list
# 
# Path: mpinterfaces/utils.py
# def get_ase_slab(pmg_struct, hkl=(1, 1, 1), min_thick=10, min_vac=10):
#     """
#     takes in the intial structure as pymatgen Structure object
#     uses ase to generate the slab
#     returns pymatgen Slab object
# 
#     Args:
#         pmg_struct: pymatgen structure object
#         hkl: hkl index of surface of slab to be created
#         min_thick: minimum thickness of slab in Angstroms
#         min_vac: minimum vacuum spacing
#     """
#     ase_atoms = AseAtomsAdaptor().get_atoms(pmg_struct)
#     pmg_slab_gen = SlabGenerator(pmg_struct, hkl, min_thick, min_vac)
#     h = pmg_slab_gen._proj_height
#     nlayers = int(math.ceil(pmg_slab_gen.min_slab_size / h))
#     ase_slab = surface(ase_atoms, hkl, nlayers)
#     ase_slab.center(vacuum=min_vac / 2, axis=2)
#     pmg_slab_structure = AseAtomsAdaptor().get_structure(ase_slab)
#     return Slab(lattice=pmg_slab_structure.lattice,
#                 species=pmg_slab_structure.species_and_occu,
#                 coords=pmg_slab_structure.frac_coords,
#                 site_properties=pmg_slab_structure.site_properties,
#                 miller_index=hkl, oriented_unit_cell=pmg_slab_structure,
#                 shift=0., scale_factor=None, energy=None)
# 
# Path: mpinterfaces/default_logger.py
# def get_default_logger(name, output_stream=sys.stdout):
#     logger = logging.getLogger(name)
#     logger.setLevel(logging.DEBUG)
#     logger.propagate = False
#     formatter = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
#     sh = logging.StreamHandler(stream=output_stream)
#     sh.setFormatter(formatter)
#     logger.addHandler(sh)
#     return logger


# Path: mpinterfaces/interface.py
from six.moves import range
from pymatgen.core.structure import Structure, Molecule
from pymatgen.core.lattice import Lattice
from pymatgen.core.surface import Slab, SlabGenerator
from pymatgen.core.operations import SymmOp
from pymatgen.util.coord import get_angle
from mpinterfaces.transformations import reduced_supercell_vectors
from mpinterfaces.utils import get_ase_slab
from mpinterfaces.default_logger import get_default_logger
import sys
import math
import copy
import numpy as np
    import os

                'requested surface coverage exceeds the max possible coverage. exiting.')
            sys.exit()
        else:
            for scell in range(1, self.scell_nmax):
                for nlig in range(1, scell * n_top_atoms + 1):
                    surface_area = scell * surface_area_orig
                    surface_coverage = nlig / surface_area
                    diff_coverage = np.abs(
                        surface_coverage - self.surface_coverage)
                    if diff_coverage <= self.surface_coverage * self.coverage_tol:
                        logger.info(
                            'tolerance limit = {}'.format(self.coverage_tol))
                        logger.info(
                            'possible coverage within the tolerance limit = {}'.format(
                                nlig / surface_area))
                        logger.info('supercell size = {}'.format(scell))
                        logger.info('number of ligands = {}'.format(nlig))
                        return scell, nlig
        return None, None

    def get_reduced_scell(self):
        """
        enforces the surface coverage criterion and generates
        the list all reduced lattice vectors that correspond to
        the computed supercell size and returns the one with similar
        lattice vector norms
        """
        scell, nlig = self.enforce_coverage()
        if scell and nlig:
            ab = [self.lattice.matrix[0, :], self.lattice.matrix[1, :]]

            uv_list, _ = reduced_supercell_vectors(ab, scell)