def cont(calc): import HighThroughput.manage.calculation as manage baks = 0 bako = 0 bakx = 0 bakt = 0 for file in os.listdir(os.curdir): if os.path.isfile(file) and file[0:10] == 'POSCAR.bak': baks += 1 if os.path.isfile(file) and file[0:10] == 'OUTCAR.bak': bako += 1 if os.path.isfile(file) and file[0:11] == 'XDATCAR.bak': bakx += 1 if os.path.isfile(file) and file[0:11] == 'tempout.bak': bakt += 1 if os.path.isfile('CONTCAR') and os.stat('CONTCAR').st_size > 0: os.rename('POSCAR','POSCAR.bak' + str(baks)) os.rename('CONTCAR','POSCAR') if os.path.isfile('OUTCAR') and os.stat('OUTCAR').st_size > 0: os.rename('OUTCAR','OUTCAR.bak' + str(bako)) if os.path.isfile('XDATCAR') and os.stat('XDATCAR').st_size > 0: os.rename('XDATCAR','XDATCAR.bak' + str(bakx)) if os.path.isfile('tempout') and os.stat('tempout').st_size > 0: os.rename('tempout','tempout.bak' + str(bakt)) psettings = manage.getSettings(calc['parent']) if 'continued' not in psettings.keys(): psettings['continued'] = 1 else: psettings['continued'] += 1 manage.updateSettings(psettings, calc['parent']) return calc
def cont(calc, settings): import HighThroughput.manage.calculation as manage bakc = 0 bakl = 0 for file in os.listdir(os.curdir): if os.path.isfile(file) and file[6:10] == '.com': baks += 1 if os.path.isfile(file) and file[6:10] == '.log': bako += 1 if os.path.isfile(settings['name'] + '.com') and os.stat(settings['name'] + '.com').st_size > 0: shutil.copy(COMname, COMname + '.bak' + str(baks)) # if 'SCF=Restart' not in settings['route']: # settings['route'] += ' SCF=Restart' if os.path.isfile(settings['name'] + '.log') and os.stat(settings['name'] + '.log').st_size > 0: os.rename(settings['name'] + '.log', settings['name'] + '.log' + '.bak' + str(bako)) psettings = manage.getSettings(calc['parent']) if 'continued' not in psettings.keys(): psettings['continued'] = 1 else: psettings['continued'] += 1 manage.updateSettings(psettings, calc['parent']) return calc
def cont(calc): import HighThroughput.manage.calculation as manage baks = 0 bako = 0 bakx = 0 bakt = 0 for file in os.listdir(os.curdir): if os.path.isfile(file) and file[0:10] == 'POSCAR.bak': baks += 1 if os.path.isfile(file) and file[0:10] == 'OUTCAR.bak': bako += 1 if os.path.isfile(file) and file[0:11] == 'XDATCAR.bak': bakx += 1 if os.path.isfile(file) and file[0:11] == 'tempout.bak': bakt += 1 if os.path.isfile('CONTCAR') and os.stat('CONTCAR').st_size > 0: os.rename('POSCAR','POSCAR.bak' + str(baks)) os.rename('CONTCAR','POSCAR') if os.path.isfile('OUTCAR') and os.stat('OUTCAR').st_size > 0: os.rename('OUTCAR','OUTCAR.bak' + str(bako)) if os.path.isfile('XDATCAR') and os.stat('XDATCAR').st_size > 0: os.rename('XDATCAR','XDATCAR.bak' + str(bakx)) if os.path.isfile('tempout') and os.stat('tempout').st_size > 0: os.rename('tempout','tempout.bak' + str(bakt)) psettings = manage.getSettings(calc['parent']) presults = manage.getResults(calc['parent']) if 'continued' not in psettings.keys(): psettings['continued'] = 1 else: psettings['continued'] += 1 if presults.get('settingsmod') != None: if presults['settingsmod'].get('KPOINTS').get('K') != None and calc['settings']['KPOINTS'].get('K') != None: curkp = [int(x) for x in calc['settings']['KPOINTS']['K'].split(' ')] curmod = [int(x) for x in presults['settingsmod']['KPOINTS']['K'].split(' ')] calc['settings']['KPOINTS']['K'] = ' '.join([str(curkp[x] + curmod[x]) for x in range(3)]) if 'ENCUT' in presults['settingsmod'].keys(): calc['settings']['INCAR']['ENCUT'] = int(calc['settings']['INCAR']['ENCUT']) + presults['settingsmod']['INCAR']['ENCUT'] manage.updateSettings(psettings, calc['parent']) manage.updateResults(presults, calc['parent']) return calc
def cont(calc,settings): import HighThroughput.manage.calculation as manage bakc = 0 bakl = 0 for file in os.listdir(os.curdir): if os.path.isfile(file) and file[6:10] == '.com': baks += 1 if os.path.isfile(file) and file[6:10] == '.log': bako += 1 if os.path.isfile(settings['name'] + '.com') and os.stat(settings['name'] + '.com').st_size > 0: shutil.copy(COMname,COMname + '.bak' + str(baks)) # if 'SCF=Restart' not in settings['route']: # settings['route'] += ' SCF=Restart' if os.path.isfile(settings['name'] + '.log') and os.stat(settings['name'] + '.log').st_size > 0: os.rename(settings['name'] + '.log',settings['name'] + '.log' + '.bak' + str(bako)) psettings = manage.getSettings(calc['parent']) if 'continued' not in psettings.keys(): psettings['continued'] = 1 else: psettings['continued'] += 1 manage.updateSettings(psettings, calc['parent']) return calc
print( 'Energy OK. Ending calculation, deleting junk files and fetching results.' ) HT.end(cinfo['id']) #cleanup function # Can change this to a step dictionary os.remove('CHG') print('Updating settings.') # Update POTCAR INFO POTCAR_version = execute('grep -a \'TITEL\' POTCAR | awk \'{ print $4 }\'') cinfo['settings']['POTCAR'] = POTCAR_version.strip().replace('\n', ', ') HT.updateSettings(cinfo['settings'], cinfo['id']) # Update priority with Machine Learning model #if step == 21: # updateMLPriority(cinfo['queue'], 42) stat_info = os.stat(qdir) uid = stat_info.st_uid gid = stat_info.st_gid for root, dirs, files in os.walk( os.path.join(qdir, 'CALCULATIONS', cinfo['file'])): for momo in dirs: try: os.chown(os.path.join(root, momo), -1, gid) os.chmod(os.path.join(root, momo), 0o774)
def cont(calc): print('DEBUG: continue') baks = 0 bako = 0 bakx = 0 bakt = 0 bakv = 0 for file in os.listdir(os.curdir): if os.path.isfile(file) and file[0:10] == 'POSCAR.bak': baks += 1 if os.path.isfile(file) and file[0:10] == 'OUTCAR.bak': bako += 1 if os.path.isfile(file) and file[0:11] == 'XDATCAR.bak': bakx += 1 if os.path.isfile(file) and file[0:11] == 'tempout.bak': bakt += 1 if os.path.isfile(file) and file[0:11] == 'vasprun.bak': bakv += 1 if os.path.isfile('CONTCAR') and os.stat('CONTCAR').st_size > 0: os.rename('POSCAR', 'POSCAR.bak' + str(baks)) os.rename('CONTCAR', 'POSCAR') if os.path.isfile('OUTCAR') and os.stat('OUTCAR').st_size > 0: os.rename('OUTCAR', 'OUTCAR.bak' + str(bako)) if os.path.isfile('XDATCAR') and os.stat('XDATCAR').st_size > 0: os.rename('XDATCAR', 'XDATCAR.bak' + str(bakx)) if os.path.isfile('tempout') and os.stat('tempout').st_size > 0: os.rename('tempout', 'tempout.bak' + str(bakt)) if os.path.isfile('vasprun.xml') and os.stat('vasprun.xml').st_size > 0: os.rename('vasprun.xml', 'vasprun.bak' + str(bakv)) psettings = manage.getSettings(calc['parent']) presults = manage.getResults(calc['parent']) if 'continued' not in psettings.keys(): psettings['continued'] = 1 else: psettings['continued'] += 1 if presults.get('settingsmod') is not None: if presults['settingsmod'].get('KPOINTS') is not None and calc[ 'settings'].get('KPOINTS') is not None: if presults['settingsmod'].get('KPOINTS').get( 'K') is not None and calc['settings']['KPOINTS'].get( 'K') is not None: curkp = [ int(x) for x in calc['settings']['KPOINTS']['K'].split(' ') ] curmod = [ int(x) for x in presults['settingsmod']['KPOINTS']['K'].split(' ') ] calc['settings']['KPOINTS']['K'] = ' '.join( [str(curkp[x] + curmod[x]) for x in range(3)]) if presults.get('settingsmod').get('INCAR') is not None: if presults.get('settingsmod').get('INCAR').get( 'ENCUT') is not None: calc['settings']['INCAR']['ENCUT'] = int(calc['settings']['INCAR']['ENCUT']) + \ presults['settingsmod']['INCAR']['ENCUT'] if presults.get('settingsmod').get('INCAR').get( 'SIGMA') is not None: calc['settings']['INCAR']['SIGMA'] = presults['settingsmod'][ 'INCAR']['SIGMA'] if presults.get('settingsmod').get('INCAR').get( 'ISMEAR') is not None: if int(calc['settings']['INCAR']['ISMEAR']) != -5: calc['settings']['INCAR']['ISMEAR'] = presults[ 'settingsmod']['INCAR']['ISMEAR'] if presults.get('settingsmod').get('INCAR').get( 'ISPIN') is not None: calc['settings']['INCAR']['ISPIN'] = presults['settingsmod'][ 'INCAR']['ISPIN'] manage.updateSettings(psettings, calc['parent']) manage.updateResults(presults, calc['parent']) return calc
nc = round(norm(c), 3) results['a'] = na results['b'] = nb results['c'] = nc results['alpha'] = round(degrees(arccos(dot(b, c) / nb / nc)), 1) results['beta'] = round(degrees(arccos(dot(c, a) / nc / na)), 1) results['gamma'] = round(degrees(arccos(dot(a, b) / na / nb)), 1) print('Updating results') print results HT.updateResults(results, cid) print('Updating settings') print settings HT.updateSettings(settings, cid) #RELOOP to the script #exit() #No new calculations allowed. cid_new = HT.fetch(qid) print('Fetched calculation ' + str(cid_new) + ' from queue ' + str(qid) + '.') os.chdir(qdir + '/LOGFILES') if int(cid_new) > 0: print('Queue not empty: submit new job.') execute(' ssh login1 "~/bin/HTtools/QZPsubmit_reeosleuven ' + str(qid) + ' ' + str(argv[2]) + ' ' + str(argv[3]) + ' ' + str(argv[4]) + '"')
if step == 1: results['E0PBE'] = energy else: results['E0HSE06'] = energy results['E0PBE'] = float(execute('grep \'energy without entropy\' ../STEP1/OUTCAR | tail -1 | awk \'{ print $4 }\'')) print('Updating results') print results # updateresults could be assumed from dictionary keys and automated. HT.updateResults(results, cid) print('Updating settings') print settings HT.updateSettings(settings, cid) #RELOOP to the script cid_new = HT.fetch(qid) print('Fetched calculation '+str(cid_new)+' from queue '+str(qid)+'.') os.chdir(qdir+'/LOGFILES') if int(cid_new) > 0: # print('Script ONCE: do not submit new job') #execute('vaspsubmit ' + str(qid) + ' ' + str(submit_arg)) else: print('No calculations left; end script without submitting new job.')
) HT.end(cid) #cleanup function os.remove('CHG') results = json.loads(cinfo['results']) #could leave this out when working with QZP's energy = float(energy) if status == 1: results['E0PBE'] = energy else: results['E0HSE06'] = energy results['E0PBE'] = float( execute( 'grep \'energy without entropy\' ../STEP1/OUTCAR | tail -1 | awk \'{ print $4 }\'' )) print('Updating results') # updateresults could be assumed from dictionary keys and automated. HT.updateResults(results, cid) print('Updating settings') HT.updateSettings(cinfo['settings'], cid) newcalc = int(HT.fetch(str(qid))) print(str(newcalc)) if int(HT.fetch(str(qid))) > 0 and int(qid) != 167 and int(qid) != 171: execute('betaHSE ' + str(qid) + ' ' + str(submit_arg)) # -*- coding: utf-8 -*-