Example #1
0
    def from_dict(cls, d):
        from pymatgen.serializers.json_coders import PMGJSONDecoder

        dec = PMGJSONDecoder()
        reactants = [dec.process_decoded(e) for e in d["reactants"]]
        products = [dec.process_decoded(e) for e in d["products"]]
        return cls(reactants, products)
 def from_dict(cls, d):
     dec = PMGJSONDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None))
 def from_dict(cls, d):
     dec = PMGJSONDecoder()
     return cls(d["composition"], d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None),
                attribute=d["attribute"] if "attribute" in d else None)
Example #4
0
    def from_dict(d):

        dec = PMGJSONDecoder()
        return ConversionElectrode(
            dec.process_decoded(d["voltage_pairs"]),
            dec.process_decoded(d["working_ion_entry"]),
            Composition(d["initial_comp"]),
        )
Example #5
0
 def from_dict(d):
     dec = PMGJSONDecoder()
     sub_d = {"optional_files": {}}
     for k, v in d.items():
         if k in ["INCAR", "POSCAR", "POTCAR", "KPOINTS"]:
             sub_d[k.lower()] = dec.process_decoded(v)
         elif k not in ["@module", "@class"]:
             sub_d["optional_files"][k] = dec.process_decoded(v)
     return VaspInput(**sub_d)
Example #6
0
 def from_dict(cls, d):
     dec = PMGJSONDecoder()
     working_ion_entry = dec.process_decoded(d["working_ion_entry"])
     balanced_rxn = dec.process_decoded(d["balanced_rxn"])
     entries_charge = dec.process_decoded(d["entries_charge"])
     entries_discharge = dec.process_decoded(d["entries_discharge"])
     return ConversionVoltagePair(balanced_rxn, d["voltage"], d["mAh"],
                                d["vol_charge"], d["vol_discharge"],
                                d["mass_charge"], d["mass_discharge"],
                                d["frac_charge"], d["frac_discharge"],
                                entries_charge, entries_discharge,
                                working_ion_entry)
Example #7
0
    def from_dict(cls, d):
        a = d["about"]
        dec = PMGJSONDecoder()

        created_at = dec.process_decoded(a.get("created_at"))
        data = {k: v for k, v in d["about"].items()
                if k.startswith("_")}
        data = dec.process_decoded(data)

        structure = Structure.from_dict(d) if "lattice" in d \
            else Molecule.from_dict(d)
        return cls(structure, a["authors"], projects=a.get("projects", None),
                   references=a.get("references", ""),
                   remarks=a.get("remarks", None), data=data,
                   history=a.get("history", None), created_at=created_at)
Example #8
0
    def test_entry(self):
        enc = PMGJSONEncoder()
        dec = PMGJSONDecoder()

        entry = ComputedEntry("Fe2O3", 2.3)
        jsonstr = enc.encode(entry)
        d = dec.decode(jsonstr)
        self.assertEqual(type(d), ComputedEntry)

        #Check list of entries
        entries = [entry, entry, entry]
        jsonstr = enc.encode(entries)
        d = dec.decode(jsonstr)
        for i in d:
            self.assertEqual(type(i), ComputedEntry)
        self.assertEqual(len(d), 3)
Example #9
0
    def test_to_from_dict(self):
        self.mitparamset = MITVaspInputSet()
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MaterialsProjectVaspInputSet()
        self.userparamset = MaterialsProjectVaspInputSet(
            {'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}}
        )
        dec = PMGJSONDecoder()
        d = self.mitparamset.to_dict
        v = dec.process_decoded(d)
        self.assertEqual(type(v), MITVaspInputSet)

        d = self.mitggaparam.to_dict
        v = dec.process_decoded(d)
        self.assertEqual(type(v), MITGGAVaspInputSet)

        d = self.mithseparamset.to_dict
        v = dec.process_decoded(d)
        self.assertEqual(type(v), MITHSEVaspInputSet)

        d = self.paramset.to_dict
        v = dec.process_decoded(d)
        self.assertEqual(type(v), MaterialsProjectVaspInputSet)

        d = self.userparamset.to_dict
        v = dec.process_decoded(d)
        self.assertEqual(type(v), MaterialsProjectVaspInputSet)
        self.assertEqual(v.incar_settings["MAGMOM"],
                         {"Fe": 10, "S": -5, "Mn3+": 100})
Example #10
0
 def from_dict(cls, d):
     dec = PMGJSONDecoder()
     entries = dec.process_decoded(d["original_entries"])
     terminal_compositions = dec.process_decoded(d["terminal_compositions"])
     return cls(entries, terminal_compositions,
                d["normalize_terminal_compositions"])
Example #11
0
 def from_dict(d):
     dec = PMGJSONDecoder()
     return ComputedEntry(d["composition"], d["energy"], d["correction"],
                          dec.process_decoded(d.get("parameters", {})),
                          dec.process_decoded(d.get("data", {})),
                          entry_id=d.get("entry_id", None))
Example #12
0
 def from_dict(cls, d):
     dec = PMGJSONDecoder()
     return cls(dec.process_decoded(d["voltage_pairs"]),
                dec.process_decoded(d["working_ion_entry"]),
                Composition(d["initial_comp"]))
Example #13
0
 def from_dict(cls, d):
     from pymatgen.serializers.json_coders import PMGJSONDecoder
     dec = PMGJSONDecoder()
     return cls(dec.process_decoded(d["entries"]),
                dec.process_decoded(d["working_ion_entry"]))