def cmpt_deepmd_lammps(jdata, conf_dir, task_name, static = False) : equi_path = re.sub('confs', global_equi_name, conf_dir) equi_path = os.path.join(equi_path, task_name.split('-')[0]) equi_path = os.path.abspath(equi_path) equi_log = os.path.join(equi_path, 'log.lammps') task_path = re.sub('confs', global_task_name, conf_dir) task_path = os.path.join(task_path, task_name) task_path = os.path.abspath(task_path) equi_natoms, equi_epa, equi_vpa = lammps.get_nev(equi_log) struct_path_widecard = os.path.join(task_path, 'struct-*-m*m') struct_path_list = glob.glob(struct_path_widecard) struct_path_list.sort() if len(struct_path_list) == 0: print("# cannot find results for conf %s" % (conf_dir)) sys.stdout.write ("Miller_Indices: \tSurf_E(J/m^2) EpA(eV) equi_EpA(eV)\n") result = os.path.join(task_path,'result') with open(result,'w') as fp: fp.write('conf_dir:%s\n'% (conf_dir)) fp.write("Miller_Indices: \tSurf_E(J/m^2) EpA(eV) equi_EpA(eV)\n") for ii in struct_path_list : structure_dir = os.path.basename(ii) lmp_log = os.path.join(ii, 'log.lammps') natoms, epa, vpa = lammps.get_nev(lmp_log) AA = lammps.get_base_area(lmp_log) Cf = 1.60217657e-16 / (1e-20 * 2) * 0.001 evac = (epa * natoms - equi_epa * natoms) / AA * Cf sys.stdout.write ("%s: \t%7.3f %8.3f %8.3f\n" % (structure_dir, evac, epa, equi_epa)) fp.write("%s:\t %7.3f %8.3f %8.3f\n" % (structure_dir, evac, epa, equi_epa)) fp.close() if 'upload_username' in jdata.keys() and task_name=='deepm': upload_username=jdata['upload_username'] util.insert_data('surf','deepmd',upload_username,result)
def cmpt_deepmd_lammps(jdata, conf_dir, task_name, static=False): equi_path = re.sub('confs', global_equi_name, conf_dir) equi_path = os.path.join(equi_path, task_name.split('-')[0]) equi_path = os.path.abspath(equi_path) equi_log = os.path.join(equi_path, 'log.lammps') task_path = re.sub('confs', global_task_name, conf_dir) task_path = os.path.join(task_path, task_name) task_path = os.path.abspath(task_path) equi_natoms, equi_epa, equi_vpa = lammps.get_nev(equi_log) struct_path_widecard = os.path.join(task_path, 'struct-*-m*m') struct_path_list = glob.glob(struct_path_widecard) struct_path_list.sort() if len(struct_path_list) == 0: print("# cannot find results for conf %s" % (conf_dir)) sys.stdout.write("Miller_Indices: \tSurf_E(J/m^2) EpA(eV) equi_EpA(eV)\n") for ii in struct_path_list: structure_dir = os.path.basename(ii) lmp_log = os.path.join(ii, 'log.lammps') natoms, epa, vpa = lammps.get_nev(lmp_log) AA = lammps.get_base_area(lmp_log) Cf = 1.60217657e-16 / (1e-20 * 2) * 0.001 evac = (epa * natoms - equi_epa * natoms) / AA * Cf sys.stdout.write("%s: \t%7.3f %8.3f %8.3f\n" % (structure_dir, evac, epa, equi_epa))
def _compute_lower(self, output_file, all_tasks, all_res): output_file = os.path.abspath(output_file) res_data = {} ptr_data = os.path.dirname(output_file) + '\n' if not self.reprod: ptr_data += "Miller_Indices: \tSurf_E(J/m^2) EpA(eV) equi_EpA(eV)\n" for ii in all_tasks: with open(os.path.join(ii, 'inter.json')) as fp: idata = json.load(fp) inter_type = idata['type'] equi_path = os.path.abspath( os.path.join(os.path.dirname(output_file), '../relaxation')) structure_dir = os.path.basename(ii) if inter_type == 'vasp': equi_outcar = os.path.join(equi_path, 'OUTCAR') equi_natoms, equi_epa, equi_vpa = vasp.get_nev(equi_outcar) outcar = os.path.join(ii, 'OUTCAR') natoms, epa, vpa = vasp.get_nev(outcar) if self.static: e0 = np.array(vasp.get_energies(outcar)) / natoms epa = e0[0] boxes = vasp.get_boxes(outcar) AA = np.linalg.norm(np.cross(boxes[0][0], boxes[0][1])) elif inter_type in ['deepmd', 'meam', 'eam_fs', 'eam_alloy']: equi_log = os.path.join(equi_path, 'log.lammps') equi_natoms, equi_epa, equi_vpa = lammps.get_nev(equi_log) lmp_log = os.path.join(ii, 'log.lammps') natoms, epa, vpa = lammps.get_nev(lmp_log) AA = lammps.get_base_area(lmp_log) else: raise RuntimeError('interaction type not supported') Cf = 1.60217657e-16 / (1e-20 * 2) * 0.001 evac = (epa * natoms - equi_epa * natoms) / AA * Cf ptr_data += "%s: \t%7.3f %8.3f %8.3f\n" % ( structure_dir, evac, epa, equi_epa) res_data[structure_dir] = [evac, epa, equi_epa] else: if 'vasp_path' not in self.parameter: raise RuntimeError( "please provide the vasp_path for reproduction") vasp_path = os.path.abspath(self.parameter['vasp_path']) res_data, ptr_data = reproduce.post_repro(vasp_path, all_tasks, ptr_data) with open(output_file, 'w') as fp: json.dump(res_data, fp, indent=4) return res_data, ptr_data