Beispiel #1
0
def raman_flow():

    # Get the unperturbed structure.
    base_structure = abilab.Structure.from_abivars(unit_cell)

    pseudos = ["14si.pspnc"]

    workdir = os.path.join(os.path.dirname(__file__), "test_abipy_new")

    manager = abilab.TaskManager.from_user_config()
    #manager = abilab.TaskManager.from_file("bfo_manager.yml")

    policy = TaskPolicy(autoparal=0)
    gs_manager = manager.deepcopy()

    # Initialize flow. Each workflow in the flow defines a complete BSE calculation for given eta.
    flow = abilab.Flow(workdir, manager)

    # There will be kppa/natom kpoints in the unit cell !
    kppa = 3456  # ngkpt = [12,12,12] for the primitive cell
    kppa_gs = 1728  # ngkpt = [8,8,8] for the primitive cell

    etas = [-1, 0, 1]  # Anyway, it rescales everything at the end :-)
    eta = 0.01

    scale_matrix = [[-1, 0, 1], [-1, 1, 0], [-1, -1, 0]]

    ph_tot = np.array([[0.01, 0.011, 0.021], [-0.01, 0.041, -0.02]])
    modifier = abilab.StructureModifier(base_structure)

    displaced_structure = modifier.frozen_phonon([0.5, 0.5, 0.5],
                                                 ph_tot,
                                                 do_real=True,
                                                 frac_coords=False,
                                                 scale_matrix=scale_matrix)

    structure = displaced_structure

    ksampgs = KSampling.automatic_density(structure,
                                          kppa_gs,
                                          chksymbreak=0,
                                          shifts=[0, 0, 0])

    gs_inp = gs_input(structure, pseudos, ksampgs)
    wflow = abilab.Work()
    gs_t = wflow.register_scf_task(gs_inp)
    gs_t.set_manager(gs_manager)
    flow.register_work(wflow, workdir="gs_task")

    ksamp = KSampling.automatic_density(structure,
                                        kppa,
                                        chksymbreak=0,
                                        shifts=[1 / 4, 1 / 4, 1 / 4])
    flow.register_work(raman_workflow(structure, pseudos, gs_t, ksamp),
                       workdir="bse_task")

    return flow.allocate()
Beispiel #2
0
def raman_flow():

    # Get the unperturbed structure.
    base_structure = abilab.Structure.from_abivars(unit_cell)

    pseudos=["14si.pspnc"]

    workdir = os.path.join(os.path.dirname(__file__), "test_abipy_new")

    manager = abilab.TaskManager.from_user_config()
    #manager = abilab.TaskManager.from_file("bfo_manager.yml")

    policy = TaskPolicy(autoparal=0)
    gs_manager = manager.deepcopy()

    # Initialize flow. Each workflow in the flow defines a complete BSE calculation for given eta.
    flow = abilab.Flow(workdir, manager)

    # There will be kppa/natom kpoints in the unit cell !
    kppa = 3456  # ngkpt = [12,12,12] for the primitive cell
    kppa_gs = 1728 # ngkpt = [8,8,8] for the primitive cell

    etas = [-1,0,1] # Anyway, it rescales everything at the end :-)
    eta=0.01

    scale_matrix = [[-1,0,1],[-1,1,0],[-1,-1,0]]

    ph_tot = np.array([[0.01,0.011,0.021],[-0.01,0.041,-0.02]])
    modifier = abilab.StructureModifier(base_structure)
           
    displaced_structure = modifier.frozen_phonon([0.5,0.5,0.5],ph_tot,do_real=True,frac_coords=False,scale_matrix=scale_matrix)

    structure = displaced_structure

    ksampgs = KSampling.automatic_density(structure,kppa_gs,chksymbreak=0,shifts=[0,0,0])

    gs_inp = gs_input(structure,pseudos, ksampgs)
    wflow = abilab.Work()
    gs_t = wflow.register_scf_task(gs_inp)
    gs_t.set_manager(gs_manager)
    flow.register_work(wflow,workdir="gs_task")

    ksamp = KSampling.automatic_density(structure,kppa,chksymbreak=0,shifts=[1/4,1/4,1/4])
    flow.register_work(raman_workflow(structure, pseudos, gs_t, ksamp),workdir="bse_task")

    return flow.allocate()
Beispiel #3
0
    def __init__(self, structure, pseudo, kppa, connect,
                 ecut=None, pawecutdg=None, ecutsm=0.5,
                 spin_mode="polarized", include_soc=False, toldfe=1.e-9, smearing="fermi_dirac:0.1 eV",
                 chksymbreak=0, workdir=None, manager=None, **kwargs):
        """
        Build a :class:`Work` for the computation of the deltafactor.

        Args:
            structure: :class:`Structure` object
            pseudo: :class:`Pseudo` object.
            kppa: Number of k-points per reciprocal atom.
            connect: True if the SCF run should be initialized from the previous run.
            spin_mode: Spin polarization mode.
            toldfe: Tolerance on the energy (Ha)
            smearing: Smearing technique.
            workdir: String specifing the working directory.
            manager: :class:`TaskManager` responsible for the submission of the tasks.
        """
        super(DeltaFactorWork, self).__init__(workdir=workdir, manager=manager)
        self._pseudo = pseudo
        self.include_soc = include_soc

        spin_mode = SpinMode.as_spinmode(spin_mode)
        smearing = Smearing.as_smearing(smearing)

        # Compute the number of bands from the pseudo and the spin-polarization.
        # Add 6 bands to account for smearing.
        #nval = structure.num_valence_electrons(self.pseudo)
        #nband = int(nval / spin_mode.nsppol) + 6

        # Set extra_abivars
        self.ecut, self.pawecutdg = ecut, pawecutdg

        extra_abivars = dict(
            ecut=ecut,
            pawecutdg=pawecutdg,
            ecutsm=ecutsm,
            toldfe=toldfe,
            prtwf=-1 if not connect else 1,
            chkprim=0,
            nstep=200,
            fband=2.0,   # 0.5 is the default value but it's not large enough from some systems.
            #paral_kgb=paral_kgb,
            #nband=nband,
            #mem_test=0,
        )

        extra_abivars.update(**kwargs)
        self._input_structure = structure
        v0 = structure.volume

        # From 94% to 106% of the equilibrium volume.
        self.volumes = v0 * np.arange(94, 108, 2) / 100.

        for vol in self.volumes:
            # Build new structure
            new_lattice = structure.lattice.scale(vol)
            new_structure = Structure(new_lattice, structure.species, structure.frac_coords)

            ksampling = KSampling.automatic_density(new_structure, kppa, chksymbreak=chksymbreak,
                                                    use_time_reversal=spin_mode.nspinor==1)

            scf_input = abilab.AbinitInput(structure=new_structure, pseudos=self.dojo_pseudo)
            scf_input.add_abiobjects(ksampling, smearing, spin_mode)
            scf_input.set_vars(extra_abivars)

            # Magnetic materials with nspinor = 2 requires connection
            # and a double SCF run (nsppol = 2 first then nspinor = 2).
            if connect and spin_mode.nspinor == 2:
                print("Using collinear then noncollinear scf task")
                self.register_collinear_then_noncollinear_scf_task(scf_input)
            else:
                self.register_scf_task(scf_input)

        if connect:
            logger.info("Connecting SCF tasks using previous WFK file")
            middle = len(self.volumes) // 2
            filetype = "WFK"
            for i, task in enumerate(self[:middle]):
                task.add_deps({self[i + 1]: filetype})

            for i, task in enumerate(self[middle+1:]):
                task.add_deps({self[middle + i]: filetype})
Beispiel #4
0
    def __init__(self, structure, pseudo, kppa, maxene,
                 ecut=None, pawecutdg=None, ecutsm=0.5,
                 spin_mode="unpolarized", include_soc=False, tolwfr=1.e-15, smearing="fermi_dirac:0.1 eV",
                 chksymbreak=0, workdir=None, manager=None, **kwargs):
        """
        Build a :class:`Work` for the computation of a bandstructure to check for ghosts.

        Args:
            structure: :class:`Structure` object
            pseudo: String with the name of the pseudopotential file or :class:`Pseudo` object.
            kppa: Number of k-points per reciprocal atom.
            maxene: 250 eV
            spin_mode: Spin polarization mode.
            include_soc=True of SOC should be included.
            tolwfr: Stopping criterion.
            smearing: Smearing technique.
            workdir: String specifing the working directory.
            manager: :class:`TaskManager` responsible for the submission of the tasks.
        """
        super(GhostsWork, self).__init__(workdir=workdir, manager=manager)
        self._pseudo = pseudo
        self.include_soc = include_soc

        spin_mode = SpinMode.as_spinmode(spin_mode)
        smearing = Smearing.as_smearing(smearing)

        # Here we find an initial guess for the number of bands
        # The goal is to reach maxene eV above the fermi level.
        # Assume ~ b4ev fact eV per band
        # Add a buffer of nbdbuf states and enforce an even number of states
        nval = structure.num_valence_electrons(self.dojo_pseudo)
        self.maxene = maxene
        b4ev = 1.3
        nband = int(nval + int(b4ev * self.maxene))
        #nband = nval // 2 + 10
        if spin_mode.nsppol == 1: nband // 2
        nbdbuf = max(int(0.1 * nband), 4)
        nband += nbdbuf
        nband += nband % 2

        # Set extra_abivars
        self.ecut, self.pawecutdg = ecut, pawecutdg

        extra_abivars = dict(
            ecut=ecut,
            pawecutdg=pawecutdg,
            ecutsm=ecutsm,
            nband=int(nband),
            nbdbuf=int(nbdbuf),
            tolwfr=tolwfr,
            #prtwf=0,
            nstep=200,
            chkprim=0,
            mem_test=0
        )

        extra_abivars.update(**kwargs)

        # Disable time-reversal if nspinor == 2
        self.kppa = kppa
        ksampling = KSampling.automatic_density(structure, kppa, chksymbreak=chksymbreak,
                                                use_time_reversal=spin_mode.nspinor==1)

        scf_input = abilab.AbinitInput(structure=structure, pseudos=self.dojo_pseudo)
        scf_input.add_abiobjects(ksampling, smearing, spin_mode)
        scf_input.set_vars(extra_abivars)
        self.register_scf_task(scf_input)

        self.dojo_status = 0
Beispiel #5
0
    def get_anaddb_input(self, item):
        """
        creates the AnaddbInput object. It also returns the list of qpoints labels for generating the
        PhononBandStructureSymmLine.
        """

        ngqpt = item["abinit_input.ngqpt"]
        q1shft = [(0, 0, 0)]

        structure = Structure.from_dict(item["abinit_input.structure"])

        hs = HighSymmKpath(structure, symprec=1e-2)

        spgn = hs._sym.get_space_group_number()
        if spgn != item["spacegroup.number"]:
            raise RuntimeError("Parsed specegroup number {} does not match "
                               "calculation spacegroup {}".format(spgn, item["spacegroup.number"]))

        # for the moment use gaussian smearing
        prtdos = 1
        dossmear = 3 / Ha_cmm1
        lo_to_splitting = True
        dipdip = 1
        asr = 2
        chneut = 1
        ng2qppa = 50000

        inp = AnaddbInput(structure, comment="ANADB input for phonon bands and DOS")

        inp.set_vars(
            ifcflag=1,
            ngqpt=np.array(ngqpt),
            q1shft=q1shft,
            nqshft=len(q1shft),
            asr=asr,
            chneut=chneut,
            dipdip=dipdip,
        )

        # Parameters for the dos.
        ng2qpt = KSampling.automatic_density(structure, kppa=ng2qppa).kpts[0]
        inp.set_vars(prtdos=prtdos, dosdeltae=None, dossmear=dossmear, ng2qpt=ng2qpt)

        # Parameters for the BS
        qpts, labels_list = hs.get_kpoints(line_density=18, coords_are_cartesian=False)

        n_qpoints = len(qpts)
        qph1l = np.zeros((n_qpoints, 4))

        qph1l[:, :-1] = qpts
        qph1l[:, -1] = 1

        inp['qph1l'] = qph1l.tolist()
        inp['nph1l'] = n_qpoints


        if lo_to_splitting:
            kpath = hs.kpath
            directions = []
            for qptbounds in kpath['path']:
                for i, qpt in enumerate(qptbounds):
                    if np.array_equal(kpath['kpoints'][qpt], (0, 0, 0)):
                        # anaddb expects cartesian coordinates for the qph2l list
                        if i > 0:
                            directions.extend(structure.lattice.reciprocal_lattice_crystallographic.get_cartesian_coords(
                                kpath['kpoints'][qptbounds[i - 1]]))
                            directions.append(0)

                        if i < len(qptbounds) - 1:
                            directions.extend(structure.lattice.reciprocal_lattice_crystallographic.get_cartesian_coords(
                                kpath['kpoints'][qptbounds[i + 1]]))
                            directions.append(0)

            if directions:
                directions = np.reshape(directions, (-1, 4))
                inp.set_vars(
                    nph2l=len(directions),
                    qph2l=directions
                )

        return inp, labels_list