Beispiel #1
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*)
Beispiel #2
0
'''
Write orbitals, electron density in VASP CHGCAR format.
'''

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())