24СʱÈÈÃŰæ¿éÅÅÐаñ    

²é¿´: 2507  |  »Ø¸´: 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 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[»ù½ðÉêÇë] ͶƱ:  ÓжàÉÙÈËÊǽñÌì²éϵͳ֪µÀ½á¹ûµÄ£¿ +14 °®¿´ÊéµÄ¿ÉÀÖ 2026-08-26 16/800 2026-08-26 20:25 by skyjudy
[»ù½ðÉêÇë] ÎÒ²»Àí½â£¡ +14 Edward_pc 2026-08-26 22/1100 2026-08-26 20:19 by Edward_pc
[»ù½ðÉêÇë] ¹ú×ÔÈ»ÃæÉϸ´ÅÌ~»¶Ó­ÌÖÂÛ +3 ÇçÌì¼ÓÓÍ 2026-08-26 4/200 2026-08-26 17:59 by Tide man
[»ù½ðÉêÇë] ϵͳ²é²»µ½ +10 ¶­°Ëǧ 2026-08-26 10/500 2026-08-26 16:30 by Equinoxhua
[»ù½ðÉêÇë] »ù½ð²»ÖУ¬¹²Ãã +3 eulota 2026-08-26 3/150 2026-08-26 16:17 by ·yyyy
[»ù½ðÉêÇë] Ôõô²é°¡ +5 huang1991js 2026-08-26 5/250 2026-08-26 16:09 by Equinoxhua
[»ù½ðÉêÇë] ·¶½øÖоÙÒ»ÎĵÄÖÐÐÄ˼Ïë +9 Ñ׻ƹóëÐ 2026-08-22 10/500 2026-08-26 15:40 by semaglutide
[»ù½ðÉêÇë] 2026Äê8ÔÂ25ÈÕ¹ú×ÔÈ»·Å°ñǰͻȻÊÕµ½ÁÐÈëÆÀÉóר¼ÒÓʼþ£¬ÓйØÏµÂ𣿠+25 ľˮ˼¶¹ 2026-08-25 28/1400 2026-08-26 14:53 by draco1987
[»ù½ðÉêÇë] ÄÜ·ñÍ˳ö²ÎÓëµÄÃæÉÏÏîÄ¿½â³ýÏÞÏî +23 koalala 2026-08-24 26/1300 2026-08-26 14:29 by ±¦±´³æ×Ó
[»ù½ðÉêÇë] ϵͳ½ø²»È¥ +4 yanglien 2026-08-26 5/250 2026-08-26 11:10 by wenfengw83
[»ù½ðÉêÇë] Ôõô¿´Çà»ùÖÐÁËûÓа¡ +4 Ò¶¾Å΢ 2026-08-26 4/200 2026-08-26 10:52 by xiacongxu
[Ö°³¡ÈËÉú] ѧÉúײ¼û¸¨µ¼Ô±ËÍÍâÂô£¬µÚ¶þÌìÈ«°à¶¼³ÁĬÁË +3 ¾¨ÓãÈÚ½ð_Õã½­_É 2026-08-22 3/150 2026-08-26 09:01 by zzuzxg
[»ù½ðÉêÇë] ¹úºÏÏÖÔڲ鲻µ½ÁËÂ𣿠+10 chengyan1220 2026-08-24 20/1000 2026-08-26 08:57 by peasantsprig
[»ù½ðÉêÇë] ÔÚ¼á±ù»¹¸Ç×ű±º£µÄʱºò£¬ÎÒ¿´µ½ÁËÅ­·ÅµÄ÷»¨¡£ (½ð±Ò+10) +6 ziyangfang 2026-08-25 9/450 2026-08-25 20:26 by huagongfeihu
[»ù½ðÉêÇë] ½ñÈÕ²»·Å°ñ£¿Íø´«¹ú×ÔȻԤ¼Æ 8 Ô 27 Èտɲé½á¹û +17 ҽѧÀÏÄк¢ 2026-08-20 22/1100 2026-08-25 15:36 by ҽѧÀÏÄк¢
[»ù½ðÉêÇë] ÈËÆø²»ÐÐÁË +11 fansofjerry 2026-08-21 11/550 2026-08-25 11:04 by ¹Â¶ÀµÄÓ¢ÐÛ6
[»ù½ðÉêÇë] ÎÒÃæÉÏÍêµ°ÁË +13 ÇÒÌý»¢Ð¥ 2026-08-20 14/700 2026-08-25 09:10 by mrkang
[½Ìʦ֮¼Ò] Ìø²ÛºóÔÚÑÐÏîÄ¿Ôõô°ì£¿ +5 ¼òµ¥»¯xn 2026-08-22 10/500 2026-08-23 12:38 by ¼òµ¥»¯xn
[»ù½ðÉêÇë] ʱ¼ä´ÁÓÖ±äÁË +13 wuchongjun 2026-08-20 19/950 2026-08-21 17:21 by ×Ïɼ´¼
[»ù½ðÉêÇë] Ó¦¸ÃÊÇÏÂÖÜÈý26ÈÕ¹«²¼Á˰ɣ¿ +4 ¹þ¹þ¸ò£¿ 2026-08-21 4/200 2026-08-21 10:58 by Vivilian
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û