コード例 #1
0
 def post_process(self, task_list):
     cwd = os.getcwd()
     poscar_start = os.path.abspath(
         os.path.join(task_list[0], '..', 'POSCAR'))
     os.chdir(os.path.join(task_list[0], '..'))
     if os.path.isfile(os.path.join(task_list[0], 'INCAR')):
         incar = incar_upper(
             Incar.from_file(os.path.join(task_list[0], 'INCAR')))
         kspacing = incar.get('KSPACING')
         kgamma = incar.get('KGAMMA', False)
         ret = vasp.make_kspacing_kpoints(poscar_start, kspacing, kgamma)
         kp = Kpoints.from_string(ret)
         if os.path.isfile('KPOINTS'):
             os.remove('KPOINTS')
         kp.write_file("KPOINTS")
         os.chdir(cwd)
         kpoints_universal = os.path.abspath(
             os.path.join(task_list[0], '..', 'KPOINTS'))
         for ii in task_list:
             if os.path.isfile(os.path.join(ii, 'KPOINTS')):
                 os.remove(os.path.join(ii, 'KPOINTS'))
             if os.path.islink(os.path.join(ii, 'KPOINTS')):
                 os.remove(os.path.join(ii, 'KPOINTS'))
             os.chdir(ii)
             os.symlink(os.path.relpath(kpoints_universal), 'KPOINTS')
     os.chdir(cwd)
コード例 #2
0
def make_vasp(jdata, conf_dir, norm_def=2e-3, shear_def=5e-3):
    fp_params = jdata['vasp_params']
    ecut = fp_params['ecut']
    ediff = fp_params['ediff']
    npar = fp_params['npar']
    kpar = fp_params['kpar']
    kspacing = fp_params['kspacing']
    kgamma = fp_params['kgamma']
    strain_start = jdata['strain_start']
    strain_end = jdata['strain_end']
    strain_step = jdata['strain_step']
    strain_direct = jdata['strain_direct']

    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    # get equi poscar
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, 'vasp-k%.2f' % kspacing)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    # stress
    equi_outcar = os.path.join(equi_path, 'OUTCAR')
    stress = vasp.get_stress(equi_outcar)
    np.savetxt(os.path.join(task_path, 'equi.stress.out'), stress)
    # gen strcture
    ss = Structure.from_file(task_poscar)
    # gen defomations
    norm_strains = np.arange(strain_start, strain_end, strain_step)
    print('gen with norm ' + str(norm_strains))
    deformations = []
    for ii in norm_strains:
        strain = Strain.from_index_amount(strain_direct, ii)
        deformations.append(strain.get_deformation_matrix())
    deformed_structures = [
        defo.apply_to_structure(ss) for defo in deformations
    ]
    n_dfm = len(deformed_structures)
    # gen incar
    fc = vasp.make_vasp_relax_incar(ecut,
                                    ediff,
                                    True,
                                    False,
                                    False,
                                    npar=npar,
                                    kpar=kpar,
                                    kspacing=None,
                                    kgamma=None)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen potcar
    with open(task_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert (os.path.exists(potcar_map[ii]))
        potcar_list.append(potcar_map[ii])
    with open(os.path.join(task_path, 'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
    with open(os.path.join(task_path, 'KPOINTS'), 'w') as fp:
        fp.write(fc)
    # gen tasks
    cwd = os.getcwd()
    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 ['POSCAR', 'POTCAR', 'INCAR', 'KPOINTS']:
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        deformed_structures[ii].to('POSCAR', 'POSCAR')
        # record strain
        strain = Strain.from_deformation(deformations[ii])
        np.savetxt('strain.out', strain)
        # link incar, potcar, kpoints
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'POTCAR')),
                   'POTCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'KPOINTS')),
                   'KPOINTS')
    cwd = os.getcwd()
コード例 #3
0
ファイル: gen_02_elastic.py プロジェクト: y1xiaoc/dpgen
def make_vasp(jdata, conf_dir, norm_def = 2e-3, shear_def = 5e-3) :
    norm_def = jdata['norm_deform']
    shear_def = jdata['shear_deform']
    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')

    # get equi poscar
    if 'relax_incar' in jdata.keys():
        vasp_str='vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str='vasp-k%.2f' % kspacing

    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, vasp_str)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR') :
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    # stress
    equi_outcar = os.path.join(equi_path, 'OUTCAR')
    stress = vasp.get_stress(equi_outcar)
    np.savetxt(os.path.join(task_path, 'equi.stress.out'), stress)
    # gen strcture
    ss = Structure.from_file(task_poscar)
    # gen defomations
    norm_strains = [-norm_def, -0.5*norm_def, 0.5*norm_def, norm_def]
    shear_strains = [-shear_def, -0.5*shear_def, 0.5*shear_def, shear_def]
    dfm_ss = DeformedStructureSet(ss, 
                                  symmetry = False, 
                                  norm_strains = norm_strains,
                                  shear_strains = shear_strains)
    n_dfm = len(dfm_ss)
    # gen incar
    if  'relax_incar' in jdata.keys():
        relax_incar_path = jdata['relax_incar']
        assert(os.path.exists(relax_incar_path))
        relax_incar_path = os.path.abspath(relax_incar_path)
        fc = open(relax_incar_path).read()
        kspacing =float(re.findall((r"KSPACING(.+?)\n"),fc)[0].replace('=',''))
        kgamma =('T' in re.findall((r"KGAMMA(.+?)\n"),fc)[0])
    else :
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_relax_incar(ecut, ediff, True, False, False, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
        
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
        fp.write(fc)
    # gen potcar
    with open(task_poscar,'r') as fp :
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list :
        assert os.path.exists(os.path.abspath(potcar_map[ii])),"No POTCAR in the potcar_map of %s"%(ii)
        potcar_list.append(os.path.abspath(potcar_map[ii]))
    with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
    with open(os.path.join(task_path,'KPOINTS'), 'w') as fp:
        fp.write(fc)
    # gen tasks    
    cwd = os.getcwd()
    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 ['POSCAR', 'POTCAR', 'INCAR', 'KPOINTS'] :
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        dfm_ss.deformed_structures[ii].to('POSCAR', 'POSCAR')
        # record strain
        strain = Strain.from_deformation(dfm_ss.deformations[ii])
        np.savetxt('strain.out', strain)
        # link incar, potcar, kpoints
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'POTCAR')), 'POTCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'KPOINTS')), 'KPOINTS')
    cwd = os.getcwd()
コード例 #4
0
def make_vasp(jdata, conf_dir):
    conf_path = os.path.abspath(conf_dir)
    equi_path = re.sub('confs', global_task_name, conf_path)
    os.makedirs(equi_path, exist_ok=True)
    cwd = os.getcwd()
    from_poscar = os.path.join(conf_path, 'POSCAR')
    to_poscar = os.path.join(equi_path, 'POSCAR')
    if os.path.exists(to_poscar):
        assert (filecmp.cmp(from_poscar, to_poscar))
    else:
        os.chdir(equi_path)
        os.symlink(os.path.relpath(from_poscar), 'POSCAR')
        os.chdir(cwd)
    is_alloy = \
               os.path.exists(
                   os.path.join(
                       os.path.join(conf_path, '..'),
                       'alloy'
                   )
               )
    # read potcar
    with open(to_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert os.path.exists(os.path.abspath(
            potcar_map[ii])), "No POTCAR in the potcar_map of %s" % (ii)
        potcar_list.append(os.path.abspath(potcar_map[ii]))

    # gen incar
    if 'relax_incar' in jdata.keys():
        relax_incar_path = jdata['relax_incar']
        assert (os.path.exists(relax_incar_path))
        relax_incar_path = os.path.abspath(relax_incar_path)
        incar = incar_upper(Incar.from_file(relax_incar_path))
        isif = 3
        if incar.get('ISIF') != isif:
            dlog.info("%s:%s setting ISIF to %d" %
                      (__file__, make_vasp.__name__, isif))
            incar['ISIF'] = isif
        fc = incar.get_string()
        kspacing = incar['KSPACING']
        kgamma = incar['KGAMMA']
        vasp_path = os.path.join(equi_path, 'vasp-relax_incar')
    else:
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_relax_incar(ecut, ediff, is_alloy, True, True,
                                        npar, kpar, kspacing, kgamma)
        vasp_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing)

    os.makedirs(vasp_path, exist_ok=True)
    os.chdir(vasp_path)

    # write incar
    with open('INCAR', 'w') as fp:
        fp.write(fc)

    # gen poscar
    if os.path.exists('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(to_poscar), 'POSCAR')

    # gen kpoints
    fc = vasp.make_kspacing_kpoints('POSCAR', kspacing, kgamma)
    with open('KPOINTS', 'w') as fp:
        fp.write(fc)

    #copy cvasp
    if ('cvasp' in jdata) and (jdata['cvasp'] == True):
        shutil.copyfile(cvasp_file, 'cvasp.py')

    # gen potcar
    with open('POTCAR', 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    os.chdir(cwd)
コード例 #5
0
def make_vasp(jdata, conf_dir) :
    vol_start = jdata['vol_start']
    vol_end = jdata['vol_end']
    vol_step = jdata['vol_step']
    eos_relax_cell_shape = jdata.get('eos_relax_cell_shape', True)
    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')

    if 'relax_incar' in jdata.keys():
        vasp_str='vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str='vasp-k%.2f' % kspacing

    # get equi poscar
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, vasp_str)
    os.makedirs(task_path, exist_ok = True)    
    # link poscar
    cwd = os.getcwd()
    from_poscar = os.path.join(equi_contcar)
    to_poscar = os.path.join(task_path, 'POSCAR')
    if os.path.exists(to_poscar) :
        assert(filecmp.cmp(from_poscar, to_poscar))
    else :
        os.chdir(task_path)
        os.symlink(os.path.relpath(from_poscar), 'POSCAR')
        os.chdir(cwd)
    vol_to_poscar = vasp.poscar_vol(to_poscar) / vasp.poscar_natoms(to_poscar)
    # print(to_poscar, vol_to_poscar)
    is_alloy = \
               os.path.exists(
                   os.path.join(
                       os.path.join(conf_path, '..'),
                       'alloy'
                   )
               )  
    # read potcar
    with open(to_poscar,'r') as fp :
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list :
        assert os.path.exists(os.path.abspath(potcar_map[ii])),"No POTCAR in the potcar_map of %s"%(ii)
        potcar_list.append(os.path.abspath(potcar_map[ii]))

    # gen incar
    if  'relax_incar' in jdata.keys():
        relax_incar_path = jdata['relax_incar']
        assert(os.path.exists(relax_incar_path))
        relax_incar_path = os.path.abspath(relax_incar_path)
        incar = incar_upper(Incar.from_file(relax_incar_path))
        if eos_relax_cell_shape:
            isif = 4
        else:
            isif = 2
        if incar.get('ISIF') != isif:
            dlog.info("%s:%s setting ISIF to %d" % (__file__, make_vasp.__name__, isif))
            incar['ISIF'] = isif
        fc = incar.get_string()
        kspacing = incar['KSPACING']
        kgamma = incar['KGAMMA']
    else :
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_relax_incar(ecut, ediff, is_alloy,  True, False, npar, kpar, kspacing, kgamma)

    os.chdir(task_path)

    with open('INCAR', 'w') as fp :
        fp.write(fc)
    # gen potcar
    with open('POTCAR', 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # loop over volumes
    for vol in np.arange(vol_start, vol_end, vol_step) :
        vol_path = os.path.join(task_path, 'vol-%.2f' % vol)        
        os.makedirs(vol_path, exist_ok = True)
        os.chdir(vol_path)
        for ii in ['INCAR', 'POTCAR', 'POSCAR.orig', 'POSCAR'] :
            if os.path.exists(ii) :
                os.remove(ii)
        # link incar, potcar
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'POTCAR')), 'POTCAR')
        # gen poscar
        os.symlink(os.path.relpath(to_poscar), 'POSCAR.orig')
        scale = (vol / vol_to_poscar) ** (1./3.)
        # print(scale)
        vasp.poscar_scale('POSCAR.orig', 'POSCAR', scale)
        # print(vol_path, vasp.poscar_vol('POSCAR') / vasp.poscar_natoms('POSCAR'))
        # gen kpoints
        fc = vasp.make_kspacing_kpoints('POSCAR', kspacing, kgamma)
        with open('KPOINTS', 'w') as fp: fp.write(fc)
        #copy cvasp
        if ('cvasp' in jdata) and (jdata['cvasp'] == True):
           shutil.copyfile(cvasp_file, os.path.join(vol_path,'cvasp.py'))
        os.chdir(cwd)
コード例 #6
0
def _make_vasp(jdata, conf_dir, supercell, insert_ele):

    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    # get equi poscar
    if 'relax_incar' in jdata.keys():
        vasp_str = 'vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str = 'vasp-k%.2f' % (kspacing)
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    assert os.path.exists(
        equi_contcar), "Please compute the equilibrium state using vasp first"
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, vasp_str)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    # gen strcture
    print("task poscar: ", task_poscar)
    ss = Structure.from_file(task_poscar)
    # gen defects
    vds = InterstitialGenerator(ss, insert_ele)
    dss = []
    for jj in vds:
        dss.append(jj.generate_defect_structure(supercell))
    # gen incar
    if 'relax_incar' in jdata.keys():
        relax_incar_path = jdata['relax_incar']
        assert (os.path.exists(relax_incar_path))
        relax_incar_path = os.path.abspath(relax_incar_path)
        incar = incar_upper(Incar.from_file(relax_incar_path))
        fc = incar.get_string()
        kspacing = incar['KSPACING']
        kgamma = incar['KGAMMA']

    else:
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_relax_incar(ecut,
                                        ediff,
                                        True,
                                        True,
                                        True,
                                        npar=npar,
                                        kpar=kpar,
                                        kspacing=kspacing,
                                        kgamma=kgamma)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen tasks
    copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
    cwd = os.getcwd()
    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 ['POSCAR', 'POTCAR', 'INCAR']:
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        dss[ii].to('POSCAR', 'POSCAR')
        # gen potcar
        with open('POSCAR', 'r') as fp:
            lines = fp.read().split('\n')
            ele_list = lines[5].split()

        os.chdir(cwd)
        potcar_map = jdata['potcar_map']
        potcar_list = []
        for ii in ele_list:
            assert os.path.exists(os.path.abspath(
                potcar_map[ii])), "No POTCAR in the potcar_map of %s" % (ii)
            potcar_list.append(os.path.abspath(potcar_map[ii]))
        os.chdir(struct_path)

        with open('POTCAR', 'w') as outfile:
            for fname in potcar_list:
                with open(fname) as infile:
                    outfile.write(infile.read())

        # link incar
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        # save supercell
        np.savetxt('supercell.out', supercell, fmt='%d')

        # write kp
        fc = vasp.make_kspacing_kpoints('POSCAR', kspacing, kgamma)
        with open('KPOINTS', 'w') as fp:
            fp.write(fc)

        #copy cvasp
        if ('cvasp' in jdata) and (jdata['cvasp'] == True):
            shutil.copyfile(cvasp_file, os.path.join(struct_path, 'cvasp.py'))
    os.chdir(cwd)
コード例 #7
0
ファイル: VASP.py プロジェクト: picodase/dpgen
    def make_input_file(self, output_dir, task_type, task_param):
        sepline(ch=output_dir)
        dumpfn(task_param, os.path.join(output_dir, 'task.json'), indent=4)

        assert (os.path.exists(self.incar)), 'no INCAR file for relaxation'
        relax_incar_path = os.path.abspath(self.incar)
        incar_relax = incar_upper(Incar.from_file(relax_incar_path))

        # deal with relaxation

        cal_type = task_param['cal_type']
        cal_setting = task_param['cal_setting']

        # user input INCAR for property calculation
        if 'input_prop' in cal_setting and os.path.isfile(
                cal_setting['input_prop']):
            incar_prop = os.path.abspath(cal_setting['input_prop'])
            incar = incar_upper(Incar.from_file(incar_prop))

        # revise INCAR based on the INCAR provided in the "interaction"
        else:
            incar = incar_relax
            if cal_type == 'relaxation':
                relax_pos = cal_setting['relax_pos']
                relax_shape = cal_setting['relax_shape']
                relax_vol = cal_setting['relax_vol']
                if [relax_pos, relax_shape, relax_vol] == [True, False, False]:
                    isif = 2
                elif [relax_pos, relax_shape, relax_vol] == [True, True, True]:
                    isif = 3
                elif [relax_pos, relax_shape,
                      relax_vol] == [True, True, False]:
                    isif = 4
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, True, False]:
                    isif = 5
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, True, True]:
                    isif = 6
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, False, True]:
                    isif = 7
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, False, False]:
                    nsw = 0
                    isif = 2
                    if not ('NSW' in incar and incar.get('NSW') == nsw):
                        dlog.info("%s setting NSW to %d" %
                                  (self.make_input_file.__name__, nsw))
                        incar['NSW'] = nsw
                else:
                    raise RuntimeError(
                        "not supported calculation setting for VASP")

                if not ('ISIF' in incar and incar.get('ISIF') == isif):
                    dlog.info("%s setting ISIF to %d" %
                              (self.make_input_file.__name__, isif))
                    incar['ISIF'] = isif

            elif cal_type == 'static':
                nsw = 0
                if not ('NSW' in incar and incar.get('NSW') == nsw):
                    dlog.info("%s setting NSW to %d" %
                              (self.make_input_file.__name__, nsw))
                    incar['NSW'] = nsw

            else:
                raise RuntimeError("not supported calculation type for VASP")

            if 'ediff' in cal_setting:
                dlog.info(
                    "%s setting EDIFF to %s" %
                    (self.make_input_file.__name__, cal_setting['ediff']))
                incar['EDIFF'] = cal_setting['ediff']

            if 'ediffg' in cal_setting:
                dlog.info(
                    "%s setting EDIFFG to %s" %
                    (self.make_input_file.__name__, cal_setting['ediffg']))
                incar['EDIFFG'] = cal_setting['ediffg']

            if 'encut' in cal_setting:
                dlog.info(
                    "%s setting ENCUT to %s" %
                    (self.make_input_file.__name__, cal_setting['encut']))
                incar['ENCUT'] = cal_setting['encut']

            if 'kspacing' in cal_setting:
                dlog.info(
                    "%s setting KSAPCING to %s" %
                    (self.make_input_file.__name__, cal_setting['kspacing']))
                incar['KSAPCING'] = cal_setting['kspacing']

            if 'kgamma' in cal_setting:
                dlog.info(
                    "%s setting KGAMMA to %s" %
                    (self.make_input_file.__name__, cal_setting['kgamma']))
                incar['KGAMMA'] = cal_setting['kgamma']

        try:
            kspacing = incar.get('KSPACING')
        except KeyError:
            raise RuntimeError("KSPACING must be given in INCAR")

        if 'KGAMMA' in incar:
            kgamma = incar.get('KGAMMA')
        else:
            kgamma = False

        incar.write_file(os.path.join(output_dir, '../INCAR'))
        cwd = os.getcwd()
        os.chdir(output_dir)
        if not os.path.islink('INCAR'):
            os.symlink('../INCAR', 'INCAR')
        elif not '../INCAR' == os.readlink('INCAR'):
            os.remove('INCAR')
            os.symlink('../INCAR', 'INCAR')
        os.chdir(cwd)
        ret = vasp.make_kspacing_kpoints(self.path_to_poscar, kspacing, kgamma)
        kp = Kpoints.from_string(ret)
        kp.write_file(os.path.join(output_dir, "KPOINTS"))
コード例 #8
0
def make_vasp(jdata, conf_dir):
    fp_params = jdata['vasp_params']
    ecut = fp_params['ecut']
    ediff = fp_params['ediff']
    npar = fp_params['npar']
    kpar = fp_params['kpar']
    kspacing = fp_params['kspacing']
    kgamma = fp_params['kgamma']
    supercell_matrix = jdata['supercell_matrix']
    band_path = jdata['band']

    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, 'vasp-k%.2f' % kspacing)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    print(task_path)
    if os.path.isfile('POSCAR-unitcell'):
        os.remove('POSCAR-unitcell')
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR-unitcell')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR-unitcell')
    # gen incar
    fc = vasp.make_vasp_phonon_incar(ecut,
                                     ediff,
                                     npar,
                                     kpar,
                                     kspacing=None,
                                     kgamma=None)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen potcar
    with open(task_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert (os.path.exists(potcar_map[ii]))
        potcar_list.append(potcar_map[ii])
    with open(os.path.join(task_path, 'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
    with open(os.path.join(task_path, 'KPOINTS'), 'w') as fp:
        fp.write(fc)
    # gen band.conf
    os.chdir(task_path)
    with open('band.conf', 'w') as fp:
        fp.write('ATOM_NAME = ')
        for ii in ele_list:
            fp.write(ii)
            fp.write(' ')
        fp.write('\n')
        fp.write(
            'DIM = %d %d %d\n' %
            (supercell_matrix[0], supercell_matrix[1], supercell_matrix[2]))
        fp.write('BAND = %s\n' % band_path)
        fp.write('FORCE_CONSTANTS=READ')
    # gen POSCAR
    os.system('phonopy -d --dim="%d %d %d" -c POSCAR-unitcell' %
              (supercell_matrix[0], supercell_matrix[1], supercell_matrix[2]))
    os.symlink('SPOSCAR', 'POSCAR')
コード例 #9
0
ファイル: gen_06_phonon.py プロジェクト: HXTP/dpgen
def make_vasp(jdata, conf_dir):
    fp_params = jdata['vasp_params']
    ecut = fp_params['ecut']
    ediff = fp_params['ediff']
    npar = fp_params['npar']
    kpar = fp_params['kpar']
    kspacing = fp_params['kspacing']
    kgamma = fp_params['kgamma']
    supercell_matrix = jdata['supercell_matrix']
    band_path = jdata['band']

    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, 'vasp-k%.2f' % kspacing)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    print(task_path)
    if os.path.isfile('POSCAR-unitcell'):
        os.remove('POSCAR-unitcell')
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR-unitcell')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR-unitcell')
    # gen incar
    fc = vasp.make_vasp_phonon_incar(ecut,
                                     ediff,
                                     1,
                                     1,
                                     kspacing=None,
                                     kgamma=None)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen potcar
    with open(task_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert (os.path.exists(potcar_map[ii]))
        potcar_list.append(potcar_map[ii])
    with open(os.path.join(task_path, 'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
    with open(os.path.join(task_path, 'KPOINTS'), 'w') as fp:
        fp.write(fc)
    # gen band.conf
    os.chdir(task_path)
    with open('band.conf', 'w') as fp:
        fp.write('ATOM_NAME = ')
        for ii in ele_list:
            fp.write(ii)
            fp.write(' ')
        fp.write('\n')
        fp.write(
            'DIM = %d %d %d\n' %
            (supercell_matrix[0], supercell_matrix[1], supercell_matrix[2]))
        fp.write('BAND = %s\n' % band_path)
        fp.write('FORCE_CONSTANTS=READ')
    # gen POSCAR
    '''
    phonon = phonopy.load(supercell_matrix=supercell_matrix,
                      primitive_matrix='auto',
                      unitcell_filename='POSCAR-unitcell')
    phonon.save(filename='phonopy_disp.yaml')       
    with open('phonopy_disp.yaml', 'r') as f:
        temp = yaml.load(f.read())
    with open('POSCAR', 'w') as fp:
        for ii in ele_list:
            fp.write(ii)
            fp.write(' ')
        fp.write('\n')
        data=open('POSCAR-unitcell', 'r')
        next(data)
        fp.write(data.readline())
        for ii in temp['supercell']['lattice']:
            fp.write(str(ii).replace(',', '').replace('[', '').replace(']','\n'))
        for ii in ele_list:
            fp.write(str(str(temp['supercell']['points']).count(ii)))
            fp.write(' ')
        fp.write('\n')
        fp.write('Direct\n')
        for ii in temp['supercell']['points']:
            fp.write(str(ii['coordinates']).replace(',', '').replace('[', '').replace(']', '\n'))
    '''
    os.system('phonopy -d --dim="%d %d %d" -c POSCAR-unitcell' %
              (supercell_matrix[0], supercell_matrix[1], supercell_matrix[2]))
    os.system('cp SPOSCAR POSCAR')
コード例 #10
0
def make_vasp(jdata, conf_dir):
    default_norm_def = 2e-3
    default_shear_def = 5e-3
    norm_def = jdata.get('norm_deform', default_norm_def)
    shear_def = jdata.get('shear_deform', default_shear_def)
    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')

    if 'relax_incar' in jdata.keys():
        vasp_str = 'vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str = 'vasp-k%.2f' % kspacing

    # get equi poscar
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, vasp_str)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    # stress
    equi_outcar = os.path.join(equi_path, 'OUTCAR')
    stress = vasp.get_stress(equi_outcar)
    np.savetxt(os.path.join(task_path, 'equi.stress.out'), stress)
    # gen strcture
    ss = Structure.from_file(task_poscar)
    # gen defomations
    norm_strains = [-norm_def, -0.5 * norm_def, 0.5 * norm_def, norm_def]
    shear_strains = [-shear_def, -0.5 * shear_def, 0.5 * shear_def, shear_def]
    dfm_ss = DeformedStructureSet(ss,
                                  symmetry=False,
                                  norm_strains=norm_strains,
                                  shear_strains=shear_strains)
    n_dfm = len(dfm_ss)
    # gen incar
    if 'relax_incar' in jdata.keys():
        relax_incar_path = jdata['relax_incar']
        assert (os.path.exists(relax_incar_path))
        relax_incar_path = os.path.abspath(relax_incar_path)
        incar = incar_upper(Incar.from_file(relax_incar_path))
        if incar.get('ISIF') != 2:
            dlog.info("%s:%s setting ISIF to 2" %
                      (__file__, make_vasp.__name__))
            incar['ISIF'] = 2
        fc = incar.get_string()
        kspacing = incar['KSPACING']
        kgamma = incar['KGAMMA']
    else:
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_relax_incar(ecut,
                                        ediff,
                                        True,
                                        False,
                                        False,
                                        npar=npar,
                                        kpar=kpar,
                                        kspacing=kspacing,
                                        kgamma=kgamma)

    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen potcar
    with open(task_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert os.path.exists(os.path.abspath(
            potcar_map[ii])), "No POTCAR in the potcar_map of %s" % (ii)
        potcar_list.append(os.path.abspath(potcar_map[ii]))
    with open(os.path.join(task_path, 'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
    with open(os.path.join(task_path, 'KPOINTS'), 'w') as fp:
        fp.write(fc)
    # gen tasks
    cwd = os.getcwd()
    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 ['POSCAR', 'POTCAR', 'INCAR', 'KPOINTS']:
            if os.path.isfile(jj):
                os.remove(jj)
        # make conf
        dfm_ss.deformed_structures[ii].to('POSCAR', 'POSCAR')
        # record strain
        strain = Strain.from_deformation(dfm_ss.deformations[ii])
        np.savetxt('strain.out', strain)
        # link incar, potcar, kpoints
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'POTCAR')),
                   'POTCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'KPOINTS')),
                   'KPOINTS')
        #copy cvasp
        if ('cvasp' in jdata) and (jdata['cvasp'] == True):
            shutil.copyfile(cvasp_file, os.path.join(dfm_path, 'cvasp.py'))
    os.chdir(cwd)
コード例 #11
0
ファイル: gen_06_phonon.py プロジェクト: zhuhui-in/dpgen
def make_vasp(jdata, conf_dir) :
    
    supercell_matrix=jdata['supercell_matrix']
    band_path=jdata['band']

    if 'relax_incar' in jdata.keys():
        vasp_str='vasp-relax_incar'
    else:
        vasp_str='vasp-k%.2f' % kspacing

    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    equi_path = re.sub('confs', global_equi_name, conf_path)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    if 'user_incar' in jdata.keys():
        vasp_user_str='vasp-user_incar'
    else:
        vasp_user_str='vasp-k%.2f' % kspacing
    task_path = os.path.join(task_path, vasp_user_str)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    print(task_path)
    if os.path.isfile('POSCAR-unitcell') :
        os.remove('POSCAR-unitcell')
    if os.path.isfile('POSCAR') :
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR-unitcell')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR-unitcell')   
    # gen incar
    if  'user_incar' in jdata.keys():
        user_incar_path = jdata['user_incar']
        assert(os.path.exists(user_incar_path))
        user_incar_path = os.path.abspath(user_incar_path)
        incar = incar_upper(Incar.from_file(user_incar_path))
        fc = incar.get_string()
        kspacing = incar['KSPACING']
        kgamma = incar['KGAMMA']
    else :
        fp_params = jdata['vasp_params']
        ecut = fp_params['ecut']
        ediff = fp_params['ediff']
        npar = fp_params['npar']
        kpar = fp_params['kpar']
        kspacing = fp_params['kspacing']
        kgamma = fp_params['kgamma']
        fc = vasp.make_vasp_phonon_incar(ecut, ediff, npar, kpar, kspacing = None, kgamma = None)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
        fp.write(fc)
    # gen potcar
    with open(task_poscar,'r') as fp :
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list :
        assert(os.path.exists(potcar_map[ii]))
        potcar_list.append(potcar_map[ii])
    with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen kpoints
#    fc = vasp.make_kspacing_kpoints(task_poscar, kspacing, kgamma)
#    with open(os.path.join(task_path,'KPOINTS'), 'w') as fp:
#        fp.write(fc)

    # write kp
    fc = vasp.make_kspacing_kpoints('POSCAR', kspacing, kgamma)
    with open('KPOINTS', 'w') as fp: fp.write(fc)
    #copy cvasp
    if ('cvasp' in jdata) and (jdata['cvasp'] == True):
       shutil.copyfile(cvasp_file, os.path.join(task_path,'cvasp.py'))

    # gen band.conf
    os.chdir(task_path)
    with open('band.conf','w') as fp:
        fp.write('ATOM_NAME = ')
        for ii in ele_list:
            fp.write(ii)
            fp.write(' ')
        fp.write('\n')
        fp.write('DIM = %d %d %d\n'%(supercell_matrix[0],supercell_matrix[1],supercell_matrix[2]))
        fp.write('BAND = %s\n'%band_path)
        fp.write('FORCE_CONSTANTS=READ')
    # gen POSCAR
    os.system('phonopy -d --dim="%d %d %d" -c POSCAR-unitcell'%(supercell_matrix[0],supercell_matrix[1],supercell_matrix[2]))
    os.symlink('SPOSCAR', 'POSCAR')
コード例 #12
0
def make_vasp(jdata, conf_dir, max_miller=2, relax_box=False, static=False):

    min_slab_size = jdata['min_slab_size']
    min_vacuum_size = jdata['min_vacuum_size']
    pert_xz = jdata['pert_xz']

    if 'relax_incar' in jdata.keys():
        vasp_str = 'vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str = 'vasp-k%.2f' % (kspacing)

    # get conf poscar
    # conf_path = os.path.abspath(conf_dir)
    # conf_poscar = os.path.join(conf_path, 'POSCAR')
    equi_path = re.sub('confs', global_equi_name, conf_dir)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_path = os.path.abspath(equi_path)
    equi_contcar = os.path.join(equi_path, 'CONTCAR')
    assert os.path.exists(
        equi_contcar), "Please compute the equilibrium state using vasp first"
    task_path = re.sub('confs', global_task_name, conf_dir)
    task_path = os.path.abspath(task_path)
    if static:
        if 'scf_incar' in jdata.keys():
            vasp_static_str = 'vasp-static-scf_incar'
        else:
            vasp_static_str = 'vasp-static-k%.2f' % (kspacing)
        task_path = os.path.join(task_path, vasp_static_str)
    else:
        task_path = os.path.join(task_path, vasp_str)
    os.makedirs(task_path, exist_ok=True)
    cwd = os.getcwd()
    os.chdir(task_path)
    if os.path.isfile('POSCAR'):
        os.remove('POSCAR')
    os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
    os.chdir(cwd)
    task_poscar = os.path.join(task_path, 'POSCAR')
    ptypes = vasp.get_poscar_types(task_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)
    # gen incar
    if static:
        if 'scf_incar' in jdata.keys():
            scf_incar_path = jdata['scf_incar']
            assert (os.path.exists(scf_incar_path))
            scf_incar_path = os.path.abspath(scf_incar_path)
            incar = incar_upper(Incar.from_file(scf_incar_path))
            fc = incar.get_string()
            kspacing = incar['KSPACING']
            kgamma = incar['KGAMMA']
        else:
            fp_params = jdata['vasp_params']
            ecut = fp_params['ecut']
            ediff = fp_params['ediff']
            npar = fp_params['npar']
            kpar = fp_params['kpar']
            kspacing = fp_params['kspacing']
            kgamma = fp_params['kgamma']
            fc = vasp.make_vasp_static_incar(ecut,
                                             ediff,
                                             npar=npar,
                                             kpar=kpar,
                                             kspacing=kspacing,
                                             kgamma=kgamma)
    else:
        if 'relax_incar' in jdata.keys():
            relax_incar_path = jdata['relax_incar']
            assert (os.path.exists(relax_incar_path))
            relax_incar_path = os.path.abspath(relax_incar_path)
            incar = incar_upper(Incar.from_file(relax_incar_path))
            fc = incar.get_string()
            kspacing = incar['KSPACING']
            kgamma = incar['KGAMMA']
        else:
            fp_params = jdata['vasp_params']
            ecut = fp_params['ecut']
            ediff = fp_params['ediff']
            npar = fp_params['npar']
            kpar = fp_params['kpar']
            kspacing = fp_params['kspacing']
            kgamma = fp_params['kgamma']
            fc = vasp.make_vasp_relax_incar(ecut,
                                            ediff,
                                            True,
                                            relax_box,
                                            False,
                                            npar=npar,
                                            kpar=kpar,
                                            kspacing=kspacing,
                                            kgamma=kgamma)
    with open(os.path.join(task_path, 'INCAR'), 'w') as fp:
        fp.write(fc)
    # gen potcar
    with open(task_poscar, 'r') as fp:
        lines = fp.read().split('\n')
        ele_list = lines[5].split()
    potcar_map = jdata['potcar_map']
    potcar_list = []
    for ii in ele_list:
        assert os.path.exists(os.path.abspath(
            potcar_map[ii])), "No POTCAR in the potcar_map of %s" % (ii)
        potcar_list.append(os.path.abspath(potcar_map[ii]))
    with open(os.path.join(task_path, 'POTCAR'), 'w') as outfile:
        for fname in potcar_list:
            with open(fname) as infile:
                outfile.write(infile.read())
    # gen tasks
    cwd = os.getcwd()
    for ii in range(len(all_slabs)):
        slab = all_slabs[ii]
        miller_str = "m%d.%d.%dm" % (
            slab.miller_index[0], slab.miller_index[1], slab.miller_index[2])
        # make dir
        struct_path = os.path.join(task_path,
                                   'struct-%03d-%s' % (ii, miller_str))
        os.makedirs(struct_path, exist_ok=True)
        os.chdir(struct_path)
        for jj in ['POSCAR', 'POTCAR', 'INCAR']:
            if os.path.isfile(jj):
                os.remove(jj)
        print("# %03d generate " % ii, struct_path,
              " \t %d atoms" % len(slab.sites))
        # make conf
        slab.to('POSCAR', 'POSCAR.tmp')
        vasp.regulate_poscar('POSCAR.tmp', 'POSCAR')
        vasp.sort_poscar('POSCAR', 'POSCAR', ptypes)
        vasp.perturb_xz('POSCAR', 'POSCAR', pert_xz)
        # record miller
        np.savetxt('miller.out', slab.miller_index, fmt='%d')
        # link incar, potcar, kpoints
        os.symlink(os.path.relpath(os.path.join(task_path, 'INCAR')), 'INCAR')
        os.symlink(os.path.relpath(os.path.join(task_path, 'POTCAR')),
                   'POTCAR')

        # write kp
        fc = vasp.make_kspacing_kpoints('POSCAR', kspacing, kgamma)
        with open('KPOINTS', 'w') as fp:
            fp.write(fc)

        #copy cvasp
        if ('cvasp' in jdata) and (jdata['cvasp'] == True):
            shutil.copyfile(cvasp_file, os.path.join(struct_path, 'cvasp.py'))
    cwd = os.getcwd()