Ejemplo n.º 1
0
def convert_projection_data(symbols, V_qnM, H_qMM, S_qMM, P_aqMi,
                            originaltype='dzp', newtype='sz'):
    Nq = len(H_qMM)
    mask = basis_subset2(symbols, originaltype, newtype)
    mask2 = np.outer(mask, mask)
    NMnew = len(mask.nonzero()[0])
    V_qnM = V_qnM[..., mask]
    H_qMM = H_qMM[:, mask2].reshape(Nq, NMnew, NMnew)
    S_qMM = S_qMM[:, mask2].reshape(Nq, NMnew, NMnew)
    P2_aqMi = {}
    for a, P_qMi in P_aqMi.items():
        P2_aqMi[a] = P_qMi[:, mask, :]
    return V_qnM, H_qMM, S_qMM, P2_aqMi
Ejemplo n.º 2
0
def convert_projection_data(symbols, V_qnM, H_qMM, S_qMM, P_aqMi,
                            originaltype='dzp', newtype='sz'):
    Nq = len(H_qMM)
    mask = basis_subset2(symbols, originaltype, newtype)
    mask2 = np.outer(mask, mask)
    NMnew = len(mask.nonzero()[0])
    V_qnM = V_qnM[..., mask]
    H_qMM = H_qMM[:, mask2].reshape(Nq, NMnew, NMnew)
    S_qMM = S_qMM[:, mask2].reshape(Nq, NMnew, NMnew)
    P2_aqMi = {}
    for a, P_qMi in P_aqMi.items():
        P2_aqMi[a] = P_qMi[:, mask, :]
    return V_qnM, H_qMM, S_qMM, P2_aqMi
Ejemplo n.º 3
0
Archivo: pwf2.py Proyecto: qsnake/gpaw
    def __init__(
        self,
        gpwfilename,
        fixedenergy=0.0,
        spin=0,
        ibl=True,
        basis="sz",
        zero_fermi=False,
        pwfbasis=None,
        lcaoatoms=None,
        projection_data=None,
    ):
        calc = GPAW(gpwfilename, txt=None, basis=basis)
        assert calc.wfs.gd.comm.size == 1
        assert calc.wfs.kpt_comm.size == 1
        assert calc.wfs.band_comm.size == 1
        if zero_fermi:
            try:
                Ef = calc.get_fermi_level()
            except NotImplementedError:
                Ef = calc.get_homo_lumo().mean()
        else:
            Ef = 0.0

        self.ibzk_kc = calc.get_ibz_k_points()
        self.nk = len(self.ibzk_kc)
        self.eps_kn = [calc.get_eigenvalues(kpt=q, spin=spin) - Ef for q in range(self.nk)]
        self.M_k = [sum(eps_n <= fixedenergy) for eps_n in self.eps_kn]
        print "Fixed states:", self.M_k
        self.calc = calc
        self.dtype = self.calc.wfs.dtype
        self.spin = spin
        self.ibl = ibl
        self.pwf_q = []
        self.norms_qn = []
        self.S_qww = []
        self.H_qww = []

        if ibl:
            if pwfbasis is not None:
                pwfmask = basis_subset2(calc.atoms.get_chemical_symbols(), basis, pwfbasis)
            if lcaoatoms is not None:
                lcaoindices = get_bfi2(calc.atoms.get_chemical_symbols(), basis, lcaoatoms)
            else:
                lcaoindices = None
            self.bfs = get_bfs(calc)
            if projection_data is None:
                V_qnM, H_qMM, S_qMM, self.P_aqMi = get_lcao_projections_HSP(
                    calc, bfs=self.bfs, spin=spin, projectionsonly=False
                )
            else:
                V_qnM, H_qMM, S_qMM, self.P_aqMi = projection_data
            H_qMM -= Ef * S_qMM
            for q, M in enumerate(self.M_k):
                if pwfbasis is None:
                    pwf = ProjectedWannierFunctionsIBL(V_qnM[q], S_qMM[q], M, lcaoindices)
                else:
                    pwf = PWFplusLCAO(V_qnM[q], S_qMM[q], M, pwfmask, lcaoindices)
                self.pwf_q.append(pwf)
                self.norms_qn.append(pwf.norms_n)
                self.S_qww.append(pwf.S_ww)
                self.H_qww.append(pwf.rotate_matrix(self.eps_kn[q][:M], H_qMM[q]))
        else:
            if projection_data is None:
                V_qnM = get_lcao_projections_HSP(calc, spin=spin)
            else:
                V_qnM = projection_data
            for q, M in enumerate(self.M_k):
                pwf = ProjectedWannierFunctionsFBL(V_qnM[q], M, ortho=False)
                self.pwf_q.append(pwf)
                self.norms_qn.append(pwf.norms_n)
                self.S_qww.append(pwf.S_ww)
                self.H_qww.append(pwf.rotate_matrix(self.eps_kn[q]))

        for S in self.S_qww:
            print "Condition number: %0.1e" % condition_number(S)
Ejemplo n.º 4
0
    def __init__(self,
                 gpwfilename,
                 fixedenergy=0.,
                 spin=0,
                 ibl=True,
                 basis='sz',
                 zero_fermi=False,
                 pwfbasis=None,
                 lcaoatoms=None,
                 projection_data=None):
        calc = GPAW(gpwfilename, txt=None, basis=basis)
        assert calc.wfs.gd.comm.size == 1
        assert calc.wfs.kd.comm.size == 1
        assert calc.wfs.bd.comm.size == 1
        if zero_fermi:
            try:
                Ef = calc.get_fermi_level()
            except NotImplementedError:
                Ef = calc.get_homo_lumo().mean()
        else:
            Ef = 0.0

        self.ibzk_kc = calc.get_ibz_k_points()
        self.nk = len(self.ibzk_kc)
        self.eps_kn = [
            calc.get_eigenvalues(kpt=q, spin=spin) - Ef for q in range(self.nk)
        ]
        self.M_k = [sum(eps_n <= fixedenergy) for eps_n in self.eps_kn]
        print('Fixed states:', self.M_k)
        self.calc = calc
        self.dtype = self.calc.wfs.dtype
        self.spin = spin
        self.ibl = ibl
        self.pwf_q = []
        self.norms_qn = []
        self.S_qww = []
        self.H_qww = []

        if ibl:
            if pwfbasis is not None:
                pwfmask = basis_subset2(calc.atoms.get_chemical_symbols(),
                                        basis, pwfbasis)
            if lcaoatoms is not None:
                lcaoindices = get_bfi2(calc.atoms.get_chemical_symbols(),
                                       basis, lcaoatoms)
            else:
                lcaoindices = None
            self.bfs = get_bfs(calc)
            if projection_data is None:
                V_qnM, H_qMM, S_qMM, self.P_aqMi = get_lcao_projections_HSP(
                    calc, bfs=self.bfs, spin=spin, projectionsonly=False)
            else:
                V_qnM, H_qMM, S_qMM, self.P_aqMi = projection_data
            H_qMM -= Ef * S_qMM
            for q, M in enumerate(self.M_k):
                if pwfbasis is None:
                    pwf = ProjectedWannierFunctionsIBL(V_qnM[q], S_qMM[q], M,
                                                       lcaoindices)
                else:
                    pwf = PWFplusLCAO(V_qnM[q], S_qMM[q], M, pwfmask,
                                      lcaoindices)
                self.pwf_q.append(pwf)
                self.norms_qn.append(pwf.norms_n)
                self.S_qww.append(pwf.S_ww)
                self.H_qww.append(
                    pwf.rotate_matrix(self.eps_kn[q][:M], H_qMM[q]))
        else:
            if projection_data is None:
                V_qnM = get_lcao_projections_HSP(calc, spin=spin)
            else:
                V_qnM = projection_data
            for q, M in enumerate(self.M_k):
                pwf = ProjectedWannierFunctionsFBL(V_qnM[q], M, ortho=False)
                self.pwf_q.append(pwf)
                self.norms_qn.append(pwf.norms_n)
                self.S_qww.append(pwf.S_ww)
                self.H_qww.append(pwf.rotate_matrix(self.eps_kn[q]))

        for S in self.S_qww:
            print('Condition number: %0.1e' % condition_number(S))