示例#1
0
    def test_map_grid2ibz(self):
        """Testing map_grid2ibz."""
        bz2ibz = map_grid2ibz(self.mgb2,
                              self.kibz,
                              self.ngkpt,
                              self.has_timrev,
                              pbc=False)

        bz = []
        nx, ny, nz = self.ngkpt
        for ix, iy, iz in itertools.product(range(nx), range(ny), range(nz)):
            bz.append([ix / nz, iy / ny, iz / nz])
        bz = np.reshape(bz, (-1, 3))

        abispg = self.mgb2.abi_spacegroup

        nmax = 54
        errors = []
        for ik_bz, kbz in enumerate(bz[:nmax]):
            ik_ibz = bz2ibz[ik_bz]
            ki = self.kibz[ik_ibz]
            for symmop in abispg.fm_symmops:
                krot = symmop.rotate_k(ki)
                if issamek(krot, kbz):
                    break
            else:
                errors.append((ik_bz, kbz))

        assert not errors
示例#2
0
    def test_map_grid2ibz(self):
        """Testing map_grid2ibz."""
        bz2ibz = map_grid2ibz(self.mgb2, self.kibz, self.ngkpt, self.has_timrev, pbc=False)

        bz = []
        nx, ny, nz = self.ngkpt
        for ix, iy, iz in itertools.product(range(nx), range(ny), range(nz)):
            bz.append([ix/nz, iy/ny, iz/nz])
        bz = np.reshape(bz, (-1, 3))

        abispg = self.mgb2.abi_spacegroup

        nmax = 54
        errors = []
        for ik_bz, kbz in enumerate(bz[:nmax]):
            ik_ibz = bz2ibz[ik_bz]
            ki = self.kibz[ik_ibz]
            for symmop in abispg.fm_symmops:
                krot = symmop.rotate_k(ki)
                if issamek(krot, kbz):
                    break
            else:
                errors.append((ik_bz, kbz))

        assert not errors
示例#3
0
    def preserve_k(self, frac_coords, ret_g0=True):
        """
        Check if the operation preserves the k-point modulo a reciprocal lattice vector.

        Args:
            frac_coords: Fractional coordinates of the k-point
            ret_g0: False if only the boolean result is wanted.

        Returns:
            bool, g0 = S(k) - k

            bool is True is self preserves k and g0 is an integer vector.
        """
        sk = self.rotate_k(frac_coords, wrap_tows=False)

        if ret_g0:
            return issamek(sk, frac_coords), np.array(np.round(sk - frac_coords), dtype=np.int)
        else:
            return issamek(sk, frac_coords)
示例#4
0
    def preserve_k(self, frac_coords, ret_g0=True):
        """
        Check if the operation preserves the k-point modulo a reciprocal lattice vector.

        Args:
            frac_coords: Fractional coordinates of the k-point
            ret_g0: False if only the boolean result is wanted.

        Returns:
            bool, g0 = S(k) - k 

            bool is True is self preserves k and g0 is an integer vector.
        """
        sk = self.rotate_k(frac_coords, wrap_tows=False)

        if ret_g0:
            return issamek(sk, frac_coords), np.array(np.round(sk - frac_coords), dtype=np.int)
        else:
            return issamek(sk, frac_coords)
示例#5
0
def slow_mesh2ibz(structure, bz, ibz):
    #print("bz",bz)
    #print("ibz",ibz)
    bz2ibz = -np.ones(len(bz), dtype=np.int)

    for ik_bz, kbz in enumerate(bz):
        #print("kbz",kbz)
        found = False

        for ik_ibz, kibz in enumerate(ibz):
            #print("kibz",kibz)
            if found: break
            for symmop in structure.spacegroup:
                krot = symmop.rotate_k(kibz.frac_coords)
                if issamek(krot, kbz):
                    bz2ibz[ik_bz] = ik_ibz
                    found = True
                    break

    return bz2ibz
示例#6
0
def slow_mesh2ibz(structure, bz, ibz):
    #print("bz",bz)
    #print("ibz",ibz)
    bz2ibz = -np.ones(len(bz), dtype=np.int)

    for ik_bz, kbz in enumerate(bz):
        #print("kbz",kbz)
        found = False

        for ik_ibz, kibz in enumerate(ibz):
            #print("kibz",kibz)
            if found: break
            for symmop in structure.spacegroup:
                krot = symmop.rotate_k(kibz.frac_coords)
                if issamek(krot, kbz):
                    bz2ibz[ik_bz] = ik_ibz
                    found = True
                    break

    return bz2ibz
示例#7
0
    def symeq(self, k1_frac_coords, k2_frac_coords, atol=None):
        """
        Test whether two k-points in fractional coordinates are symmetry equivalent
        i.e. if there's a symmetry operations TO (including time-reversal T, if present)
        such that::

            TO(k1) = k2 + G0

        Return: namedtuple with::

            isym: The index of the symmetry operation such that TS(k1) = k2 + G0
                Set to -1 if k1 and k2 are not related by symmetry.
            op: Symmetry operation.
            g0: numpy vector.
        """
        for isym, sym in enumerate(self):
            sk_coords = sym.rotate_k(k1_frac_coords, wrap_tows=False)
            if issamek(sk_coords, k2_frac_coords, atol=atol):
                g0 = sym.rotate_k(k1_frac_coords) - k2_frac_coords
                return dict2namedtuple(isym=isym, op=self[isym], g0=g0)

        return dict2namedtuple(isym=-1, op=None, g0=None)
示例#8
0
    def symeq(self, k1_frac_coords, k2_frac_coords, atol=None):
        """
        Test whether two k-points in fractional coordinates are symmetry equivalent
        i.e. if there's a symmetry operations TO (including time-reversal T, if present)
	such that::

            TO(k1) = k2 + G0

	Return: namedtuple with::

            isym: The index of the symmetry operation such that TS(k1) = k2 + G0
                Set to -1 if k1 and k2 are not related by symmetry.
            op: Symmetry operation.
            g0: numpy vector.
        """
        for isym, sym in enumerate(self):
            sk_coords = sym.rotate_k(k1_frac_coords, wrap_tows=False)
            if issamek(sk_coords, k2_frac_coords, atol=atol):
                g0 = sym.rotate_k(k1_frac_coords) - k2_frac_coords
                return dict2namedtuple(isym=isym, op=self[isym], g0=g0)

        return dict2namedtuple(isym=-1, op=None, g0=None)