示例#1
0
文件: __init__.py 项目: ryokbys/nap
    def get_num_valence(self):
        """
        Get number of valence electrons by reading POSCAR and POTCAR.
        Since POTCAR is large, reading POTCAR may take a while.
        """
        #...Read POSCAR file and get number of atoms of each species
        try:
            self.poscar
        except:
            self.poscar = poscar.POSCAR()
        self.poscar.read(self.path+'/POSCAR')
        num_atoms = copy.copy(self.poscar.num_atoms)

        #...Read POTCAR file and get number of electrons of each species
        try:
            self.potcar
        except:
            self.potcar = potcar.read_POTCAR(self.path+'/POTCAR')
        valences = self.potcar['valence']

        #...Total num of valence electrons
        nel = 0
        for i,n in enumerate(num_atoms):
            nel += n *valences[i]
        return nel
示例#2
0
    def get_num_valence(self):
        """
        Get number of valence electrons by reading POSCAR and POTCAR.
        Since POTCAR is large, reading POTCAR may take a while.
        """
        #...Read POSCAR file and get number of atoms of each species
        try:
            self.poscar
        except:
            self.poscar = poscar.POSCAR()
        self.poscar.read(self.path + '/POSCAR')
        num_atoms = copy.copy(self.poscar.num_atoms)

        #...Read POTCAR file and get number of electrons of each species
        try:
            self.potcar
        except:
            self.potcar = potcar.read_POTCAR(self.path + '/POTCAR')
        valences = self.potcar['valence']

        #...Total num of valence electrons
        nel = 0
        for i, n in enumerate(num_atoms):
            nel += n * valences[i]
        return nel
示例#3
0
def check_POTCAR():
    

#=======================================================================

if __name__ == '__main__':

    args= docopt(__doc__)

    pitch= float(args['-p'])
    leven= args['--even']
    _spin_polarized= args['--spin-polarize']
    _break_symmetry= args['--break-symmetry']
    _metal= args['--metal']
    poscar_fname= args['POSCAR']

    print ' Pitch of k points = {0:5.1f}'.format(pitch)

    poscar= poscar.POSCAR()
    poscar.read(poscar_fname)

    
    potcar= potcar.read_POTCAR()
    species= potcar['species']
    encut= max(potcar['encut'])
    valences= potcar['valence']
    a1= poscar.h[:,0]
    a2= poscar.h[:,1]
    a3= poscar.h[:,2]
    al= poscar.afac
    natms= poscar.num_atoms

    print " species:",species
    print " encut:",encut
    print " valences:",valences
    print " natms:",natms
    ntot= 0
    nele= 0
    for i in range(len(natms)):
        ntot= ntot +natms[i]
        nele= nele +natms[i]*int(valences[i])
    
    if _spin_polarized:
        nbands= int(nele/2 *1.8)
    else:
        nbands= int(nele/2 *1.4)
    
    if nbands < 50:
        nbands= nele

    l1= al *math.sqrt(a1[0]**2 +a1[1]**2 +a1[2]**2)
    l2= al *math.sqrt(a2[0]**2 +a2[1]**2 +a2[2]**2)
    l3= al *math.sqrt(a3[0]**2 +a3[1]**2 +a3[2]**2)
    print ' Length of each axes:'
    print '   l1 = {0:10.3f}'.format(l1)
    print '   l2 = {0:10.3f}'.format(l2)
    print '   l3 = {0:10.3f}'.format(l3)
    k1= determine_num_kpoint(l1,pitch,leven)
    k2= determine_num_kpoint(l2,pitch,leven)
    k3= determine_num_kpoint(l3,pitch,leven)
    print ' Number of k-points: {0:2d} {1:2d} {2:2d}'.format(k1,k2,k3)
    ndiv= [k1,k2,k3]
    
    write_KPOINTS(_KPOINTS_name,_KPOINTS_type,ndiv)
    write_INCAR(_INCAR_name,encut,nbands)
示例#4
0
    file.close()

if __name__ == '__main__':


    args= docopt(__doc__)
    pitch= float(args['--pitch'])
    dpath= args['--pot-dir']
    dpath= os.path.expanduser(dpath)

    print ' Pitch of k points = {0:5.1f}'.format(pitch)

    posc= poscar.POSCAR()
    posc.read()
    
    potc= potcar.read_POTCAR()
    species= potc['species']
    encut= max(potc['encut'])
    valences= potc['valence']
    a1= posc.h[:,0]
    a2= posc.h[:,1]
    a3= posc.h[:,2]
    al= posc.afac
    cell = [a1*al,a2*al,a3*al]
    natms= posc.num_atoms

    print " species:",species
    print " encut:",encut
    print " valences:",valences
    print " natms:",natms
    ntot= 0