'''
generates IBOs
'''
mo_occ = mf.mo_coeff[:,mf.mo_occ>0]
a = lo.iao.iao(cell, mo_occ)
# Orthogonalize IAO
a = lo.vec_lowdin(a, mf.get_ovlp())
#ibo must take the orthonormalized IAOs
ibo = lo.ibo.ibo(cell, mo_occ, a)


'''
Generates IBO files as VASP Chgcars
'''
for i in range(ibo.shape[1]):
    chgcar.orbital(cell, 'diamond_ibo{:02d}.chgcar'.format(i+1), ibo[:,i])
    print("wrote cube {:02d}".format(i+1))

'''
Makes Population Analysis with IAOs
'''
# transform mo_occ to IAO representation. Note the AO dimension is reduced
mo_occ = reduce(numpy.dot, (a.T, mf.get_ovlp(), mo_occ))

dm = numpy.dot(mo_occ, mo_occ.T) * 2
iao_mol = cell.copy()
iao_mol.build(False, False, basis='minao')
mullic = mf.mulliken_pop(iao_mol, dm, s=numpy.eye(iao_mol.nao_nr()))

Exemplo n.º 2
0
            f.write(''.join(['%5.3s' % atomN[0]
                             for atomN in vaspAtomicInfo]) + '\n')
            f.write(''.join(['%5d' % atomN[1]
                             for atomN in vaspAtomicInfo]) + '\n')
            f.write('Cartesian \n')
            for ia in range(cell.natm):
                f.write(' %14.8f %14.8f %14.8f\n' % tuple(swappedCoords[ia]))
            f.write('\n')
            f.write('%6.5s %6.5s %6.5s \n' % (self.nx, self.ny, self.nz))
            fmt = ' %14.8e '
            for iz in range(self.nz):
                for iy in range(self.ny):
                    f.write('\n')
                    for ix in range(self.nx):
                        f.write(fmt % field[ix, iy, iz])

    def read(self, chgcar_file):
        raise NotImplementedError


if __name__ == '__main__':
    from pyscf.pbc import scf
    from pyscf.tools import chgcar
    cell = gto.M(atom='H 0 0 0; H 0 0 1', a=numpy.eye(3) * 3)
    mf = scf.RHF(cell).run()
    chgcar.density(cell, 'h2.CHGCAR', mf.make_rdm1())  #makes total density
    chgcar.orbital(cell, 'h2_mo1.CHGCAR', mf.mo_coeff[:,
                                                      0])  # makes mo#1 (sigma)
    chgcar.orbital(cell, 'h2_mo2.CHGCAR',
                   mf.mo_coeff[:, 1])  # makes mo#2 (sigma*)
Exemplo n.º 3
0
import numpy as np
from pyscf.pbc import gto, scf
from pyscf.tools import chgcar

#
# Regular CHGCAR file for crystal cell
#
cell = gto.M(atom='H 0 0 0; H 0 0 1', a=np.eye(3)*3)
mf = scf.RHF(cell).run()

# electron density
chgcar.density(cell, 'cell_h2.CHGCAR', mf.make_rdm1())

# 1st MO
chgcar.orbital(cell, 'cell_h2_mo1.CHGCAR', mf.mo_coeff[:,0])


#
# Extended mode to support molecular system. In this mode, a lattic was
# generated and the molecule was placed in the center of the unit cell.
#
from pyscf import gto, scf
mol = gto.M(atom='H 0 0 0; H 0 0 1')
mf = scf.RHF(mol).run()

# electron density
chgcar.density(mol, 'mole_h2.CHGCAR', mf.make_rdm1())

# 2nd MO
chgcar.orbital(mol, 'mole_h2_mo2.CHGCAR', mf.mo_coeff[:,1])