def test_check_points_2(): tag = '19c9e217-4159-4bfe-9c3a-940fb40e023e' tag = 'd054780c-f051-4450-a611-d374d41d1884' tag = 'ed85a69b-4054-41d4-a724-7373934cdcc6' tag = '8e7b216d-c6b6-4da4-905e-e7afd44195aa' vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) EV, POSCAR, INCAR = get_rec_from_metatag(vasp_db, tag, test=True) structure = Structure.from_str(POSCAR, fmt='POSCAR') proc = EVcheck_QHA(db_file=db_file, metadata={'tag': tag}, structure=structure, deformations=np.linspace(0.94, 1.06, 7), test=True) proc.run_task({})
def EV_find(self): evdirhome = 'E-V' if not os.path.exists(evdirhome): os.mkdir(evdirhome) hit = [] count = [] phases = [] volumes = [] ITEMS = [] potname = [] fp_ev = open(os.path.join(evdirhome, "E-V.dat"), "w") for i in self.items: mm = i['metadata']['tag'] els = i['elements'] if self.skipby("", mm, els=els): continue if self.hit_condition is not None: if mm not in self.hit_condition: continue if mm in hit: volume = i['output']['structure']['lattice']['volume'] if volume not in volumes[hit.index(mm)]: volumes[hit.index(mm)].append(volume) count[hit.index(mm)] += 1 else: ITEMS.append(i) hit.append(mm) count.append(1) volumes.append([i['output']['structure']['lattice']['volume']]) potsoc = get_used_pot(i) structure = Structure.from_dict(i['output']['structure']) formula_pretty = structure.composition.reduced_formula try: formula2composition(formula_pretty) except: formula_pretty = reduced_formula( structure.composition.alphabetical_formula) sa = SpacegroupAnalyzer(structure) phasename = formula_pretty+'_'\ + sa.get_space_group_symbol().replace('/','.')+'_'+str(sa.get_space_group_number()) potname.append(potsoc) if phasename in phases: for jj in range(10000): nphasename = phasename + "#" + str(jj) if nphasename in phases: continue phasename = nphasename break phases.append(phasename) blank_lines = False for i, mm in enumerate(hit): if self.hit_condition is not None: if mm not in self.hit_condition: continue if self.qhamode == 'phonon': if self.hit_count[mm] < self.nV: continue if count[i] < self.nV: continue if self.skipby(phases[i], mm): continue EV, POSCAR, INCAR = get_rec_from_metatag(self.vasp_db, mm) metadata = {'tag': mm} pname = phases[i].split('#') if len(pname) > 1: phases[i] = pname[0] + potname[i] + EV[ 'MagState'] + '#' + pname[1] else: phases[i] = pname[0] + potname[i] + EV['MagState'] if EV['natoms'] < self.natoms: continue sys.stdout.write('{}, static: {:>2}, natoms: {:>3}, {}\n'.format( metadata, count[i], EV['natoms'], phases[i])) folder = os.path.join(evdirhome, phases[i]) if not os.path.exists(folder): os.mkdir(folder) with open(os.path.join(folder, 'POSCAR'), 'w') as fp: fp.write(POSCAR) readme = {} readme['E-V'] = EV readme['INCAR'] = INCAR readme['POSCAR'] = POSCAR natoms = readme['E-V']['natoms'] with open(os.path.join(folder, 'readme'), 'w') as fp: myjsonout(readme, fp, indent="", comma="") i_energies = np.array(EV['energies']) / natoms i_volumes = np.array(EV['volumes']) / natoms val, idx = min((val, idx) for (idx, val) in enumerate(i_energies)) if blank_lines: print("\n", file=fp_ev) blank_lines = True print("#phase:", phases[i], file=fp_ev) print("#metadata:", mm, file=fp_ev) print("#natoms:", natoms, file=fp_ev) elist = ['Fe', 'Cu', 'Se', 'Al', 'Ni', 'Co', 'Pt', 'Ta', 'O'] el = [] nel = [] if len(EV['magmoms']) > 0: fp_ev.write("#magmoms:") magmoms = EV['magmoms'][idx] m0 = magmoms[0] n0 = 1 for j in range(1, len(magmoms)): if magmoms[j] == m0: n0 += 1 else: if n0 == 1: fp_ev.write('{},'.format(m0)) else: fp_ev.write('{}*{},'.format(n0, m0)) idx = len(el) % len(elist) el.append(elist[idx]) nel.append(n0) n0 = 1 m0 = magmoms[j] if n0 == 1: fp_ev.write('{}\n'.format(m0)) else: fp_ev.write('{}*{}\n'.format(n0, m0)) idx = len(el) % len(elist) el.append(elist[idx]) nel.append(n0) lines = [l for l in POSCAR.split('\n') if l != ""] with open(os.path.join(folder, phases[i] + '.VASP'), 'w') as fp: for j in range(0, 5): print(lines[j], file=fp) for j in range(len(el)): fp.write(' {}'.format(el[j])) fp.write('\n') for j in range(len(nel)): fp.write(' {}'.format(nel[j])) fp.write('\n') print(lines[7], file=fp) for j in range(8, len(lines)): print(lines[j], float(list(magmoms[j - 8].values())[0]), file=fp) for j in range(len(i_volumes)): print(i_volumes[j], i_energies[j], file=fp_ev) thermoplot(folder, "0 K total energies (eV/atom)", i_volumes, i_energies)
def EV_find(self): hit = [] count = [] phases = [] volumes = [] ITEMS = [] for i in self.items: try: mm = i['metadata']['tag'] except: continue if mm in hit: volume = i['output']['structure']['lattice']['volume'] if volume not in volumes[hit.index(mm)]: volumes[hit.index(mm)].append(volume) count[hit.index(mm)] += 1 #if mm=='5252ccc3-e8da-499f-bb9e-9cf7eb1c5370': print("eeeeeeeee",mm, pot) else: ITEMS.append(i) hit.append(mm) count.append(1) volumes.append([i['output']['structure']['lattice']['volume']]) pot = i['input']['pseudo_potential']['functional'].upper() #if mm=='5252ccc3-e8da-499f-bb9e-9cf7eb1c5370': print("eeeeeeeee",mm, pot) if pot == "": pot = i['orig_inputs']['potcar']['functional'].upper() if pot == 'Perdew-Zunger81'.upper(): pot = "LDA" try: pot += "+" + i['input']['GGA'] except: pass if i['input']['is_hubbard']: pot += '+U' try: if i['input']['incar']['LSORBIT']: potsoc = pot + "SOC" except: potsoc = pot structure = Structure.from_dict(i['output']['structure']) natoms = len(structure.sites) formula_pretty = structure.composition.reduced_formula try: formula2composition(formula_pretty) except: formula_pretty = reduced_formula( structure.composition.alphabetical_formula) sa = SpacegroupAnalyzer(structure) phasename = formula_pretty+'_'\ + sa.get_space_group_symbol().replace('/','.')+'_'+str(sa.get_space_group_number())+potsoc if phasename in phases: for jj in range(10000): nphasename = phasename + "#" + str(jj) if nphasename in phases: continue phasename = nphasename break phases.append(phasename) for i, m in enumerate(hit): if count[i] < self.nV: continue if self.skipby(phases[i]): continue sys.stdout.write('{}, static: {:>2}, {}\n'.format( m, count[i], phases[i])) EV, POSCAR, INCAR = get_rec_from_metatag(self.vasp_db, m) evdir = './E-V/' if not os.path.exists(evdir): os.mkdir(evdir) folder = evdir + phases[i] if not os.path.exists(folder): os.mkdir(folder) with open(folder + '/POSCAR', 'w') as fp: fp.write(POSCAR) readme = {} readme['E-V'] = EV readme['INCAR'] = INCAR readme['POSCAR'] = POSCAR with open(folder + '/readme', 'w') as fp: myjsonout(readme, fp, indent="", comma="") thermoplot(folder, "0 K total energies (eV/atom)", EV['volumes'], EV['energies'])