Exemplo n.º 1
0
def PwNscfTasks(structure,kpoints,ecut,nscf_bands,nscf_kpoints=None,**kwargs):
    """
    Return a ScfTask, NscfTask and P2yTask preparing for a Yambo calculation
    """
    scf_conv_thr = kwargs.pop("conv_thr",qepyenv.CONV_THR)
    scf_conv_thr = kwargs.pop("scf_conv_thr",scf_conv_thr)
    nscf_conv_thr = kwargs.pop("nscf_conv_thr",scf_conv_thr*10)
    nscf_paralelization = kwargs.pop("nscf_paralelization","")

    #create a QE scf task and run
    qe_input = PwIn.from_structure_dict(structure,kpoints=kpoints,ecut=ecut,conv_thr=scf_conv_thr)
    qe_scf_task = PwTask.from_input(qe_input)

    # pseudo_dir
    pseudo_dir = kwargs.pop("pseudo_dir", None)
    if pseudo_dir: qe_input.control['pseudo_dir'] = "'%s'" % pseudo_dir

    #Spin
    spin = kwargs.pop("spin", None)
    if spin is "spinor": qe_input.set_spinorbit()
    if spin is "polarized": qe_input_scf.set_spinpolarized() 

    #Magnetization
    starting_magnetization = kwargs.pop("starting_magnetization", None)
    qe_input.set_magnetization(starting_magnetization)

    #create a QE nscf task and run
    if nscf_kpoints is None: nscf_kpoints = kpoints
    qe_input = qe_input.copy().set_nscf(nscf_bands,nscf_kpoints,conv_thr=nscf_conv_thr)
    qe_nscf_task = PwTask.from_input([qe_input,qe_scf_task],dependencies=qe_scf_task,paralelization=nscf_paralelization)

    #create a p2y nscf task and run
    p2y_task = P2yTask.from_nscf_task(qe_nscf_task)

    return qe_scf_task, qe_nscf_task, p2y_task
Exemplo n.º 2
0
    def get_tasks(self,scf_kpoints,nscf_kpoints_list,ecut,nscf_bands,**kwargs):
        """
        Create a flow with all the tasks to perform the calculation
        
        Arguments:
            generator: a builder function that takes structure, kpoints, ecut, 
                       nscf_bands, nscf_kpoints and kwargs as argument and returns the
                       tasks to be performed at each displacement
        """
        generator = kwargs.pop("generator",PwNscfYamboIPChiTasks)

        #create a QE scf task and run
        qe_input = PwIn.from_structure_dict(self.structure,kpoints=scf_kpoints,ecut=ecut)
        qe_scf_task = PwTask.from_input(qe_input)
        tasks = [qe_scf_task]

        for nscf_kpoints in nscf_kpoints_list:

            #generate tasks
            new_tasks = generator(structure=self.structure,kpoints=scf_kpoints,
                                  nscf_kpoints=nscf_kpoints,
                                  ecut=ecut,nscf_bands=nscf_bands,**kwargs)
            tasks.extend(new_tasks)

        return tasks
Exemplo n.º 3
0
def PwNscfTasks(structure,
                kpoints,
                ecut,
                nscf_bands,
                nscf_kpoints=None,
                **kwargs):
    """
    Return a ScfTask, NscfTask and P2yTask preparing for a Yambo calculation
    """
    scf_conv_thr = kwargs.pop("conv_thr", qepyenv.CONV_THR)
    scf_conv_thr = kwargs.pop("scf_conv_thr", scf_conv_thr)
    nscf_conv_thr = kwargs.pop("nscf_conv_thr", scf_conv_thr * 10)
    nscf_paralelization = kwargs.pop("nscf_paralelization", "")

    #create a QE scf task and run
    qe_input = PwIn.from_structure_dict(structure,
                                        kpoints=kpoints,
                                        ecut=ecut,
                                        conv_thr=scf_conv_thr)
    qe_scf_task = PwTask.from_input(qe_input)

    #create a QE nscf task and run
    if nscf_kpoints is None: nscf_kpoints = kpoints
    qe_input = qe_input.copy().set_nscf(nscf_bands,
                                        nscf_kpoints,
                                        conv_thr=nscf_conv_thr)
    qe_nscf_task = PwTask.from_input([qe_input, qe_scf_task],
                                     dependencies=qe_scf_task,
                                     paralelization=nscf_paralelization)

    #create a p2y nscf task and run
    p2y_task = P2yTask.from_nscf_task(qe_nscf_task)

    return qe_scf_task, qe_nscf_task, p2y_task
Exemplo n.º 4
0
    def test_pwin(self):
        pwi = PwIn.from_structure_dict(Si)
        pwi.set_nscf(10)
        print(pwi)

        pwi.cell_parameters = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
        pwi.ibrav = 0
        print(pwi)
Exemplo n.º 5
0
def PwRelaxTasks(structure,kpoints,ecut,cell_dofree='all',**kwargs):
    """
    Return a RelaxTask and ScfTask (Author: AMS, HM)

    Args:
        kpoints: the k-mesh for the scf calculation
        ecut: the planewave basis cutoff
        cell_free
        spin: can be 'polarized' for calculation with spin or 'spinor' for calculation with spin-orbit
        starting_magnetization: a list with the starting magnetizations for each atomic type
    """
    #raise NotImplementedError('This function is under development!')

    scf_conv_thr = kwargs.pop("conv_thr",qepyenv.CONV_THR)
    scf_conv_thr = kwargs.pop("scf_conv_thr",scf_conv_thr)
    paralelization = kwargs.pop("paralelization","")

    #create a QE input scf
    qe_input_scf = PwIn.from_structure_dict(structure,kpoints=kpoints,ecut=ecut,conv_thr=scf_conv_thr)

    #Spin
    spin = kwargs.pop("spin", None)
    if spin is "spinor": qe_input_scf.set_spinorbit()
    if spin is "polarized": qe_input_scf.set_spinpolarized() 

    #Magnetization
    starting_magnetization = kwargs.pop("starting_magnetization", None)
    qe_input_scf.set_magnetization(starting_magnetization)

    pseudo_dir = kwargs.pop("pseudo_dir", None)
    if pseudo_dir: qe_input_scf.control['pseudo_dir'] = "'%s'" % pseudo_dir

    #create a QE relax-atom task
    qe_input_relax_atoms = qe_input_scf.copy().set_relax(cell_dofree=None)
    qe_relax_atoms_task = PwTask.from_input(qe_input_relax_atoms,paralelization=paralelization)

    #create a QE relax-cell task
    qe_input_relax_cell = qe_input_scf.copy().set_relax(cell_dofree=cell_dofree)
    qe_relax_cell_task = PwTask.from_input([qe_input_relax_cell,qe_input_relax_atoms],dependencies=qe_relax_atoms_task,paralelization=paralelization)
    qe_relax_cell_task.set_vars("pwtask",qe_relax_atoms_task)
    qe_relax_cell_task.set_code("initialize",update_cell_and_positions)

    #create a QE scf task
    qe_scf_task = PwTask.from_input([qe_input_scf,qe_input_relax_cell],dependencies=qe_relax_cell_task,paralelization=paralelization)
    qe_scf_task.set_vars("pwtask",qe_relax_cell_task)
    qe_scf_task.set_code("initialize",update_cell_and_positions)

    return qe_relax_atoms_task, qe_relax_cell_task, qe_scf_task
Exemplo n.º 6
0
    def get_tasks(self,path,kpoints,ecut,nscf_bands,nscf_kpoints=None,
                  imodes_list=None,displacements=[0.01,-0.01],iqpoint=0,**kwargs):
        """
        Create a flow with all the tasks to perform the calculation
        
        Arguments:
            generator: a builder function that takes structure, kpoints, ecut, 
                       nscf_bands, nscf_kpoints and kwargs as argument and returns the
                       tasks to be performed at each displacement
        """

        if imodes_list is None: imodes_list = list(range(self.phonon_modes.nmodes))
        if not isiter(displacements): displacements = [displacements]
        generator = kwargs.pop("generator",PwNscfYamboIPChiTasks)
             
        #create qe input from structure
        pwin = PwIn.from_structure_dict(self.structure,kpoints=kpoints,ecut=ecut)

        tasks = []
        #
        # Undisplaced structure
        #
        tasks.extend(generator(pwin.get_structure(),kpoints,ecut,nscf_bands,nscf_kpoints=nscf_kpoints,**kwargs))

        #
        # Displaced structures
        #
        reference = [dict(imode=None,displacement=0)]

        for imode in imodes_list:
            #get phonon mode
            cart_mode = self.phonon_modes.modes[iqpoint,imode]
            #iterate over displacements
            for displacement in displacements:
                #displace structure
                input_mock = pwin.get_displaced(cart_mode, displacement=displacement)
                displaced_structure = input_mock.get_structure()

                #generate tasks
                new_tasks = generator(displaced_structure,kpoints,ecut,
                                      nscf_bands,nscf_kpoints=nscf_kpoints,**kwargs)
                #save task
                tasks.extend(new_tasks)
                reference.append([dict(imode=None,displacement=displacement)])

        #store a reference for each of the tasks
        self.reference = reference
        return tasks
Exemplo n.º 7
0
def PhPhononTasks(structure,kpoints,ecut,qpoints=None):
    """
    Return a ScfTask, a PhTask and Matdyn task
    """

    #create a QE scf task and run
    qe_input = PwIn.from_structure_dict(structure,kpoints=kpoints,ecut=ecut)
    qe_scf_task = PwTask.from_input(qe_input)

    #create phonon tasks
    if qpoints is None: qpoints = qe_input.kpoints
    ph_input = PhIn.from_qpoints(qpoints)
    ph_task = PhTask.from_scf_task([ph_input,qe_scf_task],dependencies=qe_scf_task)

    #create matdyn task
    matdyn_task = DynmatTask.from_phonon_task(ph_task,dependencies=ph_task)

    return qe_scf_task, ph_task, matdyn_task
Exemplo n.º 8
0
def PwBandsTasks(structure,kpoints,ecut,nscf_bands,path_kpoints,**kwargs):
    """
    Return a ScfTask and BandsTask (Author: AMS, HM)

    Args:
        kpoints: the k-mesh for the scf calculation
        ecut: the planewave basis cutoff
        nscf_bands: number of bands in the nscf_calculation
        path_kpoints: the k-points along the path
        spin: can be 'polarized' for calculation with spin or 'spinor' for calculation with spin-orbit
        starting_magnetization: a list with the starting magnetizations for each atomic type
    """
    scf_conv_thr = kwargs.pop("conv_thr",qepyenv.CONV_THR)
    scf_conv_thr = kwargs.pop("scf_conv_thr",scf_conv_thr)
    bands_conv_thr = kwargs.pop("nscf_conv_thr",scf_conv_thr*10)

    #create a QE scf task
    qe_input = PwIn.from_structure_dict(structure,kpoints=kpoints,ecut=ecut,conv_thr=scf_conv_thr)

    # pseudo_dir
    pseudo_dir = kwargs.pop("pseudo_dir", None)
    if pseudo_dir: qe_input.control['pseudo_dir'] = "'%s'" % pseudo_dir

    #Spin
    spin = kwargs.pop("spin", None)
    if spin is "spinor": qe_input.set_spinorbit()
    if spin is "polarized": qe_input.set_spinpolarized() 

    #Magnetization
    starting_magnetization = kwargs.pop("starting_magnetization", None)
    qe_input.set_magnetization(starting_magnetization)

    pseudo_dir = kwargs.pop("pseudo_dir", None)
    if pseudo_dir: qe_input.control['pseudo_dir'] = "'%s'" % pseudo_dir

    scf_paralelization = kwargs.pop("scf_paralelization","")
    qe_scf_task = PwTask.from_input(qe_input,paralelization=scf_paralelization)

    #create a QE bands task
    qe_input_bands = qe_input.copy().set_bands(nscf_bands,path_kpoints=path_kpoints,conv_thr=bands_conv_thr,**kwargs)
    nscf_paralelization = kwargs.pop("nscf_paralelization","")
    qe_bands_task = PwTask.from_input([qe_input_bands,qe_scf_task],dependencies=qe_scf_task,paralelization=nscf_paralelization,**kwargs)

    return qe_scf_task, qe_bands_task
Exemplo n.º 9
0
def AbinitNscfTasks(structure,
                    kpoints,
                    ecut,
                    nscf_bands,
                    nscf_kpoints=None,
                    **kwargs):
    from abipy.core.structure import Structure
    from abipy.abio.factories import scf_for_phonons
    from pymatgen.core.units import bohr_to_ang

    #extract pseudos
    pseudo_list = []
    for atype, (mass, pseudo) in structure['atypes'].items():
        pseudo_list.append(pseudo)
    pseudo_table = kwargs.pop("pseudo_table", pseudo_list)

    #create a PwInput file just to read the ibrav from structure
    qe_input = PwIn.from_structure_dict(structure)
    lattice, coords, species = qe_input.get_cell()
    lattice = [[col * bohr_to_ang for col in row] for row in lattice]
    structure = Structure(lattice, species, coords)

    #create an AbinitInput file from structure
    spin_mode = kwargs.pop('spin_mode', 'unpolarized')
    smearing = kwargs.pop('smearing', 'nosmearing')
    inp = scf_for_phonons(structure,
                          pseudo_table,
                          spin_mode=spin_mode,
                          smearing=smearing,
                          ecut=ecut / 2)

    return AbinitNscfTasksFromAbinitInput(inp,
                                          kpoints,
                                          ecut,
                                          nscf_bands,
                                          nscf_kpoints=nscf_kpoints,
                                          **kwargs)
Exemplo n.º 10
0
# Copyright (C) 2018 Henrique Pereira Coutada Miranda
# All rights reserved.
#
# This file is part of yambopy
#
"""
 This is an example of a BSE calculation for MoS2 
 using the new Flow/Task methods of yambopy.
 The approach is the same as the one implemented in Abipy.
"""
from yambopy.data.structures import MoS2
from qepy.pw import PwIn
from yambopy.flow import YambopyFlow, PwTask, P2yTask, YamboTask

#create a QE scf task and run
qe_input = PwIn.from_structure_dict(MoS2,kpoints=[12,12,1],ecut=30)
qe_scf_task = PwTask.from_input(qe_input)

#create a QE nscf task and run
qe_input = qe_input.copy().set_nscf(20)
qe_nscf_task = PwTask.from_input([qe_input,qe_scf_task],dependencies=qe_scf_task)

#create a p2y nscf task and run
p2y_task = P2yTask.from_nscf_task(qe_nscf_task)

#create a yambo optics task and run
yamboin_dict = dict(NGsBlkXs=[1,'Ry'],
                    BndsRnXs=[[1,20],''],
                    BSEBands=[[8,11],''],
                    BEnRange=[[0.0,6.0],'eV'],
                    BEnSteps=[1000,''])