Example #1
0
    def __call__(self,
                 structure,
                 outdir=None,
                 names=None,
                 functionals=None,
                 previous=None,
                 **kwargs):
        from Generate_Surface import get_bottom, get_SD_along_vector
        from Helpers import pyl_to_pmg
        if not functionals:
            functionals = self.functionals
        outdir = os.getcwd() if outdir is None else RelativePath(outdir).path
        sp_functionals = [
            CustomFunctional(functional.base,
                             functional.modifications + [no_relax],
                             functional.type)
            for functional in functionals[self.to_run:]
        ]
        structure_frozen_bot = structure.copy()
        pmg_s = pyl_to_pmg(structure)
        sd_bottom = get_SD_along_vector(pmg_s, 2,
                                        get_bottom(pmg_s, region='bot'))
        for (atom, sd) in zip(structure_frozen_bot, sd_bottom):
            if sd[0]:
                atom.freeze = 'xyz'
        structure_frozen_top = structure.copy()
        sd_top = get_SD_along_vector(pmg_s, 2, get_bottom(pmg_s, region='top'))
        for (atom, sd) in zip(structure_frozen_top, sd_top):
            if sd[0]:
                atom.freeze = 'xyz'

        # Clevage Energy
        (clevage, previous) = self.call_with_output(structure,
                                                    outdir=outdir,
                                                    names=self.names[-3:],
                                                    functionals=sp_functionals,
                                                    previous=previous)

        # Frozen Bottom
        (bottom, clevage) = self.call_with_output(structure_frozen_bot,
                                                  outdir=os.path.join(
                                                      outdir, 'bottom'),
                                                  names=names,
                                                  functionals=functionals,
                                                  previous=clevage)

        # Frozen Top
        (bottom,
         clevage) = self.call_with_output(structure_frozen_top,
                                          outdir=os.path.join(outdir, 'top'),
                                          names=names,
                                          functionals=functionals,
                                          previous=clevage)

        return clevage
Example #2
0
    def __init__(self, vaspobj: Vasp, bulk_structure, standard=[], override=[], incar_settings='../INCAR.defaults', kpt_modifier=1):
        from Helpers import pyl_to_pmg
        standard = [load_default_vasp, ws_bulk, load_optimized_U_species, set_kpar_2, idipol_3, no_relax]
        with open(incar_settings) as f:
            lines = [line.strip().split('=') for line in f.readlines()]
            incar = {f[0].strip(): float(f[1]) for f in lines}
            kpts = math.ceil((incar['KPOINTS'] - 0.25) * max(pyl_to_pmg(bulk_structure).lattice.abc) / kpt_modifier)

        get_nopsin_eig = CustomFunctional(Vasp, standard + [get_eigen_nospin, set_algo_fast, set_nelm_200] + override)
        get_eigenvalues = CustomFunctional(Vasp, standard + [get_eigen, set_nelm_200] + override)
        final_converge = CustomFunctional(Vasp, standard + [full_converge, set_algo_normal, all_output, set_nelm_200] + override)
        ldipol = CustomFunctional(Vasp, standard + [full_converge, set_algo_fast, all_output, set_nelm_200, surface_final] + override)
        names = ['2_nospin_eig', '3_get_eigenvalues', '4_final_converge', '5_ldipol']
        functionals = [get_nopsin_eig, get_eigenvalues, final_converge, ldipol]
        super().__init__(functionals, names=names, vaspobj=vaspobj, encut=incar['ENCUT'], kpoints=kpts)
Example #3
0
def make_surfaces_to_pylada(root, bulk_structure, incar_settings=None, label='', depth=8, frozen_depth=2, override=[], kpt_modifier=1):
    '''

    :param root: root directory of run
    :param bulk_structure: pylada bulk strucutre
    :param incar_settings: location of INCAR.defaults
    :return:
    '''
    from pylada.crystal import write
    from Generate_Surface import Generate_Surface
    from Helpers import pyl_to_pmg, pmg_to_pyl
    from Generate_Surface import get_bottom, get_SD_along_vector
    # small_surfaces = Generate_Surface(pyl_to_pmg(bulk_structure), 1, 1, 1, 3, vacuum=8, orth=True)
    for i, surface in enumerate(Generate_Surface(pyl_to_pmg(bulk_structure), 1, 1, 1, depth, vacuum=8, orth=False)):
        # Frozen Surface
        # surface_small = small_surfaces[i]
        surf_folder = root / label / str(i).zfill(2)
        surf_folder.functional = WSBulkToFrozenSurfacePBE(Vasp(), bulk_structure=bulk_structure,
                                                          incar_settings=incar_settings, override=override,
                                                          kpt_modifier=kpt_modifier)
        surf_folder.params['structure'] = pmg_to_pyl(surface).copy()
        os.makedirs(surf_folder.name[1:], exist_ok=True)
        surface.to('poscar', os.path.join(surf_folder.name[1:], 'surface.vasp'))
        with open(os.path.join(surf_folder.name[1:], 'DATABASE'), 'w') as f:
            f.write('''
surface
surface_cut {}
surface_termination  {}
convergence_study
convergence_type surface
misc_labels {}
'''.format(i, 'None', label))

        # Frozen Surfaces

        for frozen_region in ['top', 'bottom']:

            froz_folder = surf_folder / frozen_region
            froz_folder.functional = WSBulkToSurfacePBE(Vasp(), bulk_structure=bulk_structure,
                                                        incar_settings=incar_settings, override=override,
                                                        kpt_modifier=kpt_modifier)

            surface_frozen = surface.copy()
            # print(surface_frozen)
            sd = get_SD_along_vector(surface_frozen, 2, get_bottom(surface_frozen, length=frozen_depth, region=frozen_region))
            # Poscar(surface_frozen, selective_dynamics=sd).write_file(os.path.join(froz_folder.name[1:], 'surface.vasp'))
            surface_frozen_pyl = pmg_to_pyl(surface_frozen)
            # sd_small = get_SD_along_vector(surface_frozen, frozen_depth, get_bottom(surface_frozen, region=frozen_region))
            for (atom, sd) in zip(surface_frozen_pyl, sd):
                if sd[0]:
                    atom.freeze = 'xyz'
            os.makedirs(froz_folder.name[1:], exist_ok=True)
            write.poscar(surface_frozen_pyl, os.path.join(froz_folder.name[1:], 'surface.vasp'), vasp5=True)
            froz_folder.params['structure'] = surface_frozen_pyl.copy()
            os.makedirs(froz_folder.name[1:], exist_ok=True)
            with open(os.path.join(froz_folder.name[1:], 'DATABASE'), 'w') as f:
                f.write('''
surface
surface_cut {}
surface_termination  {}
misc_labels {}
'''.format(i, frozen_region, label))
Example #4
0
def set_kpoints_1704(vasp: Vasp, structure=None):
    kpts = Kpoints.automatic_density(pyl_to_pmg(structure), 1704)
    vasp.kpoints = str(kpts)
    return vasp