Exemple #1
0
    def __init__(self, frags, basis, settings=None, core=None, pointcharges=None,
                 options=None, fde=None, fdeoptions=None, adffdesetts=None):
        """
        Initialize an FDE job.

        For most of the parameters see class L{adffragmentsjob}.

        @param fde: options for the FDE run;
                    In addition to the standard options Freeze-Thaw (FT) can be controlled;
                    By default a parallel FT will be done;
                    For normal FT use 'NORMALFT'
        @type  fde: dictionary

        """
        metajob.__init__(self)

        if isinstance(frags, list):
            self._frags = fragmentlist(frags)
        else:
            self._frags = frags

        self._basis = basis
        self._settings = settings
        self._core = core
        self._pc = pointcharges
        self._options = options
        self._adffdesettings = adffdesetts

        if fde is None:
            self._fde = {}
        else:
            import copy
            self._fde = copy.copy(fde)
        if 'RELAXCYCLES' in self._fde:
            self._cycles = self._fde['RELAXCYCLES'] + 1
            del self._fde['RELAXCYCLES']
        else:
            self._cycles = 1

        if 'NORMALFT' in self._fde:
            self._normalft = True
            del self._fde['NORMALFT']
        else:
            self._normalft = False

        if fdeoptions is None:
            self._fdeoptions = {}
        else:
            self._fdeoptions = fdeoptions

        # make all fragments frozen and apply fdeoptions
        for f in iter(self._frags):
            f.isfrozen = True
            f.set_fdeoptions(self._fdeoptions)
Exemple #2
0
    def __init__(self, frags, adfoptions, diracoptions):
        metajob.__init__(self)

        if isinstance(frags, list):
            self._frags = fragmentlist(frags)
        else:
            self._frags = frags

        self._adfoptions = adfoptions
        self._diracoptions = diracoptions

        self._cycles = 0
        if "fde" in self._adfoptions:
            if 'RELAXCYCLES' in self._adfoptions["fde"]:
                self._cycles = self._adfoptions["fde"]['RELAXCYCLES']
                del self._adfoptions["fde"]['RELAXCYCLES']
Exemple #3
0
    def metarun(self):

        import copy

        print "-" * 50
        print "Beginning WFT-in-DFT embedding calculation "
        print
        print "Performing %i RELAX-cycles" % self._cycles
        print

        # first we do a normal DFT-in-DFT run
        initial_frags = copy.deepcopy(self._frags)
        for f in initial_frags:
            # rename RELAX option to RELAXsave so that we can handle it, instead of ADF
            if f.has_fdeoption("RELAX"):
                f.delete_fdeoption("RELAX")
                f.add_fdeoption("RELAXsave", "")

        # pylint: disable-msg=W0142
        dftindft_res = adffragmentsjob(initial_frags, **self._adfoptions).run()

        # now construct a new list of fragments
        frags = copy.deepcopy(fragmentlist(initial_frags.get_frozen_frags()))
        for f in frags:
            if f.has_fdeoption("RELAXsave"):
                f.isfrozen = False
        dirac_frag = fragment(dftindft_res, dftindft_res.get_nonfrozen_molecule(), subfrag="active", isfrozen=True)
        dirac_mol = dirac_frag.get_total_molecule()
        frags.append(dirac_frag)

        # now run a DFT-in-DFT calculation with the Dirac-fragment frozen,
        # and all DFT-relax fragments nonfrozen in order to get a grid that
        # can be used for all of them
        # (the Dirac step is expensive, so we want to do it only for one common grid)
        #
        # FIXME: Alternatively, Dirac could use several grids for exporting
        #
        # FIXME: we do the full DFT-in-DFT calculation, but only extracting
        #        the grid would be enough; maybe use some STOPAFTER option?

        # pylint: disable-msg=W0142
        outgrid_res = adffragmentsjob(frags, **self._adfoptions).run()

        for i in range(self._cycles):

            print "-" * 50
            print "Performing cycle ", i + 1
            print

            # do the Dirac calculation
            # pylint: disable-msg=W0142
            dirac_res = diracsinglepointjob(dirac_mol, fdein=dftindft_res, fdeout=outgrid_res, **self._diracoptions).run()

            # construct new list of fragments, update the Dirac fragment,
            frags = fragmentlist(initial_frags.get_frozen_frags())
            dirac_frag = diracfragment(dirac_res, dirac_mol, isfrozen=True)
            frags.append(dirac_frag)

            # loop over all DFT-relax fragments and update them
            for f in frags:
                if f.has_fdeoption("RELAXsave"):
                    f.isfrozen = False
                    # pylint: disable-msg=W0142
                    f.results = adffragmentsjob(frags, **self._adfoptions).run()
                    f.isfrozen = True

            frozenfrags = frags.get_frozen_frags()
            frozenfrags = [f for f in frozenfrags if not isinstance(f, diracfragment)]
            initial_frags = copy.deepcopy(fragmentlist(frozenfrags))
            dirac_frag = fragment(dftindft_res, dirac_mol, subfrag="active", isfrozen=False)
            initial_frags.append(dirac_frag)

            # run ADF DFT-in-DFT again to get a new embedding potential
            #
            # FIXME: rho1 is calculated by ADF in this step again.
            #        Instead, the rho1 calculated by Dirac should be used
            dftindft_res = adffragmentsjob(initial_frags, **self._adfoptions).run()

        print "-" * 50
        print "Performing final DIRAC calculation "
        print

        dirac_res = diracsinglepointjob(dirac_mol, fdein=dftindft_res, fdeout=outgrid_res, **self._diracoptions).run()

        return dirac_res