24小时热门版块排行榜    

查看: 2304  |  回复: 3

sulisha_agrh

新虫 (小有名气)

[求助] vasp分割DOSCAR和PROCAR 救助 已有1人参与

在设置LORBIT =11的情况下得到的分波态密度数据中,第一列示能量第二列示s轨道的dos那么第三四五列示px-py-pz(因为PROCAR中貌似是按s--py-pz-px-dxy-dyz-dz2.....的顺序)吗用网上流传的split_dos.py处理,PORCAR用dos_procar.f处理,后附代码求大神罩我
#!/usr/bin/env python
import numpy as np
import ase

### READ DOSCAR ###
def read_dosfile():
    f = open("DOSCAR", 'r')
    lines = f.readlines()
    f.close()
    index = 0
    natoms = int(lines[index].strip().split()[0])
    index = 5
    nedos = int(lines[index].strip().split()[2])
    efermi = float(lines[index].strip().split()[3])
    print natoms, nedos, efermi

    return lines, index, natoms, nedos, efermi

###READ POSCAR or CONTCAR and save pos
def read_posfile():
    from ase.io import read

    try:
        atoms = read('POSCAR')
    except IOError:
        print "[__main__]: Couldn't open input file POSCAR, atomic positions will not be written...\n"
        atoms = []
   
    return atoms

### WRITE DOS0 CONTAINING TOTAL DOS ###
def write_dos0(lines, index, nedos, efermi):
   
    fdos = open("DOS0", 'w')
    index +=1
    line = lines[index+2].strip().split()
    ncols = int(len(line))
    fdos.write('# %d \n' % (ncols))

    for n in xrange(1,nedos):
            index +=1
        e = float(lines[index].strip().split()[0])
        e_f = e-efermi
        fdos.write('%15.8f ' % (e_f))
        
        for col in xrange(1, ncols):
            dos = float(lines[index].strip().split()[col])
            fdos.write('%15.8f ' % (dos))
            col +=1  
            fdos.write('\n ')             
        n +=1  
    return index

### LOOP OVER SETS OF DOS, NATOMS ###
def write_nospin(lines, index, nedos, natoms, ncols, efermi):
   
    atoms = read_posfile()
    if len(atoms) < natoms:
            pos = np.zeros((natoms, 3))
    else:
            pos = atoms.get_positions()

    for i in xrange(1,natoms+1):
            si = str(i)
        
    ## OPEN DOSi FOR WRITING ##
        fdos = open("DOS"+si, 'w')
        index +=2
        ia = i -1
            fdos.write('# %d \n' % (ncols))
            fdos.write('# %15.8f %15.8f %15.8f \n' % (pos[ia,0], pos[ia,1], pos[ia,2]))
   
    ### LOOP OVER NEDOS ###
        for n in xrange(1,nedos):
                index +=1
                e = float(lines[index].strip().split()[0])
                e_f = e-efermi
                fdos.write('%15.8f ' % (e_f))
                
                for col in xrange(1, ncols):
                    dos = float(lines[index].strip().split()[col])
                    fdos.write('%15.8f ' % (dos))
                    col +=1
                fdos.write('\n ')             
                n +=1
            i+=1
    fdos.close()

def write_spin(lines, index, nedos, natoms, ncols, efermi):
    #pos=[]
    atoms = read_posfile()
    if len(atoms) < natoms:
            pos = np.zeros((natoms, 3))
    else:
            pos = atoms.get_positions()

    nsites = (ncols -1)/2
   
    for i in xrange(1,natoms+1):
            si = str(i)
    ## OPEN DOSi FOR WRITING ##
        fdos = open("DOS"+si, 'w')
        index +=2
        ia = i-1
            fdos.write('# %d \n' % (ncols))
        fdos.write('# %15.8f %15.8f %15.8f \n' % (pos[ia,0], pos[ia,1], pos[ia,2]))
   
    ### LOOP OVER NEDOS ###
        for n in xrange(1,nedos):
                index +=1   
                e = float(lines[index].strip().split()[0])
                e_f = e-efermi
                fdos.write('%15.8f ' % (e_f))
                
                for col in xrange(1, nsites):
                        dos_up = float(lines[index].strip().split()[col])
                        dos_down = float(lines[index].strip().split()[col+1])*-1
                        fdos.write('%15.8f %15.8f ' % (dos_up, dos_down))
                        col +=1
                fdos.write('\n ')
                n +=1
            i+=1
            fdos.close()


#
if __name__ == '__main__':
        import sys
        import os
        import datetime
        import time
        import optparse

        lines, index, natoms, nedos, efermi = read_dosfile()
        index = write_dos0(lines, index, nedos, efermi)
        ##Test if there a spin calculation was performed ##
        line = lines[index+2].strip().split()
        ncols = int(len(line))
        if ncols==7 or ncols==19 or ncols==9 or ncols==33:
                write_spin(lines, index, nedos, natoms, ncols, efermi)
                is_spin=True
        else:
                write_nospin(lines, index, nedos, natoms, ncols, efermi)
                is_spin=False
        print "Spin unrestricted calculation: ", is_spin
    #if is_spin:
    #        write_spin(lines, index, ncols, natoms, nedos, efermi)
    #else:
   #         write_nospin(lines, index, ncols, natoms, nedos, efermi)
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sulisha_agrh

新虫 (小有名气)

上边的是split_dos.py代码下边贡献一个split_dos(需要vp)代码
#!/bin/ksh


# Script to break the VASP DOSCAR file into segments for
# each atomic site.
# JMS NRL 5/0/02

# Modified to also align the Fermi level from the ground state
# to E=0.0
# JMS NRL 6/19/02

# Modified to be compatible to LORBIT=11
# weibingchen.thu@gmail.com
# 2009.11.1


# Executables reside here
#BIN=~/bin/vtstscripts
# GH: replace this so that it looks for vp in the same directory as this script
EXE=$0
BIN=${EXE%/*}

if [ $# -ne 0 ]; then
"split_dos" 230L, 5859C
2楼2015-04-29 18:43:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

huterx

金虫 (小有名气)

【答案】应助回帖


感谢参与,应助指数 +1
ljw4010: 金币+1, 谢谢交流! 2015-04-30 20:36:45
建议你用最新版的vaspkit 直接就分出来了 非常好用
3楼2015-04-30 07:58:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sulisha_agrh

新虫 (小有名气)

引用回帖:
3楼: Originally posted by huterx at 2015-04-30 07:58:55
建议你用最新版的vaspkit 直接就分出来了 非常好用

谢谢
4楼2015-04-30 19:21:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 sulisha_agrh 的主题更新
信息提示
请填处理意见