24小时热门版块排行榜    

查看: 2522  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +5 6F5UbRU2I5hL 2026-09-14 5/250 2026-09-17 13:17 by ObVzqQQh1rrE
[找工作] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +4 mibUvS8DDCwf 2026-09-15 4/200 2026-09-17 06:26 by k06BKNblrGRH
[考博] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +4 vZfe6xYu34yj 2026-09-14 4/200 2026-09-17 05:50 by k06BKNblrGRH
[硕博家园] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 vZfe6xYu34yj 2026-09-14 3/150 2026-09-17 05:16 by k06BKNblrGRH
[公派出国] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +4 40ms4Wlo4umh 2026-09-14 4/200 2026-09-17 04:26 by k06BKNblrGRH
[硕博家园] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +5 40ms4Wlo4umh 2026-09-14 5/250 2026-09-17 04:14 by k06BKNblrGRH
[考研] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +5 23jxep3nCNZb 2026-09-14 5/250 2026-09-17 03:50 by k06BKNblrGRH
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 s3fFTmArrBt6 2026-09-14 3/150 2026-09-17 02:38 by Tql5LQhh5rLK
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +4 LwdutQ8HoqWP 2026-09-13 7/350 2026-09-17 02:02 by Tql5LQhh5rLK
[考研] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +7 LwdutQ8HoqWP 2026-09-13 7/350 2026-09-17 01:52 by Tql5LQhh5rLK
[公派出国] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +8 QUjhNVAcOSff 2026-09-13 11/550 2026-09-16 18:37 by rRvxEj3zorCy
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 6F5UbRU2I5hL 2026-09-14 3/150 2026-09-16 17:12 by i3KBRD19ERkG
[考博] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +4 6F5UbRU2I5hL 2026-09-14 4/200 2026-09-16 17:00 by i3KBRD19ERkG
[考博] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 s3fFTmArrBt6 2026-09-13 5/250 2026-09-16 15:48 by i3KBRD19ERkG
[找工作] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 Aj1rhIDL5ixY 2026-09-14 3/150 2026-09-16 07:12 by LH5NkK5Ud4bh
[硕博家园] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 0pYnUiPDfdnk 2026-09-14 3/150 2026-09-16 06:51 by LH5NkK5Ud4bh
[公派出国] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 Aj1rhIDL5ixY 2026-09-14 3/150 2026-09-15 19:59 by CgyNCDVNhGVg
[考博] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 6F5UbRU2I5hL 2026-09-14 3/150 2026-09-15 17:39 by CgyNCDVNhGVg
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 3n8v2C8RimXI 2026-09-13 5/250 2026-09-15 14:58 by CgyNCDVNhGVg
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +4 6F5UbRU2I5hL 2026-09-14 4/200 2026-09-15 08:02 by C79jjtjAKjEn
信息提示
请填处理意见