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

²é¿´: 2506  |  »Ø¸´: 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Ò»ÇøT0PÎÄÕ£¬ÎÒ:8.O.55.1.O.5.4,¿ÆÄ¿È«,¿É+¼± +3 Qj98d49dHFb9 2026-08-25 5/250 2026-08-26 04:57 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
[»ù½ðÉêÇë] 2026Äê8ÔÂ25ÈÕ¹ú×ÔÈ»·Å°ñǰͻȻÊÕµ½ÁÐÈëÆÀÉóר¼ÒÓʼþ£¬ÓйØÏµÂ𣿠+17 ľˮ˼¶¹ 2026-08-25 20/1000 2026-08-26 01:26 by chengyan1220
[»ù½ðÉêÇë] ½ñÌìÎñί»á¿ªÍêÁË£¬Ã÷Ìì³ö½á¹ûÂð +18 angus9576 2026-08-25 22/1100 2026-08-26 00:41 by merchancy
[»ù½ðÉêÇë] ÔÚ¼á±ù»¹¸Ç×ű±º£µÄʱºò£¬ÎÒ¿´µ½ÁËÅ­·ÅµÄ÷»¨¡£ (½ð±Ò+10) +6 ziyangfang 2026-08-25 9/450 2026-08-25 20:26 by huagongfeihu
[»ù½ðÉêÇë] ÓÐûÓдóÉñ°ïÎÒ¿´¿´»ù½ð´úÂë 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
[»ù½ðÉêÇë] ½ñÈÕ²»·Å°ñ£¿Íø´«¹ú×ÔȻԤ¼Æ 8 Ô 27 Èտɲé½á¹û +17 ҽѧÀÏÄк¢ 2026-08-20 22/1100 2026-08-25 15:36 by ҽѧÀÏÄк¢
[»ù½ðÉêÇë] ûÓÐÈκÎÏûÏ¢-ÊDz»ÊǾÍÁ¹ÁË +9 ͼÀ²Í¼À² 2026-08-24 10/500 2026-08-25 11:59 by ÄϺ£Ð¡¸ç
[»ù½ðÉêÇë] ÈËÆø²»ÐÐÁË +11 fansofjerry 2026-08-21 11/550 2026-08-25 11:04 by ¹Â¶ÀµÄÓ¢ÐÛ6
[½Ìʦ֮¼Ò] µ¼Ê¦Í²ۣºÎÒÔõô̯ÉÏÁËÕâô¸ö¼«Æ·Ñо¿Éú£¡ +3 ËÕ¶«ÆÂ¶þÊÀ 2026-08-23 3/150 2026-08-25 10:35 by shisan1313
[»ù½ðÉêÇë] 2026ÄêµÄ¹ú¼ÒÉç¿Æ»ù½ðÏîĿͨѶÆÀÉóµÄйæÔòÓëж¯Ïò¡¢ÐÂÌôÕ½ +5 process2012 2026-08-23 7/350 2026-08-25 09:42 by huixian257
[»ù½ðÉêÇë] ½ñÌì»ù½ð»á³ö½á¹ûÂð£¿20260819 +17 kkkl_v 2026-08-19 18/900 2026-08-25 09:41 by windflowerwy
[»ù½ðÉêÇë] ÎÒÃæÉÏÍêµ°ÁË +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
[»ù½ðÉêÇë] ÈÃÎÒÖÐÒ»¸öÃæÉϰɣ¡ +13 ´óƼ1987 2026-08-20 16/800 2026-08-24 10:23 by ̫ɵÁË
[»ù½ðÉêÇë] ¿ÆÑй¶ùÌ«ÄÑÁË +18 ÎÒ4´ó°×²Ë 2026-08-20 19/950 2026-08-24 09:47 by ¿­¶÷¹ãÊ¢´ß»¯·ÖÎ
[½Ìʦ֮¼Ò] Ìø²ÛºóÔÚÑÐÏîÄ¿Ôõô°ì£¿ +5 ¼òµ¥»¯xn 2026-08-22 10/500 2026-08-23 12:38 by ¼òµ¥»¯xn
[»ù½ðÉêÇë] ¿´À´½ñÌì²»»á·Å°ñÁË£¿ +8 chengyan1220 2026-08-21 11/550 2026-08-21 17:52 by dcqxinyang
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û