How to use the dpgen.auto_test.lib.lammps.cvt_lammps_conf 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_06_phonon.py View on Github external
task_poscar = os.path.join(task_path, 'POSCAR')
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR') :
        os.remove('POSCAR')
    os.symlink(os.path.relpath(conf_poscar), 'POSCAR')
    os.chdir(cwd)    
    with open(task_poscar,'r') as fp :
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    
    print(task_path)
    # make conf.lmp  
    conf_file = os.path.join(task_path, 'conf.lmp')
    lammps.cvt_lammps_conf(task_poscar, os.path.relpath(conf_file))
    ptypes = vasp.get_poscar_types(task_poscar)
    lammps.apply_type_map(conf_file, type_map, ptypes) 
    # make lammps.in
    ntypes=len(ele_list)
    unitcell=get_structure_from_poscar(task_poscar)
    if task_type=='deepmd':
        fc = lammps.make_lammps_phonon('conf.lmp', 
                                    unitcell.masses, 
                                    lammps.inter_deepmd,
                                    model_name)
    if task_type=='meam':
        fc = lammps.make_lammps_phonon('conf.lmp', 
                                    unitcell.masses, 
                                    lammps.inter_meam,
                                    model_param)      
    f_lammps_in = os.path.join(task_path, 'lammps.in')
github deepmodeling / dpgen / dpgen / auto_test / MEAM_LMP.py View on Github external
def make_input_file(self,
                        output_dir,
                        task_type,
                        task_param):
        lammps.cvt_lammps_conf(os.path.join(output_dir, 'POSCAR'), os.path.join(output_dir,'conf.lmp'))
        with open(os.path.join(output_dir, 'task.json'), 'w') as fp:
            json.dump(task_param, fp, indent=4)
        # lines in lammps.in related to model
        #         line_model = "pair_style      meam \n"
        #         line_model += "pair_coeff      * * %s " % (os.path.basename(self.model[0]))
        #         for ii in self.type_map:
        #             line_model += ii + ' '
        #         line_model += "%s " % (os.path.basename(self.model[1]))
        #         for ii in self.type_map:
        #             line_model += ii + ' '
        #         line_model += '\n'

        etol = 1e-12
        ftol = 1e-6
        maxiter = 5000
        maxeval = 500000
github deepmodeling / dpgen / dpgen / auto_test / DEEPMD_LMP.py View on Github external
def make_input_file(self,
                        output_dir,
                        task_type,
                        task_param):
        lammps.cvt_lammps_conf(os.path.join(output_dir, 'POSCAR'), os.path.join(output_dir,'conf.lmp'))
        with open(os.path.join(output_dir, 'task.json'), 'w') as fp:
            json.dump(task_param, fp, indent=4)
        # lines in lammps.in related to model
        #        line_model = lammps.inter_deepmd(self.inter)
        #        line_model = "pair_style deepmd %s \n" % (os.path.basename(self.model))
        #        line_model += "pair_coeff\n

        etol = 1e-12
        ftol = 1e-6
        maxiter = 5000
        maxeval = 500000
        change_box = True
        B0 = 70
        bp = 0
        scale2equi = 1
        ntypes = len(self.type_map)
github deepmodeling / dpgen / dpgen / auto_test / EAM_FS_LMP.py View on Github external
def make_input_file(self,
                        output_dir,
                        task_type,
                        task_param):
        lammps.cvt_lammps_conf(os.path.join(output_dir, 'POSCAR'), os.path.join(output_dir,'conf.lmp'))
        with open(os.path.join(output_dir, 'task.json'), 'w') as fp:
            json.dump(task_param, fp, indent=4)
        # lines in lammps.in related to model
        #         line_model = "pair_style      eam/fs \n"
        #         line_model += "pair_coeff      * * %s " % (os.path.basename(self.model))
        #         for ii in self.type_map:
        #             line_model += ii + ' '
        #         line_model += '\n'

        etol = 1e-12
        ftol = 1e-6
        maxiter = 5000
        maxeval = 500000
        change_box = True
        B0 = 70
        bp = 0
github deepmodeling / dpgen / dpgen / auto_test / gen_04_interstitial.py View on Github external
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]

    for ii in range(len(dss)) :
        struct_path = os.path.join(task_path, 'struct-%s-%s-%03d' % (insert_ele,copy_str,ii))
        print('# generate %s' % (struct_path))
        os.makedirs(struct_path, exist_ok=True)
        os.chdir(struct_path)
        for jj in ['conf.lmp', 'lammps.in'] + model_name :
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        dss[ii].to('POSCAR', 'POSCAR')
        lammps.cvt_lammps_conf('POSCAR', 'conf.lmp')
        ptypes = vasp.get_poscar_types('POSCAR')
        lammps.apply_type_map('conf.lmp', type_map, ptypes)
        # link lammps.in
        os.symlink(os.path.relpath(f_lammps_in), 'lammps.in')
        # link models
        for (ii,jj) in zip(share_models, model_name) :
            os.symlink(os.path.relpath(ii), jj)
        # save supercell
        np.savetxt('supercell.out', supercell, fmt='%d')
    os.chdir(cwd)
github deepmodeling / dpgen / dpgen / auto_test / gen_07_SScurve.py View on Github external
os.symlink(os.path.relpath(ii), jj)
        share_models = glob.glob(os.path.join(task_path, '*pb'))
    else:
        share_models = models

    for ii in range(n_dfm) :
        # make dir
        dfm_path = os.path.join(task_path, 'dfm-%03d' % ii)
        os.makedirs(dfm_path, exist_ok=True)
        os.chdir(dfm_path)
        for jj in ['conf.lmp', 'lammps.in'] + model_name :
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        deformed_structures[ii].to('POSCAR', 'POSCAR')
        lammps.cvt_lammps_conf('POSCAR', 'conf.lmp')
        ptypes = vasp.get_poscar_types('POSCAR')
        lammps.apply_type_map('conf.lmp', type_map, ptypes)    
        # record strain
        strain = Strain.from_deformation(deformations[ii])
        np.savetxt('strain.out', strain)
        # link lammps.in
        os.symlink(os.path.relpath(f_lammps_in), 'lammps.in')
        # link models
        for (ii,jj) in zip(share_models, model_name) :
            os.symlink(os.path.relpath(ii), jj)
    cwd = os.getcwd()
github deepmodeling / dpgen / dpgen / auto_test / gen_04_interstitial.py View on Github external
frame_path = 'frame.%06d' % ii
            os.makedirs(frame_path, exist_ok=True)
            os.chdir(frame_path)
            # clear dir
            for jj in ['conf.lmp'] :
                if os.path.isfile(jj):
                    os.remove(jj)
            for jj in ['lammps.in'] + model_name :
                if os.path.islink(jj):
                    os.unlink(jj)
            # link lammps in
            os.symlink(os.path.relpath('../lammps.in'), 'lammps.in')
            # make conf
            with open('POSCAR', 'w') as fp :
                fp.write('\n'.join(xdat_lines[ii*xdat_secsize:(ii+1)*xdat_secsize]))
            lammps.cvt_lammps_conf('POSCAR', 'conf.lmp')
            ptypes = vasp.get_poscar_types('POSCAR')
            lammps.apply_type_map('conf.lmp', type_map, ptypes)
            # link models
            for (kk,ll) in zip(share_models, model_name) :
                os.symlink(os.path.relpath(kk), ll)
            os.chdir(ls)
        os.chdir(cwd)
github deepmodeling / dpgen / dpgen / auto_test / gen_01_eos.py View on Github external
share_models = [os.path.join(task_path,ii) for ii in model_name]

    # make vols
    for vol in np.arange(vol_start, vol_end, vol_step) :
        vol_path = os.path.join(task_path, 'vol-%.2f' % vol)        
        print('# generate %s' % (vol_path))
        os.makedirs(vol_path, exist_ok = True)
        os.chdir(vol_path)
        for ii in ['conf.lmp', 'conf.lmp', 'lammps.in'] + model_name :
            if os.path.exists(ii) :
                os.remove(ii)                
        # make conf
        scale_ss = ss.copy()
        scale_ss.scale_lattice(vol * natoms)
        scale_ss.to('POSCAR', 'POSCAR')
        lammps.cvt_lammps_conf('POSCAR', 'conf.lmp')
        ptypes = vasp.get_poscar_types('POSCAR')
        lammps.apply_type_map('conf.lmp', type_map, ptypes)
        # link lammps.in
        os.symlink(os.path.relpath(f_lammps_in), 'lammps.in')
        # link models
        for (ii,jj) in zip(share_models,model_name) :
            os.symlink(os.path.relpath(ii), jj)
        # make lammps input
        os.chdir(cwd)
github deepmodeling / dpgen / dpgen / auto_test / gen_03_vacancy.py View on Github external
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]

    for ii in range(len(dss)) :
        struct_path = os.path.join(task_path, 'struct-%s-%03d' % (copy_str,ii))
        print('# generate %s' % (struct_path))
        os.makedirs(struct_path, exist_ok=True)
        os.chdir(struct_path)
        for jj in ['conf.lmp', 'lammps.in'] + model_name :
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        dss[ii].to('POSCAR', 'POSCAR')
        lammps.cvt_lammps_conf('POSCAR', 'conf.lmp')
        ptypes = vasp.get_poscar_types('POSCAR')
        lammps.apply_type_map('conf.lmp', type_map, ptypes)
        # link lammps.in
        os.symlink(os.path.relpath(f_lammps_in), 'lammps.in')
        # link models
        for (ii,jj) in zip(share_models, model_name) :
            os.symlink(os.path.relpath(ii), jj)
        # save supercell
        np.savetxt('supercell.out', supercell, fmt='%d')
    os.chdir(cwd)