How to use the dpgen.auto_test.lib.lammps.make_lammps_equi 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 / gen_00_equi.py View on Github external
else :
        os.chdir(equi_path)
        os.symlink(os.path.relpath(from_poscar), 'POSCAR')
        os.chdir(cwd)
    # lmp path
    lmp_path = os.path.join(equi_path, task_type)
    os.makedirs(lmp_path, exist_ok = True)    
    print(lmp_path)
    # lmp conf
    conf_file = os.path.join(lmp_path, 'conf.lmp')
    lammps.cvt_lammps_conf(to_poscar, os.path.relpath(conf_file))
    ptypes = vasp.get_poscar_types(to_poscar)
    lammps.apply_type_map(conf_file, type_map, ptypes)    
    # lmp input
    if task_type=='deepmd':
        fc = lammps.make_lammps_equi(os.path.basename(conf_file), 
                                 ntypes, 
                                 lammps.inter_deepmd, 
                                 model_name)
    elif task_type=='meam':
        fc = lammps.make_lammps_equi(os.path.basename(conf_file), 
                                 ntypes, 
                                 lammps.inter_meam, 
                                 model_param)
    with open(os.path.join(lmp_path, 'lammps.in'), 'w') as fp :
        fp.write(fc)
    # link models
    os.chdir(lmp_path)
    for ii in model_name :
        if os.path.exists(ii) :
            os.remove(ii)
    for (ii,jj) in zip(models, model_name) :
github deepmodeling / dpgen / dpgen / auto_test / gen_00_equi.py View on Github external
lmp_path = os.path.join(equi_path, task_type)
    os.makedirs(lmp_path, exist_ok = True)    
    print(lmp_path)
    # lmp conf
    conf_file = os.path.join(lmp_path, 'conf.lmp')
    lammps.cvt_lammps_conf(to_poscar, os.path.relpath(conf_file))
    ptypes = vasp.get_poscar_types(to_poscar)
    lammps.apply_type_map(conf_file, type_map, ptypes)    
    # lmp input
    if task_type=='deepmd':
        fc = lammps.make_lammps_equi(os.path.basename(conf_file), 
                                 ntypes, 
                                 lammps.inter_deepmd, 
                                 model_name)
    elif task_type=='meam':
        fc = lammps.make_lammps_equi(os.path.basename(conf_file), 
                                 ntypes, 
                                 lammps.inter_meam, 
                                 model_param)
    with open(os.path.join(lmp_path, 'lammps.in'), 'w') as fp :
        fp.write(fc)
    # link models
    os.chdir(lmp_path)
    for ii in model_name :
        if os.path.exists(ii) :
            os.remove(ii)
    for (ii,jj) in zip(models, model_name) :
        os.symlink(os.path.relpath(ii), jj)
    os.chdir(cwd)
github deepmodeling / dpgen / dpgen / auto_test / EAM_ALLOY_LMP.py View on Github external
scale2equi = task_param['scale2equi']
        if 'reprod_opt' in task_param:
            reprod_opt = task_param['reprod_opt']
        if 'static-opt' in task_param:
            static = task_param['static-opt']

        model_name = os.path.basename(self.model)

        model_param = {'model_name': model_name,
                       'param_type': self.type_map}

        fc = ''
        if task_type == 'relaxation' \
                or (task_type == 'eos' and not change_box) \
                or (task_type == 'surface' and not static):
            fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param,
                                         etol, ftol, maxiter, maxeval, change_box)

        if task_type == 'static' \
                or (task_type == 'surface' and static):
            fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param)

        if task_type == 'elastic':
            fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param,
                                            etol, ftol, maxiter, maxeval)

        if task_type == 'vacancy' \
                or (task_type == 'eos' and change_box) \
                or (task_type == 'interstitial' and not reprod_opt):
            fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_eam_alloy,
                                                model_param, B0, bp, etol, ftol, maxiter, maxeval)
github deepmodeling / dpgen / dpgen / auto_test / DEEPMD_LMP.py View on Github external
reprod_opt = task_param['reprod_opt']
        if 'static-opt' in task_param:
            static = task_param['static-opt']

        model_name = os.path.basename(self.model)
        deepmd_version = self.inter.get("deepmd_version", "0.12")

        model_param = {'model_name': [model_name],
                       'param_type': self.type_map,
                       'deepmd_version': deepmd_version}

        fc = ''
        if task_type == 'relaxation' \
                or (task_type == 'eos' and not change_box) \
                or (task_type == 'surface' and not static):
            fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_deepmd, model_param,
                                         etol, ftol, maxiter, maxeval, change_box)

        if task_type == 'static' \
                or (task_type == 'surface' and static):
            fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_deepmd, model_param)

        if task_type == 'elastic':
            fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_deepmd, model_param,
                                            etol, ftol, maxiter, maxeval)

        if task_type == 'vacancy' \
                or (task_type == 'eos' and change_box) \
                or (task_type == 'interstitial'):
            fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_deepmd,
                                                model_param, B0, bp, etol, ftol, maxiter, maxeval)
        if reprod_opt:
github deepmodeling / dpgen / dpgen / auto_test / MEAM_LMP.py View on Github external
scale2equi = task_param['scale2equi']
        if 'reprod_opt' in task_param:
            reprod_opt = task_param['reprod_opt']
        if 'static-opt' in task_param:
            static = task_param['static-opt']

        model_name = list(map(os.path.basename,self.model))

        model_param = {'model_name': model_name,
                       'param_type': self.type_map}

        fc = ''
        if task_type == 'relaxation' \
                or (task_type == 'eos' and not change_box) \
                or (task_type == 'surface' and not static):
            fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_meam, model_param,
                                         etol, ftol, maxiter, maxeval, change_box)

        if task_type == 'static' \
                or (task_type == 'surface' and static):
            fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_meam, model_param)

        if task_type == 'elastic':
            fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_meam, model_param,
                                            etol, ftol, maxiter, maxeval)

        if task_type == 'vacancy' \
                or (task_type == 'eos' and change_box) \
                or (task_type == 'interstitial'):
            fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_meam,
                                                model_param, B0, bp, etol, ftol, maxiter, maxeval)
github deepmodeling / dpgen / dpgen / auto_test / gen_05_surf.py View on Github external
os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    # gen strcture
    ss = Structure.from_file(task_poscar)
    # gen slabs
    all_slabs = generate_all_slabs(ss, max_miller, min_slab_size, min_vacuum_size)
    # make lammps.in
    if task_type =='deepmd':
        if static :
            fc = lammps.make_lammps_eval('conf.lmp',
                                     ntypes,
                                     lammps.inter_deepmd,
                                     model_name)
        else :
            fc = lammps.make_lammps_equi('conf.lmp',
                                     ntypes,
                                     lammps.inter_deepmd,
                                     model_name,
                                     change_box = relax_box)
    elif task_type =='meam':
        if static :
            fc = lammps.make_lammps_eval('conf.lmp',
                                     ntypes,
                                     lammps.inter_meam,
                                     model_param)
        else :
            fc = lammps.make_lammps_equi('conf.lmp',
                                     ntypes,
                                     lammps.inter_meam,
                                     model_param,
                                     change_box = relax_box)
github deepmodeling / dpgen / dpgen / auto_test / gen_05_surf.py View on Github external
lammps.inter_deepmd,
                                     model_name)
        else :
            fc = lammps.make_lammps_equi('conf.lmp',
                                     ntypes,
                                     lammps.inter_deepmd,
                                     model_name,
                                     change_box = relax_box)
    elif task_type =='meam':
        if static :
            fc = lammps.make_lammps_eval('conf.lmp',
                                     ntypes,
                                     lammps.inter_meam,
                                     model_param)
        else :
            fc = lammps.make_lammps_equi('conf.lmp',
                                     ntypes,
                                     lammps.inter_meam,
                                     model_param,
                                     change_box = relax_box)
    f_lammps_in = os.path.join(task_path, 'lammps.in')
    with open(f_lammps_in, 'w') as fp :
        fp.write(fc)
    cwd = os.getcwd()

    os.chdir(task_path)
    for ii in model_name :
        if os.path.exists(ii) :
            os.remove(ii)
    for (ii,jj) in zip(models, model_name) :
        os.symlink(os.path.relpath(ii), jj)
    share_models = [os.path.join(task_path,ii) for ii in model_name]
github deepmodeling / dpgen / dpgen / auto_test / gen_01_eos.py View on Github external
cwd = os.getcwd()
    volume = vasp.poscar_vol(task_poscar)
    natoms = vasp.poscar_natoms(task_poscar)
    vpa = volume / natoms
    # structrure
    ss = Structure.from_file(task_poscar)
    # make lammps.in
    if task_type=='deepmd':
        fc = lammps.make_lammps_equi('conf.lmp', 
                                 ntypes, 
                                 lammps.inter_deepmd, 
                                 model_name, 
                                 change_box = False)
    elif task_type=='meam':
        fc = lammps.make_lammps_equi('conf.lmp', 
                                 ntypes, 
                                 lammps.inter_meam, 
                                 model_param, 
                                 change_box = False)
    f_lammps_in = os.path.join(task_path, 'lammps.in')
    with open(f_lammps_in, 'w') as fp :
        fp.write(fc)

    os.chdir(task_path)
    for ii in model_name :
        if os.path.exists(ii) :
            os.remove(ii)
    for (ii,jj) in zip(models, model_name) :
        os.symlink(os.path.relpath(ii), jj)
    share_models = [os.path.join(task_path,ii) for ii in model_name]