Exemplo n.º 1
0
    def accept_pseudo(self, pseudo, **kwargs):
        """Returns True if the master can train the pseudo."""
        ready = super(DeltaFactorMaster, self).accept_pseudo(pseudo, **kwargs)

        # Do we have this element in the deltafactor database?
        from pseudo_dojo.refdata.deltafactor import df_database
        return (ready and df_database().has_symbol(self.pseudo.symbol))
Exemplo n.º 2
0
    def compare_delta_factor(self, accuracy="normal", exclude_na=True):
        """Returns a table (list of lists) comparing the deltafactor results."""
        from pseudo_dojo.refdata.deltafactor import df_database
        dfdb = df_database()

        def fmt(float):
            return "%.3f" % float

        table = []; app = table.append
        app(["pseudo", "V0", "B0", "B1", "%V0", "%B0", "%B1", "Delta"])
        deltas, names = [], []
        for pseudo in self:
            if not pseudo.has_dojo_report or "delta_factor" not in pseudo.dojo_report:
                if not exclude_na: app([pseudo.name] + 7 * ["N/A"])
                continue

            ref = dfdb.get_entry(pseudo.symbol)
            vals = pseudo.dojo_report["delta_factor"][accuracy]
            v0, b0_GPa, b1, dfact = vals["v0"], vals["b0_GPa"], vals["b1"], vals["dfact"]
            rerr_v0  = 100 * (v0 - ref.v0) / ref.v0
            rerr_b0  = 100 * (b0_GPa - ref.b0_GPa) / ref.b0_GPa
            rerr_b1  = 100 * (b1 - ref.b1) / ref.b1
            app([pseudo.name] + map(fmt, [v0, b0_GPa, b1, rerr_v0, rerr_b0, rerr_b1, dfact]))

            deltas.append(dfact)
            names.append(pseudo.name)

        stats = compute_stats(deltas, labels=names)
        print(stats)
        return table
Exemplo n.º 3
0
    def get_results(self):
        results = super(DeltaFactorWork, self).get_results()

        num_sites = self._input_structure.num_sites
        etotals = self.read_etotals(unit="eV")

        results.update(dict(
            etotals=list(etotals),
            volumes=list(self.volumes),
            num_sites=num_sites))

        d = {}
        try:
            # Use same fit as the one employed for the deltafactor.
            eos_fit = EOS.DeltaFactor().fit(self.volumes/num_sites, etotals/num_sites)

            # Get reference results (Wien2K).
            wien2k = df_database().get_entry(self.pseudo.symbol)

            # Compute deltafactor estimator.
            dfact = df_compute(wien2k.v0, wien2k.b0_GPa, wien2k.b1,
                               eos_fit.v0, eos_fit.b0_GPa, eos_fit.b1, b0_GPa=True)
            dfact = dfact if not isinstance(dfact, complex) else float('NaN')

            dfactprime_meV = dfact * (30 * 100) / (eos_fit.v0 * eos_fit.b0_GPa)

            dfactprime_meV = dfactprime_meV if not isinstance(dfactprime_meV, complex) else float('NaN')

            print("delta", eos_fit)
            print("Ecut %.1f, dfact = %.3f meV, dfactprime %.3f meV" % (self.ecut, dfact, dfactprime_meV))

            results.update({
                "dfact_meV": dfact,
                "v0": eos_fit.v0,
                "b0": eos_fit.b0,
                "b0_GPa": eos_fit.b0_GPa,
                "b1": eos_fit.b1,
                "dfactprime_meV": dfactprime_meV
            })

            d = {k: results[k] for k in 
                ("dfact_meV", "v0", "b0", "b0_GPa", "b1", "etotals", "volumes", "num_sites", "dfactprime_meV")}

            # Write data for the computation of the delta factor
            with open(self.outdir.path_in("deltadata.txt"), "w") as fh:
                fh.write("# Deltafactor = %s meV\n" % dfact)
                fh.write("# Volume/natom [Ang^3] Etotal/natom [eV]\n")
                for v, e in zip(self.volumes, etotals):
                    fh.write("%s %s\n" % (v/num_sites, e/num_sites))

        except EOS.Error as exc:
            results.push_exceptions(exc)

        if results.exceptions:
            d["_exceptions"] = str(results.exceptions)

        self.write_dojo_report(d)

        return results
Exemplo n.º 4
0
    def get_results(self):
        num_sites = self._input_structure.num_sites

        etotal = ArrayWithUnit(self.read_etotal(), "Ha").to("eV")

        wf_results = super(DeltaFactorWorkflow, self).get_results()

        wf_results.update({
            "etotal"    : list(etotal),
            "volumes"   : list(self.volumes),
            "natom"     : num_sites,
            "dojo_level": 1,
        })

        try:
            #eos_fit = EOS.Murnaghan().fit(self.volumes/num_sites, etotal/num_sites)
            #print("murn",eos_fit)
            #eos_fit.plot(show=False, savefig=self.path_in_workdir("murn_eos.pdf"))

            # Use same fit as the one employed for the deltafactor.
            eos_fit = EOS.DeltaFactor().fit(self.volumes/num_sites, etotal/num_sites)

            eos_fit.plot(show=False, savefig=self.outdir.path_in("eos.pdf"))

            # FIXME: This object should be moved to pseudo_dojo.
            # Get reference results (Wien2K).
            from pseudo_dojo.refdata.deltafactor import df_database, df_compute
            wien2k = df_database().get_entry(self.pseudo.symbol)
                                                                                                 
            # Compute deltafactor estimator.
            dfact = df_compute(wien2k.v0, wien2k.b0_GPa, wien2k.b1, eos_fit.v0, eos_fit.b0_GPa, eos_fit.b1, b0_GPa=True)

            print("delta",eos_fit)
            print("Deltafactor = %.3f meV" % dfact)

            wf_results.update({
                "v0": eos_fit.v0,
                "b0": eos_fit.b0,
                "b0_GPa": eos_fit.b0_GPa,
                "b1": eos_fit.b1,
            })

        except EOS.Error as exc:
            wf_results.push_exceptions(exc)

        #if kwargs.get("json_dump", True):
        #    wf_results.json_dump(self.path_in_workdir("results.json"))

        # Write data for the computation of the delta factor
        with open(self.outdir.path_in("deltadata.txt"), "w") as fh:
            fh.write("# Deltafactor = %s meV\n" % dfact)
            fh.write("# Volume/natom [Ang^3] Etotal/natom [eV]\n")
            for (v, e) in zip(self.volumes, etotal):
                fh.write("%s %s\n" % (v/num_sites, e/num_sites))

        return wf_results
Exemplo n.º 5
0
    def make_report(self, results, **kwargs):
        # Get reference results (Wien2K).
        from pseudo_dojo.refdata.deltafactor import df_database, df_compute
        wien2k = df_database().get_entry(self.pseudo.symbol)

        # Get our results and compute deltafactor estimator.
        v0, b0_GPa, b1 = results["v0"], results["b0_GPa"], results["b1"]

        dfact = df_compute(wien2k.v0, wien2k.b0_GPa, wien2k.b1, v0, b0_GPa, b1, b0_GPa=True)
        print("Deltafactor = %.3f meV" % dfact)

        d = dict(v0=v0,
                 b0_GPa=b0_GPa,
                 b1=b1,
                 dfact=dfact
                )

        if results.exceptions:
            d["_exceptions"] = str(results.exceptions)

        d = {self.accuracy: d}
        return {self.dojo_key: d}
Exemplo n.º 6
0
 def __init__(self):
     self._dfdb = df_database()
Exemplo n.º 7
0
 def __init__(self, xc):
     """xc is the exchange-correlation functional e.g. PBE, PW."""
     # Get reference to the deltafactor database
     self._dfdb = df_database(xc)
Exemplo n.º 8
0
 def __init__(self, manager=None, workdir=None):
     # reference to the deltafactor database
     # use the elemental solid in the gs configuration
     self._dfdb = df_database()
     self.manager = manager
     self.workdir = workdir
Exemplo n.º 9
0
 def __init__(self):
     # Get a reference to the deltafactor database
     self._dfdb = df_database()
Exemplo n.º 10
0
 def __init__(self, xc='PBE'):
     # Get a reference to the deltafactor database
     self._dfdb = df_database(xc=xc)