How to use the dpgen.auto_test.lib.lammps.get_nev function in dpgen

To help you get started, we’ve selected a few dpgen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deepmodeling / dpgen / dpgen / auto_test / cmpt_01_eos.py View on Github external
def comput_lmp_eos(jdata,conf_dir, task_name) :
    conf_path = re.sub('confs', global_task_name, conf_dir)
    conf_path = os.path.abspath(conf_path)
    conf_path = os.path.join(conf_path, task_name)
    vol_paths = glob.glob(os.path.join(conf_path, 'vol-*'))
    vol_paths.sort(key=lambda k : float(k.split('-')[-1]))
    result = os.path.join(conf_path,'result')
    print('Vpa(A^3)\tEpA(eV)')
    with open(result,'w') as fp:
        fp.write('conf_dir:%s\n VpA(A^3)  EpA(eV)\n'% (conf_dir))
        for ii in vol_paths :
            log_lammps = os.path.join(ii, 'log.lammps')
            natoms, epa, vpa = lammps.get_nev(log_lammps)
            print(vpa, epa)
            fp.write('%7.3f  %8.4f \n' % (vpa,epa))
    fp.close()
    if 'upload_username' in jdata.keys() and task_name =='deepmd':
        upload_username=jdata['upload_username']
        util.insert_data('eos','deepmd',upload_username,result)
github deepmodeling / dpgen / dpgen / auto_test / cmpt_04_interstitial.py View on Github external
def _cmpt_deepmd_lammps(jdata, conf_dir, supercell, insert_ele, task_name) :
    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)

    copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
    struct_path_widecard = os.path.join(task_path, 'struct-%s-%s-*' % (insert_ele,copy_str))
    struct_path_list = glob.glob(struct_path_widecard)
    print(struct_path_widecard)
    struct_path_list.sort()
    if len(struct_path_list) == 0:
        print("# cannot find results for conf %s supercell %s" % (conf_dir, supercell))
    sys.stdout.write ("Insert_ele-Struct: Inter_E(eV)  E(eV) equi_E(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 ("Insert_ele-Struct: Inter_E(eV)  E(eV) equi_E(eV)\n")
        for ii in struct_path_list :
            structure_dir = os.path.basename(ii)
            lmp_log = os.path.join(ii, 'log.lammps')
github deepmodeling / dpgen / dpgen / auto_test / cmpt_05_surf.py View on Github external
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)
github deepmodeling / dpgen / dpgen / auto_test / cmpt_03_vacancy.py View on Github external
def cmpt_deepmd_lammps(jdata, conf_dir, supercell, task_name) :
    equi_path = re.sub('confs', global_equi_name, conf_dir)
    equi_path = os.path.join(equi_path, task_name)
    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)
    print("# ", task_path)

    equi_natoms, equi_epa, equi_vpa = lammps.get_nev(equi_log)

    copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
    struct_path_widecard = os.path.join(task_path, 'struct-%s-*' % (copy_str))
    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 supercell %s" % (conf_dir, supercell))
    sys.stdout.write ("Structure: \tVac_E(eV)  E(eV) equi_E(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("Structure: \tVac_E(eV)  E(eV) equi_E(eV)\n")
        for ii in struct_path_list :
            struct_poscar = os.path.join(ii, 'POSCAR')
            #energy_shift = comput_e_shift(struct_poscar, task_name)
            structure_dir = os.path.basename(ii)
github deepmodeling / dpgen / dpgen / auto_test / cmpt_04_interstitial.py View on Github external
copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
    struct_path_widecard = os.path.join(task_path, 'struct-%s-%s-*' % (insert_ele,copy_str))
    struct_path_list = glob.glob(struct_path_widecard)
    print(struct_path_widecard)
    struct_path_list.sort()
    if len(struct_path_list) == 0:
        print("# cannot find results for conf %s supercell %s" % (conf_dir, supercell))
    sys.stdout.write ("Insert_ele-Struct: Inter_E(eV)  E(eV) equi_E(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 ("Insert_ele-Struct: Inter_E(eV)  E(eV) equi_E(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)
            evac = epa * natoms - equi_epa * natoms
            sys.stdout.write ("%s: %7.3f  %7.3f %7.3f \n" % (structure_dir, evac, epa * natoms, equi_epa * natoms))
            fp.write ("%s: %7.3f  %7.3f %7.3f \n" % (structure_dir, evac, epa * natoms, equi_epa * natoms))
    fp.close()
github deepmodeling / dpgen / dpgen / auto_test / cmpt_04_interstitial.py View on Github external
for vs in vasp_struct :
        # compute vasp
        outcar = os.path.join(vs, 'OUTCAR')
        vasp_ener = np.array(vasp.get_energies(outcar))
        vasp_ener_file = os.path.join(vs, 'ener.vasp.out')
        # compute reprod
        struct_basename  = os.path.basename(vs)
        ls = os.path.join(lmps_path, struct_basename)
        frame_widecard = os.path.join(ls, 'frame.*')
        frames = glob.glob(frame_widecard)
        frames.sort()
        lmp_ener = []
        for ii in frames :
            log_lmp = os.path.join(ii, 'log.lammps')
            natoms, epa, vpa = lammps.get_nev(log_lmp)
            lmp_ener.append(epa)
        lmp_ener = np.array(lmp_ener)
        lmp_ener = np.reshape(lmp_ener,  [-1,1])
        lmp_ener_file = os.path.join(ls, 'ener.lmp.out')
        vasp_ener = np.reshape(vasp_ener, [-1,1]) / natoms
        error_start = 1
        lmp_ener -= lmp_ener[-1] - vasp_ener[-1]
        diff = lmp_ener - vasp_ener
        diff = diff[error_start:]
        error = np.linalg.norm(diff) / np.sqrt(np.size(lmp_ener))
        np.savetxt(vasp_ener_file, vasp_ener[error_start:])
        np.savetxt(lmp_ener_file,  lmp_ener[error_start:])
        print(os.path.basename(ls), 'EpA_std_err=',error)