Beispiel #1
0
    def __init__(self, struct_type, formula, pseudos_or_dict, dojo_pptable):
        """
        Initialize the record for the chemical formula and the list of
        pseudopotentials.
        """
        keys = ("basename", "Z_val", "l_max", "md5")

        #if isinstance(pseudos_or_dict, (list, tuple)):
        if all(hasattr(p, "as_dict") for p in pseudos_or_dict):

            def get_info(p):
                """Extract the most important info from the pseudo."""
                #symbol = p.symbol
                d = p.as_dict()
                return {k: d[k] for k in keys}

            meta = {p.symbol: get_info(p) for p in pseudos_or_dict}
            pseudos = pseudos_or_dict

        else:
            meta = pseudos_or_dict
            for v in meta.values():
                assert set(v.keys()) == set(keys)

            def pmatch(ps, esymb, d):
                return (ps.md5 == d["md5"] and ps.symbol == esymb
                        and ps.Z_val == d["Z_val"] and ps.l_max == d["l_max"])

            pseudos = []
            for esymb, d in meta.items():
                for p in dojo_pptable.pseudo_with_symbol(esymb,
                                                         allow_multi=True):
                    if pmatch(p, esymb, d):
                        pseudos.append(p)
                        break
                else:
                    raise ValueError(
                        "Cannot find pseudo:\n %s\n in dojo_pptable" % str(d))

        super(GbrvRecord, self).__init__(formula=formula,
                                         pseudos_metadata=meta,
                                         normal=None,
                                         high=None)

        self.pseudos = DojoTable.as_table(pseudos)
        self.dojo_pptable = dojo_pptable
        self.struct_type = struct_type
Beispiel #2
0
    def __init__(self, struct_type, formula, pseudos_or_dict, dojo_pptable):
        """
        Initialize the record for the chemical formula and the list of
        pseudopotentials.
        """
        keys = ("basename", "Z_val", "l_max", "md5")

        #if isinstance(pseudos_or_dict, (list, tuple)):
        if all(hasattr(p, "as_dict") for p in pseudos_or_dict):
            def get_info(p):
                """Extract the most important info from the pseudo."""
                #symbol = p.symbol
                d = p.as_dict()
                return {k: d[k] for k in keys}

            meta = {p.symbol: get_info(p) for p in pseudos_or_dict}
            pseudos = pseudos_or_dict

        else:
            meta = pseudos_or_dict
            for v in meta.values():
                assert set(v.keys()) == set(keys)

            def pmatch(ps, esymb, d):
                return (ps.md5 == d["md5"] and
                        ps.symbol == esymb and
                        ps.Z_val == d["Z_val"] and
                        ps.l_max == d["l_max"])

            pseudos = []
            for esymb, d in meta.items():
                for p in dojo_pptable.pseudo_with_symbol(esymb, allow_multi=True):
                    if pmatch(p, esymb, d):
                        pseudos.append(p)
                        break
                else:
                    raise ValueError("Cannot find pseudo:\n %s\n in dojo_pptable" % str(d))

        super(GbrvRecord, self).__init__(formula=formula, pseudos_metadata=meta,
                                         normal=None, high=None)

        self.pseudos = DojoTable.as_table(pseudos)
        self.dojo_pptable = dojo_pptable
        self.struct_type = struct_type
Beispiel #3
0
    def relax_and_eos_work(self,
                           accuracy,
                           pseudos,
                           formula,
                           struct_type,
                           ecut=None,
                           pawecutdg=None,
                           ref="ae",
                           ngkpt=(8, 8, 8),
                           fband=2.0):
        """
        Returns a :class:`Work` object from the given pseudopotential.

        Args:
            kwargs: Extra variables passed to Abinit.

        .. note::

            GBRV tests are done with the following parameteres:

                - No spin polarization for structural relaxation
                  (only for magnetic moments for which spin-unpolarized structures are used)
                - All calculations are done on an 8x8x8 k-point density and with 0.002 Ry Fermi-Dirac smearing
        """
        pseudos = DojoTable.as_table(pseudos)
        if pseudos.allpaw and pawecutdg is None:
            raise ValueError(
                "pawecutdg must be specified for PAW calculations.")

        structure = self.make_ref_structure(formula,
                                            struct_type=struct_type,
                                            ref=ref)

        return GbrvCompoundRelaxAndEosWork(structure,
                                           formula,
                                           struct_type,
                                           pseudos,
                                           self.db.xc,
                                           accuracy,
                                           ecut=ecut,
                                           pawecutdg=pawecutdg,
                                           ngkpt=ngkpt,
                                           fband=fband)
Beispiel #4
0
    def test_db_update(self):
        """Testing DB update"""
        dirpath = dojotable_absdir("ONCVPSP-PBE")

        # Init an empty object.
        outdb = RocksaltOutdb.new_from_dojodir(dirpath)

        # No change here
        u = outdb.check_update()
        print(u)
        assert u.nrec_added == 0 and u.nrec_removed == 0

        # Now I hack a bit the object to simulate a pseudo that has been removed
        new_table = [p for p in outdb.dojo_pptable if p.basename != "Si.psp8"]
        outdb.dojo_pptable = DojoTable.as_table(new_table)

        # TODO:
        u = outdb.check_update()
        print(u)
        assert u.nrec_added == 0 and u.nrec_removed == 0
Beispiel #5
0
    def test_db_update(self):
        """Testing DB update"""
        return
        dirpath = dojotable_absdir("ONCVPSP-PBE")

        # Init an empty object.
        outdb = RocksaltOutdb.new_from_dojodir(dirpath)

        # No change here
        u = outdb.check_update()
        print(u)
        assert u.nrec_added == 0 and u.nrec_removed == 0

        # Now I hack a bit the object to simulate a pseudo that has been removed
        new_table = [p for p in outdb.dojo_pptable if p.basename != "Si.psp8"]
        outdb.dojo_pptable = DojoTable.as_table(new_table)

        # TODO:
        u = outdb.check_update()
        print(u)
        assert u.nrec_added == 0 and u.nrec_removed == 0
Beispiel #6
0
    def relax_and_eos_work(self, accuracy, pseudos, formula, struct_type,
                           ecut=None, pawecutdg=None, ref="ae", ngkpt=(8, 8, 8), fband=2.0):
        """
        Returns a :class:`Work` object from the given pseudopotential.

        Args:
            kwargs: Extra variables passed to Abinit.

        .. note::

            GBRV tests are done with the following parameteres:

                - No spin polarization for structural relaxation
                  (only for magnetic moments for which spin-unpolarized structures are used)
                - All calculations are done on an 8x8x8 k-point density and with 0.002 Ry Fermi-Dirac smearing
        """
        pseudos = DojoTable.as_table(pseudos)
        if pseudos.allpaw and pawecutdg is None:
            raise ValueError("pawecutdg must be specified for PAW calculations.")

        structure = self.make_ref_structure(formula, struct_type=struct_type, ref=ref)

        return GbrvCompoundRelaxAndEosWork(structure, formula, struct_type, pseudos, self.db.xc, accuracy,
                                           ecut=ecut, pawecutdg=pawecutdg, ngkpt=ngkpt, fband=fband)