コード例 #1
0
ファイル: test_kpoints.py プロジェクト: zbwang/abipy
    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
ファイル: test_kpoints.py プロジェクト: gmatteo/abipy
    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
ファイル: symmetries.py プロジェクト: xue-smile/abipy
    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
ファイル: symmetries.py プロジェクト: akakcolin/abipy
    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
ファイル: test_kpoints.py プロジェクト: xue-smile/abipy
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
ファイル: test_kpoints.py プロジェクト: davidwaroquiers/abipy
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
ファイル: symmetries.py プロジェクト: xue-smile/abipy
    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
ファイル: symmetries.py プロジェクト: gmatteo/abipy
    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)