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)
Ejemplo n.º 2
0
 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(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))
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
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"]),
        )
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
 def from_dict(cls, d):
     init = d["init_args"]
     return MagOrderingTransformation(
         init["mag_species_spin"],
         init["order_parameter"],
         energy_model=PMGJSONDecoder().process_decoded(
             init["energy_model"]),
         **init["enum_kwargs"])
Ejemplo n.º 13
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})
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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))
Ejemplo n.º 17
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"])
Ejemplo n.º 18
0
 def from_dict(cls, d):
     entries = PMGJSONDecoder().process_decoded(d["all_entries"])
     elements = PMGJSONDecoder().process_decoded(d["elements"])
     return cls(entries, d["chempots"], elements)
Ejemplo n.º 19
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"]))
Ejemplo n.º 20
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"]))
Ejemplo n.º 21
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"]))
Ejemplo n.º 22
0
 def from_dict(cls, d):
     chempots = {Element(symbol): u for symbol, u in d["chempots"].items()}
     entry = PMGJSONDecoder().process_decoded(d["entry"])
     return cls(entry, chempots, d["name"])
Ejemplo n.º 23
0
import unittest
import os
from numpy import array

from pymatgen.io.vaspio_set import MITVaspInputSet, MITHSEVaspInputSet, \
    MPVaspInputSet, MITGGAVaspInputSet, MITNEBVaspInputSet,\
    MPStaticVaspInputSet, MPNonSCFVaspInputSet, MITMDVaspInputSet
from pymatgen.io.vaspio.vasp_input import Poscar
from pymatgen import Specie, Lattice, Structure
from pymatgen.serializers.json_coders import PMGJSONDecoder

test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                        'test_files')

dec = PMGJSONDecoder()


class MITMPVaspInputSetTest(unittest.TestCase):
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        self.struct = poscar.structure

        self.mitparamset = MITVaspInputSet()
        self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False)
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MPVaspInputSet()
        self.userparamset = MPVaspInputSet(
            user_incar_settings={'MAGMOM': {
                "Fe": 10,
Ejemplo n.º 24
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"])
Ejemplo n.º 25
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"]))
Ejemplo n.º 26
0
 def from_dict(cls, d):
     entry = PMGJSONDecoder().process_decoded(d["entry"])
     return cls(d["composition"], entry)
Ejemplo n.º 27
0
 def __init__(self, parameters):
     self.update(parameters)
     self.jobs = map(VaspJob.from_dict, self['jobs'])
     dec = PMGJSONDecoder()
     self.handlers = map(dec.process_decoded, self['handlers'])
     self.max_errors = self.get('max_errors', 1)