24小时热门版块排行榜    

查看: 2505  |  回复: 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一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 PbwVEMK5haaE 2026-08-25 4/200 2026-08-26 03:20 by cNXvBfCpiZOM
[考博] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 Qj98d49dHFb9 2026-08-25 4/200 2026-08-26 03:08 by cNXvBfCpiZOM
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 7K1CJE38xLG4 2026-08-25 4/200 2026-08-26 02:04 by cNXvBfCpiZOM
[论文投稿] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 7K1CJE38xLG4 2026-08-25 4/200 2026-08-26 02:04 by cNXvBfCpiZOM
[基金申请] 有没有大神帮我看看基金代码 28+4 1234567wang 2026-08-24 10/500 2026-08-25 19:15 by lfy8008
[基金申请] 放榜前的不淡定 20+4 snowwithsea 2026-08-19 19/950 2026-08-25 17:57 by chick875
[基金申请] 某些机构,以效率低为荣,以效率低作为存在感 +9 yuleib84 2026-08-25 10/500 2026-08-25 17:14 by alexon
[基金申请] 2026国自然函评费到账 +20 羊腰板 2026-08-21 23/1150 2026-08-25 16:34 by zsna
[基金申请] 今日不放榜?网传国自然预计 8 月 27 日可查结果 +17 医学老男孩 2026-08-20 22/1100 2026-08-25 15:36 by 医学老男孩
[基金申请] 没有任何消息-是不是就凉了 +9 图啦图啦 2026-08-24 10/500 2026-08-25 11:59 by 南海小哥
[教师之家] 导师吐槽:我怎么摊上了这么个极品研究生! +3 苏东坡二世 2026-08-23 3/150 2026-08-25 10:35 by shisan1313
[基金申请] 我面上完蛋了 +13 且听虎啸 2026-08-20 14/700 2026-08-25 09:10 by mrkang
[基金申请] 范进中举一文的中心思想 +7 炎黄贵胄 2026-08-22 8/400 2026-08-25 08:48 by ZJTJZ
[基金申请] 只有每年这种时候来逛逛小木虫 +25 yaoyewhu2008 2026-08-20 27/1350 2026-08-25 08:01 by Equinoxhua
[基金申请] 能否退出参与的面上项目解除限项 +21 koalala 2026-08-24 24/1200 2026-08-24 19:25 by 家与远方
[基金申请] 建议基金发布提前给出明确的时间点 +13 kulium 2026-08-21 16/800 2026-08-24 16:27 by superceng
[教师之家] 跳槽后在研项目怎么办? +5 简单化xn 2026-08-22 10/500 2026-08-23 12:38 by 简单化xn
[基金申请] 时间戳今天,20号变了 +5 archvillain 2026-08-20 5/250 2026-08-22 06:12 by hui_daxiao
[基金申请] 时间戳又变了 +13 wuchongjun 2026-08-20 19/950 2026-08-21 17:21 by 紫杉醇
[基金申请] 基金啊基金 +4 longfie172 2026-08-20 4/200 2026-08-21 08:58 by mark mao
信息提示
请填处理意见