示例#1
0
    def test_init(self):
        from pyscf.pbc import dft
        cell_u = cell.copy()
        cell_u.spin = 2
        self.assertTrue(isinstance(pscf.RKS  (cell  ), dft.rks.RKS    ))
        self.assertTrue(isinstance(pscf.RKS  (cell_u), dft.roks.ROKS  ))
        self.assertTrue(isinstance(pscf.UKS  (cell  ), dft.uks.UKS    ))
        self.assertTrue(isinstance(pscf.ROKS (cell  ), dft.roks.ROKS  ))
        self.assertTrue(isinstance(pscf.KS   (cell  ), dft.rks.RKS    ))
        self.assertTrue(isinstance(pscf.KS   (cell_u), dft.uks.UKS    ))
        self.assertTrue(isinstance(pscf.KRKS (cell  ), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KRKS (cell_u), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KUKS (cell  ), dft.kuks.KUKS  ))
        self.assertTrue(isinstance(pscf.KROKS(cell  ), dft.kroks.KROKS))
        self.assertTrue(isinstance(pscf.KKS  (cell  ), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KKS  (cell_u), dft.kuks.KUKS  ))

        self.assertTrue(isinstance(pscf.RHF  (cell  ), pscf.hf.RHF     ))
        self.assertTrue(isinstance(pscf.RHF  (cell_u), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.KRHF (cell  ), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.KRHF (cell_u), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.UHF  (cell  ), pscf.uhf.UHF    ))
        self.assertTrue(isinstance(pscf.KUHF (cell_u), pscf.kuhf.KUHF  ))
        self.assertTrue(isinstance(pscf.GHF  (cell  ), pscf.ghf.GHF    ))
        self.assertTrue(isinstance(pscf.KGHF (cell_u), pscf.kghf.KGHF  ))
        self.assertTrue(isinstance(pscf.ROHF (cell  ), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.ROHF (cell_u), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.KROHF(cell  ), pscf.krohf.KROHF))
        self.assertTrue(isinstance(pscf.KROHF(cell_u), pscf.krohf.KROHF))
        self.assertTrue(isinstance(pscf.HF   (cell  ), pscf.hf.RHF     ))
        self.assertTrue(isinstance(pscf.HF   (cell_u), pscf.uhf.UHF    ))
        self.assertTrue(isinstance(pscf.KHF  (cell  ), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.KHF  (cell_u), pscf.kuhf.KUHF  ))
示例#2
0
from pyscf.pbc.tools import pywannier90

# Definte unit cell
cell = gto.Cell()
cell.atom = [['Si', [0.0, 0.0, 0.0]], ['Si', [1.35775, 1.35775, 1.35775]]]
cell.a = [[0.0, 2.7155, 2.7155], [2.7155, 0.0, 2.7155], [2.7155, 2.7155, 0.0]]
cell.basis = 'gth-dzv'
cell.pseudo = 'gth-pade'
cell.exp_to_discard = 0.1
cell.build()

# PBE calculation
kmesh = [3, 3, 3]
kpts = cell.make_kpts(kmesh)
nkpts = kpts.shape[0]
kks = scf.KKS(cell, kpts)
kks.xc = 'PBE'
kks.chkfile = 'chkfile'
kks.init_guess = 'chkfile'
kks.run()

# the kks object can be saved and loaded before running pyWannier90
# Hence, one does not need to perform the kks calculation every time
# the localization parameters change, for example, the guessing orbitals or the disentanglement windows
pywannier90.save_kmf(kks, 'chk_PBE')
kmf = pywannier90.load_kmf('chk_PBE')

# (1) Construct MLWFs
num_wann = 8
keywords = \
"""
示例#3
0
    def __init__(self, cell, kmf, w90):
        '''
        TODO: need to be written
        Args:
            kmf        : a k-dependent mean-field wf
            w90        : a converged wannier90 object
            
        Indices
            u, v    : k-space ao indices 
            i, j    : k-space mo/local indices
            m, n    : embedding indices
            capital : R-space indices 
            R, S, T : R-spacce lattice vector
            
        '''

        # Collect cell and kmf object information
        self.cell = cell
        self.spin = cell.spin
        self.e_tot = kmf.e_tot
        self.kmesh = w90.mp_grid_loc
        self.kmf = kmf
        self.kpts = kmf.kpts
        self.Nkpts = kmf.kpts.shape[0]
        self.nao = cell.nao_nr()

        scell, self.phase = self.get_phase(self.cell, self.kpts, self.kmesh)
        self.ao2lo = self.get_ao2lo(
            w90)  # Used to transform AO to local basis in k-space
        self.nlo = self.ao2lo.shape[-1]

        #-------------------------------------------------------------
        # Construct the effective Hamiltonian due to the frozen core  |
        #-------------------------------------------------------------

        # Active part info
        self.active = np.zeros([cell.nao_nr()], dtype=int)

        for orb in range(cell.nao_nr()):
            if (orb + 1) not in w90.exclude_bands: self.active[orb] = 1
        self.nelec_per_cell = np.int32(
            cell.nelectron - np.sum(kmf.mo_occ_kpts[0][self.active == 0]))
        self.nelec_total = self.Nkpts * self.nelec_per_cell  # per computional super cell

        full_OEI_k = kmf.get_hcore()
        mo_k = kmf.mo_coeff_kpts
        coreDM_kpts = []
        for kpt in range(self.Nkpts):
            coreDMmo = kmf.mo_occ_kpts[kpt].copy()
            coreDMmo[self.active == 1] = 0
            coreDMao = reduce(
                np.dot, (mo_k[kpt], np.diag(coreDMmo), mo_k[kpt].T.conj()))
            coreDM_kpts.append(coreDMao)

        self.coreDM_kpts = np.asarray(coreDM_kpts, dtype=np.complex128)
        coreJK_kpts = kmf.get_veff(cell,
                                   self.coreDM_kpts,
                                   hermi=1,
                                   kpts=self.kpts,
                                   kpts_band=None)

        # Core energy from the frozen orbitals
        self.e_core = cell.energy_nuc() + 1. / self.Nkpts * lib.einsum(
            'kij,kji->', full_OEI_k + 0.5 * coreJK_kpts, self.coreDM_kpts).real

        # 1e integral for the active part
        self.actOEI_kpts = full_OEI_k + coreJK_kpts
        self.loc_actOEI_kpts = self.ao_2_loc(self.actOEI_kpts, self.ao2lo)

        # Fock for the active part
        self.fullfock_kpts = kmf.get_fock()
        self.loc_actFOCK_kpts = self.ao_2_loc(self.fullfock_kpts, self.ao2lo)
        self.actJK_kpts = self.fullfock_kpts - self.actOEI_kpts
        self.loc_actJK_kpts = self.ao_2_loc(
            self.actJK_kpts, self.ao2lo)  #DEBUG: used to debug, may be removed

        #DEBUG DFT-DMET
        dm_kpts = self.kmf.make_rdm1()
        self.vj, self.vk = self.kmf.get_jk(dm_kpts=dm_kpts)
        self.dm = self.kmf.make_rdm1()
        self.h_core = self.kmf.get_hcore()
        #self.vklr = self.kmf.get_k(self.cell, self.dm, 1, self.kpts, None, omega=0.11)

        from pyscf.pbc.dft import multigrid
        self.kks = scf.KKS(self.cell, self.kpts).density_fit()
        self.kks.with_df._cderi = self.kmf.with_df._cderi