Exemplo n.º 1
0
def VaspNEBCheckRMS():
    print('CheckNEBRMS is running...')
    if '00' in os.listdir() and 'INCAR' in os.listdir():
        data_INCAR = zzd.File.openFile('./INCAR')
        data_log = zzd.File.openFile('./log')
        image = zzd.File.getLine(data_INCAR,
                                 'IMAGES')[0].split('=')[-1].strip('\n')
        #print(zzd.File.getAllline(data_log,'F='))
        ionstep = zzd.File.getAllline(data_log, 'F=')[-1].split()[0]
        if int(image) <= 9:
            #print('aa')
            #data00 = zzd.getshellResult('grep RMS 00/OUTCAR')
            data01 = zzd.getshellResult('grep RMS 01/OUTCAR')
            data02 = zzd.getshellResult('grep RMS 02/OUTCAR')
            data03 = zzd.getshellResult('grep RMS 03/OUTCAR')
            #data04 = zzd.getshellResult('grep RMS 04/OUTCAR')
            #print(data00)
            print('{:^3}{:^10}{:^10}{:^10}{:^10}'.format(
                'Step', '01-RMS', '02-RMS', '03-RMS', '01+02+03'))
            for i in range(int(ionstep)):
                print('{:>3}{:>10}{:>10}{:>10}{:>10.6f}'.format(
                    i + 1, data01[i].split()[4], data02[i].split()[4],
                    data03[i].split()[4],
                    float(data01[i].split()[4]) + float(data02[i].split()[4]) +
                    float(data03[i].split()[4])))
    else:
        print('不在NEB目录,退出程序')
        exit()
Exemplo n.º 2
0
def VaspNEBCheckDist(POSorCONT):
    if '00' in os.listdir() and 'INCAR' in os.listdir():
        data_log = zzd.File.openFile('./INCAR')
        image = zzd.File.getLine(data_log,
                                 'IMAGES')[0].split('=')[-1].strip('\n')
        if int(image) <= 9:
            #os.system('cp ini/CONTCAR 00/CONTCAR')
            #os.system('cp fin/CONTCAR 0'+str(int(image)+1)+'/CONTCAR')
            for i in range(0, int(image) + 1):
                if i == 0:
                    dist = zzd.getshellResult('dist.pl ./0' + str(i) +
                                              '/POSCAR ./0' + str(i + 1) +
                                              '/' + POSorCONT)
                elif i == int(image):
                    dist = zzd.getshellResult('dist.pl ./0' + str(i) + '/' +
                                              POSorCONT + ' ./0' + str(i + 1) +
                                              '/POSCAR')
                else:
                    dist = zzd.getshellResult('dist.pl ./0' + str(i) + '/' +
                                              POSorCONT + ' ./0' + str(i + 1) +
                                              '/' + POSorCONT)
                print('{}  0{}-0{}  {}'.format(POSorCONT, i, i + 1,
                                               dist[0].strip('\n')))
        else:
            print('image too large')
    else:
        print('当前不在NEB目录,退出程序')
        exit()
Exemplo n.º 3
0
def run2(ele):
	atoms = [53, 16, 12, 25, 14, 17, 23, 26, 39, 40, 37, 42, 31, 48, 27, 36, 30, 28, 13, 11, 5]
	fre1 = np.array([])
	for i in range(len(atoms)):
		atom = str(atoms[i])
		code = f'grep THz {ele}-Energies/{ele}-V/52Fe1{ele}1V/vib_analysis/atom{atom}/OUTCAR'
		result = zzdlib.getshellResult(code)
		fre = decode_vib_frequency(result)
		fre1 = np.concatenate((fre1, fre), axis=0)
	print(fre1.shape)

	vac_1nn = np.array([6.6160, 6.6107, 5.5804])
	vac_2nn = np.array([7.0517, 7.0461, 6.6759])
	item1 = np.power(np.prod(vac_1nn), 8) * np.power(np.prod(vac_2nn), 6)

	pure = np.array([7.0748, 7.0727, 7.0708])
	item2 = np.power(np.prod(pure), 8)

	sol = np.array([6.4545, 6.4515, 6.4482])
	sol_1nn = np.array([7.0020, 6.9931, 6.8190])
	sol_2nn = np.array([7.1250, 7.0793, 7.0716])
	item3 = np.prod(sol) * np.power(np.prod(sol_1nn), 8) * np.power(np.prod(sol_2nn), 6)

	item4 = np.prod(fre1)

	inner = item1 * item3 / item2 / item4
	Sb = np.log(inner)

	print(f'item1: {item1}\nitem2: {item2} \nitem3: {item3} \nitem4: {item4}\n inner: {inner} Sb: {Sb}')
Exemplo n.º 4
0
def get_Hm_and_v_from_raw():
    cases = 'w0_3nn,w1,w2,w3_2nn,w3_3nn,w3_4nn'.split(',')
    Hm_list = []
    v_list = []
    for i in range(len(cases)):
        case = cases[i]
        os.chdir(case)

        # 获取Hm
        # print(pys_path, os.getcwd())
        res = zzdlib.getshellResult(f'python3 {pys_path}/NEBCheck.py --func=2')
        # print(res)
        line, index = zzdlib.File.getLine(res, 'IMAGE')
        IMAGE = []
        Barrier = []
        # print(res)
        for j in range(index + 1, len(res)):
            if res[j] == '\n':
                break
            img = int(res[j].split()[0])
            barrier = float(res[j].split()[-1])
            IMAGE.append(img)
            Barrier.append(barrier)
        Hm_foreward = np.max(Barrier)
        Hm_backward = np.max(Barrier) - Barrier[-1]
        Hm_list.append(Hm_foreward)
        Hm_list.append(Hm_backward)

        # 获取v
        code = f'python3 {pys_path}/VaspVibAna_Result.py --isprint=True'
        res = zzdlib.getshellResult(code)
        v_foreward = zzdlib.File.getLine(res,
                                         keywords='foreward')[0].split()[-1]
        v_backward = zzdlib.File.getLine(res,
                                         keywords='backward')[0].split()[-1]
        if v_backward == 'Match':
            v_backward = '0'
        v_list.append(float(v_foreward))
        v_list.append(float(v_backward))
        os.chdir('..')
Exemplo n.º 5
0
def run(ele, correct=False):
	code1 = f'grep THz {ele}-Energies/{ele}-V/52Fe1{ele}1V/vib_analysis/*/OUTCAR'
	result1 = zzdlib.getshellResult(code1)
	fre1 = decode_vib_frequency(result1)

	code2 = f'grep THz {ele}-Energies/{ele}-V/53Fe1{ele}/vib_analysis/*/OUTCAR'
	result2 = zzdlib.getshellResult(code2)
	fre2 = decode_vib_frequency(result2)

	print(fre1.shape, fre2.shape)

	# 主要是因为bcc_withCr 中 52Fe1Cr1V的atom46原子振动计算没有完成,fre1缺少一个原子的振动数据,用其他的原子的振动的平均值补充上去
	if correct:
		number = fre1.shape[0]
		row = int(number/3)
		print(f'总{number} 行{row}')
		fre1 = fre1.reshape(row, 3)
		fre1_mean = np.mean(fre1, axis=0)
		fre1_mean = fre1_mean.reshape(1, 3)
		fre1 = np.concatenate((fre1, fre1_mean), axis=0)
		fre1 = fre1.reshape(number+3)

	vac_1nn = np.array([6.6160, 6.6107, 5.5804])
	vac_2nn = np.array([7.0517, 7.0461, 6.6759])
	item1 = np.power(np.prod(vac_1nn), 8) * np.power(np.prod(vac_2nn), 6)

	pure = np.array([7.0748, 7.0727, 7.0708])
	item2 = np.power(np.prod(pure), 15)

	item4 = np.prod(fre1)
	item3 = np.prod(fre2)

	inner = item1 * item3 / item2 / item4
	Sb = np.log(inner)

	print(f'item1: {item1}\nitem2: {item2} \nitem3: {item3} \nitem4: {item4}\n inner: {inner} Sb: {Sb}')
Exemplo n.º 6
0
def grep_fre(path):
    code = f'grep THz {path}/OUTCAR'
    result = zzdlib.getshellResult(code)
    fre = decode_vib_frequency(result)
    return fre
Exemplo n.º 7
0
def getBarrier(IS='-1'):
    #IS代表输入的Ionstep,根据IS获取该步时候的扩散势垒
    Path = []
    Barrier = []
    Step = []
    Image = []
    runpath = os.getcwd()
    for dirpath, dirnames, filenames in os.walk('./'):
        if 'INCAR' in filenames and 'POTCAR' in filenames and 'KPOINTS' in filenames:
            data_INCAR = zzd.File.openFile(dirpath + '/INCAR', 'r')
            #print('dir',data_INCAR[0].split('=')[-1])
            if 'NEB' in data_INCAR[0].split('=')[-1]:
                #print('NEB')
                data_Sh = zzd.File.openFile(dirpath + '/Vasp.sh', 'r')
                jobname = zzd.File.getLine(
                    data_Sh, '#PBS -N')[0].split()[-1][:10]  #获取任务名,且只取前10个字符
                stat = zzd.Vasp.checkJobstatus(jobname)
                if stat == 'R' or stat == 'Q':
                    print('路径{} NEB计算正在{}'.format(dirpath, stat))
                elif 'log' in os.listdir(dirpath):  #未提交或者已经算完:
                    data_log = zzd.File.openFile(dirpath + '/log', 'r')
                    isRA = zzd.File.getLine(data_log,
                                            'reached required accuracy')[0]
                    images = zzd.File.getLine(data_INCAR,
                                              'IMAGES')[0].split('=')[-1]
                    Fstep = zzd.File.getLine(data_INCAR,
                                             'NSW')[0].split('=')[-1]
                    ionstep = zzd.File.getAllline(data_log,
                                                  'F=')[-1].split()[0]
                    if 'reached required accuracy' in isRA or Fstep == ionstep:
                        #print('RA')
                        barriers = []
                        os.chdir(dirpath)
                        if IS == '-1':  #默认用nebef.pl获取势垒
                            nebef = zzd.getshellResult('nebef.pl')
                            for inn in nebef:
                                barriers.append(float(inn.split()[3]))
                        else:  #获取输出的步数IS,计算该步数下的势垒。
                            try:
                                data_OUTini = zzd.File.openFile(
                                    './00/OUTCAR', 'r')
                                Eini = zzd.File.getAllline(
                                    data_OUTini,
                                    'energy without entropy')[-1].split()[-1]
                                data_OUTfin = zzd.File.openFile(
                                    './0' + str(int(images) + 1) + '/OUTCAR',
                                    'r')
                                Efin = zzd.File.getAllline(
                                    data_OUTini,
                                    'energy without entropy')[-1].split()[-1]
                                barriers.append(float(Eini) - float(Eini))
                                for ii in range(1, int(images) + 1):
                                    data = zzd.File.openFile(
                                        './0' + str(ii) + '/stdout', 'r')
                                    Ener = zzd.File.getLine(
                                        data, IS + ' F=')[0].split()[4]
                                    barriers.append(float(Ener) - float(Eini))
                            except Exception as e:
                                print('获取第{}步势垒出现问题,提示为:{}'.format(IS, e))
                        Barrier.append(max(barriers))
                        Step.append(ionstep)
                        Path.append(dirpath[:18])
                        Image.append(images)
                        os.chdir(runpath)
                    else:
                        print('{} 未达到收敛标准或者计算步数未满,退出'.format(dirpath))
                else:
                    print('出现了奇怪的问题')
    print('{:<20}{:<10}{:<5}{:<3}'.format('path', 'barrier', 'step', 'images'))
    for i in range(len(Barrier)):
        print('{:<20}{:<10.7f}{:<5}{:<3}'.format(Path[i], Barrier[i], Step[i],
                                                 Image[i]))
Exemplo n.º 8
0
def CheckWARNING(usript):
    #usrinput为1时,只打印是否完成,为2时候,只打印能量信息,为3时,打印全部
    Path = []
    Energy = []
    Step = []
    mag = []
    dist = []
    RMS = []
    warnflag = 0
    jstat = ['Running...', 'Done', 'SC Running...', 'SC done', 'Stoped']
    for dirpath, dirnames, filenames in os.walk('./'):
        if 'INCAR' in filenames and 'POSCAR' in filenames and 'Vasp.sh' in filenames:
            data_Sh = zzd.File.openFile(dirpath + '/Vasp.sh', 'r')
            data_INCAR = zzd.File.openFile(dirpath + '/INCAR', 'r')
            SYSTEM = zzd.File.getLine(data_INCAR, 'SYSTEM')[0].split('=')[-1]
            jobname = zzd.File.getLine(data_Sh,
                                       '#PBS -N')[0].strip('\n').split()[-1]
            jobstatus = zzd.Vasp.checkJobstatus(jobname)
            #print('Path:{}  {}   {}'.format(dirpath,jobstatus,jobname))
            if jobstatus == 'Q':
                print('Path:{:<60}任务正在排队...   '.format(dirpath))
            elif jobstatus == 'R' or 'log' in filenames:  #正在计算和算完了用相同的检测方法
                if usript == '1' or usript == '3':
                    data_log = zzd.File.openFile(dirpath + '/log', 'r')
                    reachRA = zzd.File.getLine(data_log,
                                               'reached required accuracy')[0]
                    try:
                        RMM = zzd.File.getAllline(data_log,
                                                  'RMM:')[-1].split()[1]
                        RMM = RMM + ' RMM'
                    except:
                        RMM = '0 RMM'
                    try:
                        DAV = zzd.File.getAllline(data_log,
                                                  'DAV:')[-1].split()[1]
                        DAV = DAV + ' DAV'
                    except:
                        DAV = '0 DAV'
                    termination = zzd.File.getLine(
                        data_log, 'Ctrl-C caught... cleaning up processes')[0]
                    try:
                        ionstep = zzd.File.getAllline(data_log,
                                                      'F=')[-1].split()[0]
                    except:
                        ionstep = '0'
                    #print('Path:{}  {}   {}'.format(dirpath,reachRA,v1F))
                    if 'reached required accuracy' in reachRA:
                        print('Path:{:<60}{:<15}{:>3}F{:>9}'.format(
                            dirpath, jstat[1], ionstep, RMM))
                    elif SYSTEM == 'Self' or SYSTEM == 'Static' or SYSTEM == 'self' or SYSTEM == 'static':
                        vRMM = zzd.File.getLine(data_log, 'RMM:')[0]
                        vDAV = zzd.File.getLine(data_log, 'DAV:')[0]
                        if ('DAV:' in vDAV
                                or 'RMM:' in vRMM) and ionstep == '0':
                            print('Path:{:<60}{:<15}{:>3}F{:>9}{:>7}{:>5}'.
                                  format(dirpath, jstat[2], ionstep, RMM, DAV,
                                         '*'))
                        elif ionstep == '1':  #没有完成,但有1F了
                            print('Path:{:<60}{:<15}{:>3}F{:>9}'.format(
                                dirpath, jstat[3], ionstep, RMM))
                    elif 'cleaning up processes' in termination:
                        print('Path:{:<60}{:<15}{:>3}F{:>9}{:>7}'.format(
                            dirpath, jstat[4], ionstep, RMM, DAV))
                    else:
                        print('Path:{:<60}{:<15}{:>3}F{:>9}{:>7}{:>5}'.format(
                            dirpath, jstat[0], ionstep, RMM, DAV, '*'))

                    # 检查警告
                    try:
                        data_OUTCAR = zzd.File.openFile(
                            dirpath + '/OUTCAR', 'r')
                        WARNING_log = zzd.File.getAllline(data_log, 'WARNING')
                        WARNING_OUT = zzd.File.getAllline(
                            data_OUTCAR, 'WARNING')
                        ERROR_log = zzd.File.getAllline(data_log, 'ERROR')
                        if WARNING_log != [] or WARNING_OUT != []:
                            print('Path:{:<60}    出现警告'.format(
                                dirpath, ionstep))
                            zzd.File.printData(WARNING_log)
                            zzd.File.printData(WARNING_OUT)
                            warnflag = 1
                        if ERROR_log != []:
                            zzd.File.printData(ERROR_log)
                            warnflag = 1
                    except Exception as e:
                        print('path:{} {}'.format(dirpath, e))

                if usript == '2' or usript == '3':
                    #打印能量信息
                    data_log = zzd.File.openFile(dirpath + '/log', 'r')
                    try:
                        log_lastF = zzd.File.getAllline(data_log, 'F=')[-1]
                    except:
                        log_lastF = '0 F= 0 E0= 0  d E 0  mag=    0'  #在存在log,Log中连1步都没算完的时候
                    if len(dirpath) > 15:
                        path = '...' + dirpath[-15:]
                    else:
                        path = dirpath
                    Path.append(path)
                    Energy.append(log_lastF.split()[4])
                    Step.append(log_lastF.split()[0])
                    try:
                        mag.append(log_lastF.split()[9])
                    except:
                        mag.append('0')
                    dist.append(
                        zzd.getshellResult('dist.pl ' + dirpath + '/POSCAR ' +
                                           dirpath +
                                           '/CONTCAR')[-1].strip('\n'))
                    try:
                        RMS.append(
                            zzd.getshellResult('grep RMS ' + dirpath +
                                               '/OUTCAR')[-1].split()[4])
                    except:  #如果出现没算完,grep返回一个空的列表的时候
                        RMS.append('0')

    if (usript == '1' or usript == '3') and warnflag == 0:
        print('无警告或错误')
    if (usript == '2' or usript == '3'):
        print('{:<18}{:<11}{:<5}{:^10}{:^10}{:^10}'.format(
            '路径', '能量', '步数', 'mag', 'dist', 'RMS'))
        for i in range(len(Path)):
            print('{:<20}{:<13.4f}{:<7}{:<12.4f}{:<10.4f}{:<10.4f}'.format(
                Path[i], eval(Energy[i]), Step[i], eval(mag[i]), eval(dist[i]),
                eval(RMS[i])))