Exemplo n.º 1
0
def comput_vasp_eos(jdata, conf_dir):
    conf_path = re.sub('confs', global_task_name, conf_dir)
    conf_path = os.path.abspath(conf_path)

    if 'relax_incar' in jdata.keys():
        vasp_str = 'vasp-relax_incar'
    else:
        kspacing = jdata['vasp_params']['kspacing']
        vasp_str = 'vasp-k%.2f' % kspacing
    task_path = os.path.join(conf_path, vasp_str)
    vol_paths = glob.glob(os.path.join(task_path, 'vol-*'))
    vol_paths.sort(key=lambda k: float(k.split('-')[-1]))
    result = os.path.join(task_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:
            outcar = os.path.join(ii, 'OUTCAR')
            natoms, epa, vpa = vasp.get_nev(outcar)
            print(vpa, epa)
            fp.write('%7.3f  %8.4f \n' % (vpa, epa))
    fp.close()
    if 'upload_username' in jdata.keys():
        upload_username = jdata['upload_username']
        util.insert_data('eos', 'vasp', upload_username, result)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :
    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    task_path = os.path.join(task_path, task_name)
    equi_stress = Stress(np.loadtxt(os.path.join(task_path, 'equi.stress.out')))

    lst_dfm_path = glob.glob(os.path.join(task_path, 'dfm-*'))
    lst_strain = []
    lst_stress = []
    for ii in lst_dfm_path :
        strain = np.loadtxt(os.path.join(ii, 'strain.out'))
        stress = lammps.get_stress(os.path.join(ii, 'log.lammps'))
        # convert from pressure to stress
        stress = -stress
        lst_strain.append(Strain(strain))
        lst_stress.append(Stress(stress))
    et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = equi_stress, vasp = False)
    # et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = None)
    # bar to GPa
    # et = -et / 1e4
    print_et(et)
    result = os.path.join(task_path,'result')
    result_et(et,conf_dir,result)
    if 'upload_username' in jdata.keys() and task_name=='deepmd':
        upload_username=jdata['upload_username']
        util.insert_data('elastic','deepmd',upload_username,result)
Exemplo n.º 4
0
def cmpt_vasp(jdata, conf_dir) :
    conf_path = os.path.abspath(conf_dir)
    conf_poscar = os.path.join(conf_path, 'POSCAR')
    task_path = re.sub('confs', global_task_name, conf_path)
    if 'relax_incar' in jdata.keys():
        vasp_str='vasp-relax_incar'
    else:
        fp_params = jdata['vasp_params']
        kspacing = fp_params['kspacing']
        vasp_str='vasp-k%.2f' % kspacing
    task_path = os.path.join(task_path, vasp_str)

    equi_stress = Stress(np.loadtxt(os.path.join(task_path, 'equi.stress.out')))

    lst_dfm_path = glob.glob(os.path.join(task_path, 'dfm-*'))
    lst_strain = []
    lst_stress = []
    for ii in lst_dfm_path :
        strain = np.loadtxt(os.path.join(ii, 'strain.out'))
        stress = vasp.get_stress(os.path.join(ii, 'OUTCAR'))
        # convert from pressure in kB to stress
        stress *= -1000
        lst_strain.append(Strain(strain))
        lst_stress.append(Stress(stress))
    et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = equi_stress, vasp = False)
    # et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = None)
    # bar to GPa
    # et = -et / 1e4
    print_et(et)
    result = os.path.join(task_path,'result')
    result_et(et,conf_dir,result)
    if 'upload_username' in jdata.keys():
        upload_username=jdata['upload_username']
        util.insert_data('elastic','vasp',upload_username,result)
Exemplo n.º 5
0
def cmpt_vasp(jdata, conf_dir, static=False):

    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_dir)
    equi_path = os.path.join(equi_path, vasp_str)
    equi_path = os.path.abspath(equi_path)
    equi_outcar = os.path.join(equi_path, 'OUTCAR')
    task_path = re.sub('confs', global_task_name, conf_dir)
    if static:
        if 'scf_incar' in jdata.keys():
            vasp_static_str = 'vasp-static-scf_incar'
        else:
            kspacing = jdata['vasp_params']['kspacing']
            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)
    task_path = os.path.abspath(task_path)

    equi_natoms, equi_epa, equi_vpa = vasp.get_nev(equi_outcar)

    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)
            outcar = os.path.join(ii, 'OUTCAR')
            natoms, epa, vpa = vasp.get_nev(outcar)
            if 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]))
            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():
        upload_username = jdata['upload_username']
        util.insert_data('surf', 'vasp', upload_username, result)
Exemplo n.º 6
0
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)