Example #1
0
def init_guess_by_wolfsberg_helmholtz(mol):
    """Diagonal will be taken from core hamiltonian, the off diagonal elements
    are interpolated by wolfsberg helmholtz scheme. 
    
        H_ji = k_ji (H_ii + H_ij) S_ij / 2, with k_ij =1.75
    
    (Generalized Wolfsberg Helmholtz GWH). See here:
    http://www.q-chem.com/qchem-website/manual/qchem50_manual/sect-initialguess.html

    M. Wolfsberg and L. Helmholz, J. Chem. Phys. 20, 837 (1952). 
    """
    from pyscf.scf.hf import eig, get_hcore, get_ovlp, get_occ, make_rdm1, SCF
    import numpy

    H = numpy.diag(get_hcore(mol))

    k = numpy.ones((len(H), len(H))) * 1.75 - \
        numpy.diag(numpy.ones(H.shape)) * 0.75
    S = get_ovlp(mol)

    H = k * numpy.add.outer(H, H) * S / 2

    mo_energy, mo_coeff = eig(H, S)
    mo_occ = get_occ(SCF(mol), mo_energy, mo_coeff)

    return make_rdm1(mo_coeff, mo_occ)
Example #2
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
    cell.h = c.cell.T

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([5, 5, 5])
    cell.verbose = 7
    cell.build(None, None)

    scaled_kpts = ase.dft.kpoints.monkhorst_pack((1, 1, 1))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    print kmf.scf()

    e_kn = []
    for kpt in band_kpts:
        fb, sb = kmf.get_band_fock_ovlp(kmf.get_hcore() + kmf.get_veff(),
                                        kmf.get_ovlp(), kpt)
        e, c = hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)

    emin = -1
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
Example #3
0
def eig(mf, h, s):
    '''Solve generalized eigenvalue problem, for each irrep.  The
    eigenvalues and eigenvectors are not sorted to ascending order.
    Instead, they are grouped based on irreps.
    '''
    if not mf.mol.symmetry:
        return hf.eig(h, s)

    nirrep = mf.mol.symm_orb.__len__()
    h = symm.symmetrize_matrix(h, mf.mol.symm_orb)
    s = symm.symmetrize_matrix(s, mf.mol.symm_orb)
    cs = []
    es = []
    for ir in range(nirrep):
        e, c = hf.eig(h[ir], s[ir])
        cs.append(c)
        es.append(e)
    e = numpy.hstack(es)
    c = so2ao_mo_coeff(mf.mol.symm_orb, cs)
    return e, c
Example #4
0
def eig(mf, h, s):
    '''Solve generalized eigenvalue problem, for each irrep.  The
    eigenvalues and eigenvectors are not sorted to ascending order.
    Instead, they are grouped based on irreps.
    '''
    if not mf.mol.symmetry:
        return hf.eig(h, s)

    nirrep = mf.mol.symm_orb.__len__()
    h = symm.symmetrize_matrix(h, mf.mol.symm_orb)
    s = symm.symmetrize_matrix(s, mf.mol.symm_orb)
    cs = []
    es = []
    for ir in range(nirrep):
        e, c = hf.eig(h[ir], s[ir])
        cs.append(c)
        es.append(e)
    e = numpy.hstack(es)
    c = so2ao_mo_coeff(mf.mol.symm_orb, cs)
    return e, c
Example #5
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(c)
    cell.a=c.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs=np.array([5,5,5])
    cell.verbose=7
    cell.build(None,None)
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((1,1,1))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
 
    e_kn = []
    for kpt in band_kpts:
        fb, sb=kmf.get_band_fock_ovlp(kmf.get_hcore()+kmf.get_veff(),
                                      kmf.get_ovlp(), kpt)
        e, c=hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)
    
    emin = -1 
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
Example #6
0
    def get_bands(self, kpt_band, cell=None, dm_kpts=None, kpts=None):
        '''Get energy bands at a given (arbitrary) 'band' k-point.

        Returns:
            mo_energy : (nao,) ndarray
                Bands energies E_n(k)
            mo_coeff : (nao, nao) ndarray
                Band orbitals psi_n(k)
        '''
        if cell is None: cell = self.cell
        if dm_kpts is None: dm_kpts = self.make_rdm1()
        if kpts is None: kpts = self.kpts

        fock = self.get_hcore(cell, kpt_band)
        fock = fock + self.get_veff(cell, dm_kpts, kpts=kpts, kpt_band=kpt_band)
        s1e = self.get_ovlp(cell, kpt_band)
        mo_energy, mo_coeff = hf.eig(fock, s1e)
        return mo_energy, mo_coeff
Example #7
0
    def get_bands(self, kpt_band, cell=None, dm_kpts=None, kpts=None):
        '''Get energy bands at a given (arbitrary) 'band' k-point.

        Returns:
            mo_energy : (nao,) ndarray
                Bands energies E_n(k)
            mo_coeff : (nao, nao) ndarray
                Band orbitals psi_n(k)
        '''
        if cell is None: cell = self.cell
        if dm_kpts is None: dm_kpts = self.make_rdm1()
        if kpts is None: kpts = self.kpts

        fock = self.get_hcore(cell, kpt_band)
        fock = fock + self.get_veff(
            cell, dm_kpts, kpts=kpts, kpt_band=kpt_band)
        s1e = self.get_ovlp(cell, kpt_band)
        mo_energy, mo_coeff = hf.eig(fock, s1e)
        return mo_energy, mo_coeff