Esempio n. 1
0
    def test_init(self):
        # both 'LiCoO2' and "FeF3" are using Li+ as working ion; MnO2 is for the multivalent Mg2+ ion
        formulas = ['LiCoO2', "FeF3", "MnO2"]
        expected_properties = {}
        expected_properties['LiCoO2'] = {'average_voltage': 2.26940307125,
                                         'capacity_grav': 903.19752911225669,
                                         'capacity_vol': 2903.35804724,
                                         'specific_energy': 2049.7192465127678,
                                         'energy_density': 6588.8896693479574}
        expected_properties['FeF3'] = {'average_voltage': 3.06179925889,
                                       'capacity_grav': 601.54508701578118,
                                       'capacity_vol': 2132.2069115142394,
                                       'specific_energy': 1841.8103016131706,
                                       'energy_density': 6528.38954147}
        expected_properties['MnO2'] = {'average_voltage': 1.7127027687901726,
                                       'capacity_grav': 790.9142070034802,
                                       'capacity_vol': 3543.202003526853,
                                       'specific_energy': 1354.6009522103434,
                                       'energy_density': 6068.451881823329}
        for f in formulas:

            with open(os.path.join(test_dir, f + "_batt.json"), 'r') as fid:
                entries = json.load(fid, cls=MontyDecoder)

                #entries = computed_entries_from_json(fid.read())

            # with open(os.path.join(test_dir, f + "_batt.json"), 'w') as fid:
            #json.dump(entries, fid, cls=MontyEncoder)
            if f in ['LiCoO2', "FeF3"]:
                working_ion = "Li"
            elif f in ["MnO2"]:
                working_ion = "Mg"
            c = ConversionElectrode.from_composition_and_entries(
                Composition(f), entries,working_ion_symbol=working_ion)
            self.assertEqual(len(c.get_sub_electrodes(True)), c.num_steps)
            self.assertEqual(len(c.get_sub_electrodes(False)),
                             sum(range(1, c.num_steps + 1)))
            self.assertIsNotNone(str(c))
            p = expected_properties[f]

            for k, v in p.items():
                self.assertAlmostEqual(getattr(c, "get_" + k).__call__(), v, 2)

            self.assertIsNotNone(c.get_summary_dict(True))

            #Test pair to dict

            pair = c.voltage_pairs[0]
            d = pair.as_dict()
            pair2 = ConversionVoltagePair.from_dict(d)
            for prop in ['voltage', 'mass_charge', 'mass_discharge']:
                self.assertEqual(getattr(pair, prop), getattr(pair2, prop), 2)

            #Test
            d = c.as_dict()
            electrode = ConversionElectrode.from_dict(d)
            for k, v in p.items():
                self.assertAlmostEqual(getattr(electrode,
                                               "get_" + k).__call__(), v, 2)
    def test_init(self):
        # both 'LiCoO2' and "FeF3" are using Li+ as working ion; MnO2 is for the multivalent Mg2+ ion
        formulas = ['LiCoO2', "FeF3", "MnO2"]
        expected_properties = {}
        expected_properties['LiCoO2'] = {'average_voltage': 2.26940307125,
                                         'capacity_grav': 903.19752911225669,
                                         'capacity_vol': 2903.35804724,
                                         'specific_energy': 2049.7192465127678,
                                         'energy_density': 6588.8896693479574}
        expected_properties['FeF3'] = {'average_voltage': 3.06179925889,
                                       'capacity_grav': 601.54508701578118,
                                       'capacity_vol': 2132.2069115142394,
                                       'specific_energy': 1841.8103016131706,
                                       'energy_density': 6528.38954147}
        expected_properties['MnO2'] = {'average_voltage': 1.7127027687901726,
                                       'capacity_grav': 790.9142070034802,
                                       'capacity_vol': 3543.202003526853,
                                       'specific_energy': 1354.6009522103434,
                                       'energy_density': 6068.451881823329}
        for f in formulas:

            with open(os.path.join(test_dir, f + "_batt.json"), 'r') as fid:
                entries = json.load(fid, cls=MontyDecoder)

                #entries = computed_entries_from_json(fid.read())

            # with open(os.path.join(test_dir, f + "_batt.json"), 'w') as fid:
            #json.dump(entries, fid, cls=MontyEncoder)
            if f in ['LiCoO2', "FeF3"]:
                working_ion = "Li"
            elif f in ["MnO2"]:
                working_ion = "Mg"
            c = ConversionElectrode.from_composition_and_entries(
                Composition(f), entries,working_ion_symbol=working_ion)
            self.assertEqual(len(c.get_sub_electrodes(True)), c.num_steps)
            self.assertEqual(len(c.get_sub_electrodes(False)),
                             sum(range(1, c.num_steps + 1)))
            self.assertIsNotNone(str(c))
            p = expected_properties[f]

            for k, v in p.items():
                self.assertAlmostEqual(getattr(c, "get_" + k).__call__(), v, 2)

            self.assertIsNotNone(c.get_summary_dict(True))

            #Test pair to dict

            pair = c.voltage_pairs[0]
            d = pair.as_dict()
            pair2 = ConversionVoltagePair.from_dict(d)
            for prop in ['voltage', 'mass_charge', 'mass_discharge']:
                self.assertEqual(getattr(pair, prop), getattr(pair2, prop), 2)

            #Test
            d = c.as_dict()
            electrode = ConversionElectrode.from_dict(d)
            for k, v in p.items():
                self.assertAlmostEqual(getattr(electrode,
                                               "get_" + k).__call__(), v, 2)
    def test_init(self):
        formulas = ['LiCoO2', "FeF3"]
        expected_properties = {}
        expected_properties['LiCoO2'] = {
            'average_voltage': 2.26940307125,
            'capacity_grav': 903.19752911225669,
            'capacity_vol': 2903.35804724,
            'specific_energy': 2049.7192465127678,
            'energy_density': 6588.8896693479574
        }
        expected_properties['FeF3'] = {
            'average_voltage': 3.06179925889,
            'capacity_grav': 601.54508701578118,
            'capacity_vol': 2132.2069115142394,
            'specific_energy': 1841.8103016131706,
            'energy_density': 6528.38954147
        }

        for f in formulas:

            with open(os.path.join(test_dir, f + "_batt.json"), 'r') as fid:
                entries = json.load(fid, cls=MontyDecoder)

                #entries = computed_entries_from_json(fid.read())

            # with open(os.path.join(test_dir, f + "_batt.json"), 'w') as fid:
            #json.dump(entries, fid, cls=MontyEncoder)

            c = ConversionElectrode.from_composition_and_entries(
                Composition(f), entries)
            self.assertEqual(len(c.get_sub_electrodes(True)), c.num_steps)
            self.assertEqual(len(c.get_sub_electrodes(False)),
                             sum(range(1, c.num_steps + 1)))
            self.assertIsNotNone(str(c))
            p = expected_properties[f]

            for k, v in p.items():
                self.assertAlmostEqual(getattr(c, "get_" + k).__call__(), v, 2)

            self.assertIsNotNone(c.get_summary_dict(True))

            #Test pair to dict

            pair = c.voltage_pairs[0]
            d = pair.as_dict()
            pair2 = ConversionVoltagePair.from_dict(d)
            for prop in ['voltage', 'mass_charge', 'mass_discharge']:
                self.assertEqual(getattr(pair, prop), getattr(pair2, prop), 2)

            #Test
            d = c.as_dict()
            electrode = ConversionElectrode.from_dict(d)
            for k, v in p.items():
                self.assertAlmostEqual(
                    getattr(electrode, "get_" + k).__call__(), v, 2)
    def test_init(self):
        formulas = ['LiCoO2', "FeF3"]
        expected_properties = {}
        expected_properties['LiCoO2'] = {'average_voltage': 2.26940307125,
                                         'capacity_grav': 903.19752911225669,
                                         'capacity_vol': 2903.35804724,
                                         'specific_energy': 2049.7192465127678,
                                         'energy_density': 6588.8896693479574}
        expected_properties['FeF3'] = {'average_voltage': 3.06179925889,
                                         'capacity_grav': 601.54508701578118,
                                         'capacity_vol': 2132.2069115142394,
                                         'specific_energy': 1841.8103016131706,
                                         'energy_density': 6528.38954147}

        for f in formulas:

            with open(os.path.join(test_dir, f + "_batt.json"), 'r') as fid:
                entries = json.load(fid, cls=PMGJSONDecoder)

                #entries = computed_entries_from_json(fid.read())

            # with open(os.path.join(test_dir, f + "_batt.json"), 'w') as fid:
            #json.dump(entries, fid, cls=PMGJSONEncoder)

            c = ConversionElectrode.from_composition_and_entries(
                                                                Composition(f),
                                                                entries)
            self.assertEqual(len(c.get_sub_electrodes(True)), c.num_steps)
            self.assertEqual(len(c.get_sub_electrodes(False)),
                             sum(xrange(1, c.num_steps + 1)))
            self.assertIsNotNone(str(c))
            p = expected_properties[f]

            for k, v in p.items():
                self.assertAlmostEqual(getattr(c, "get_" + k).__call__(), v, 2)

            self.assertIsNotNone(c.get_summary_dict(True))

            #Test pair to dict

            pair = c.voltage_pairs[0]
            d = pair.to_dict
            pair2 = ConversionVoltagePair.from_dict(d)
            for prop in ['voltage', 'mass_charge', 'mass_discharge']:
                self.assertEqual(getattr(pair, prop), getattr(pair2, prop), 2)

            #Test
            d = c.to_dict
            electrode = ConversionElectrode.from_dict(d)
            for k, v in p.items():
                self.assertAlmostEqual(getattr(electrode,
                                               "get_" + k).__call__(), v, 2)
    def test_init(self):
        # both 'LiCoO2' and "FeF3" are using Li+ as working ion; MnO2 is for the multivalent Mg2+ ion
        for f in self.formulas:
            c = self.conversion_eletrodes[f]["CE"]

            self.assertEqual(len(c.get_sub_electrodes(True)), c.num_steps)
            self.assertEqual(len(c.get_sub_electrodes(False)),
                             sum(range(1, c.num_steps + 1)))
            self.assertIsNotNone(str(c))
            p = self.expected_properties[f]

            for k, v in p.items():
                self.assertAlmostEqual(getattr(c, "get_" + k).__call__(), v, 2)

            self.assertIsNotNone(c.get_summary_dict(True))

            # Test pair to dict

            pair = c.voltage_pairs[0]
            d = pair.as_dict()
            pair2 = ConversionVoltagePair.from_dict(d)
            for prop in ["voltage", "mass_charge", "mass_discharge"]:
                self.assertEqual(getattr(pair, prop), getattr(pair2, prop), 2)

            # Test
            d = c.as_dict()
            electrode = ConversionElectrode.from_dict(d)
            for k, v in p.items():
                self.assertAlmostEqual(
                    getattr(electrode, "get_" + k).__call__(), v, 2)
Esempio n. 6
0
def conversion_elec(test_dir):
    conversion_eletrodes = {}

    entries_LCO = loadfn(test_dir / "LiCoO2_batt.json")
    c = ConversionElectrode.from_composition_and_entries(
        Composition("LiCoO2"), entries_LCO, working_ion_symbol="Li")
    conversion_eletrodes["LiCoO2"] = {
        "working_ion": "Li",
        "CE": c,
        "entries": entries_LCO,
    }

    expected_properties = {
        "LiCoO2": {
            "average_voltage": 2.26940307125,
            "capacity_grav": 903.19752911225669,
            "capacity_vol": 2903.35804724,
            "energy_grav": 2049.7192465127678,
            "energy_vol": 6588.8896693479574,
        }
    }

    return {
        k: (conversion_eletrodes[k], expected_properties[k])
        for k in conversion_eletrodes.keys()
    }
Esempio n. 7
0
    def setUp(self):
        entry_Li = ComputedEntry("Li", -1.90753119)

        with open(os.path.join(test_dir, "LiTiO2_batt.json"), "r") as f:
            entries_LTO = json.load(f, cls=MontyDecoder)
            self.ie_LTO = InsertionElectrode.from_entries(
                entries_LTO, entry_Li)

        with open(os.path.join(test_dir, "FeF3_batt.json"), "r") as fid:
            entries = json.load(fid, cls=MontyDecoder)
            self.ce_FF = ConversionElectrode.from_composition_and_entries(
                Composition("FeF3"), entries)
Esempio n. 8
0
    def testName(self):
        entry_Li = ComputedEntry("Li", -1.90753119)

        with open(os.path.join(test_dir, "LiTiO2_batt.json"), "r") as f:
            entries_LTO = json.load(f, cls=MontyDecoder)
            ie_LTO = InsertionElectrode(entries_LTO, entry_Li)

        with open(os.path.join(test_dir, "FeF3_batt.json"), 'r') as fid:
            entries = json.load(fid, cls=MontyDecoder)
            ce_FF = ConversionElectrode.from_composition_and_entries(
                Composition("FeF3"), entries)

        plotter = VoltageProfilePlotter(xaxis="frac_x")
        plotter.add_electrode(ie_LTO, "LTO insertion")
        plotter.add_electrode(ce_FF, "FeF3 conversion")
        self.assertIsNotNone(plotter.get_plot_data(ie_LTO))
        self.assertIsNotNone(plotter.get_plot_data(ce_FF))
Esempio n. 9
0
    def testName(self):
        entry_Li = ComputedEntry("Li", -1.90753119)

        with open(os.path.join(test_dir, "LiTiO2_batt.json"), "r") as f:
            entries_LTO = json.load(f, cls=MontyDecoder)
            ie_LTO = InsertionElectrode(entries_LTO, entry_Li)

        with open(os.path.join(test_dir, "FeF3_batt.json"), 'r') as fid:
            entries = json.load(fid, cls=MontyDecoder)
            ce_FF = ConversionElectrode.from_composition_and_entries(
                Composition("FeF3"),
                entries)

        plotter = VoltageProfilePlotter(xaxis="frac_x")
        plotter.add_electrode(ie_LTO, "LTO insertion")
        plotter.add_electrode(ce_FF, "FeF3 conversion")
        self.assertIsNotNone(plotter.get_plot_data(ie_LTO))
        self.assertIsNotNone(plotter.get_plot_data(ce_FF))
Esempio n. 10
0
 def from_composition_and_entries(
     cls,
     composition: Composition,
     entries: List[ComputedEntry],
     working_ion_symbol: str,
     task_id: Union[MPID, int],
 ):
     ce = ConversionElectrode.from_composition_and_entries(
         comp=composition,
         entries_in_chemsys=entries,
         working_ion_symbol=working_ion_symbol,
     )
     d = ce.get_summary_dict()
     d["num_steps"] = d.pop("nsteps", None)
     d["last_updated"] = datetime.utcnow()
     return cls(task_id=task_id,
                framework=Composition(d["framework_formula"]),
                **d)
    def setUp(self):

        self.formulas = ["LiCoO2", "FeF3", "MnO2"]
        self.conversion_eletrodes = {}
        for f in self.formulas:

            with open(
                    os.path.join(PymatgenTest.TEST_FILES_DIR,
                                 f + "_batt.json")) as fid:
                entries = json.load(fid, cls=MontyDecoder)
            if f in ["LiCoO2", "FeF3"]:
                working_ion = "Li"
            elif f in ["MnO2"]:
                working_ion = "Mg"
            c = ConversionElectrode.from_composition_and_entries(
                Composition(f), entries, working_ion_symbol=working_ion)
            self.conversion_eletrodes[f] = {
                "working_ion": working_ion,
                "CE": c
            }

        self.expected_properties = {
            "LiCoO2": {
                "average_voltage": 2.26940307125,
                "capacity_grav": 903.19752911225669,
                "capacity_vol": 2903.35804724,
                "specific_energy": 2049.7192465127678,
                "energy_density": 6588.8896693479574,
            },
            "FeF3": {
                "average_voltage": 3.06179925889,
                "capacity_grav": 601.54508701578118,
                "capacity_vol": 2132.2069115142394,
                "specific_energy": 1841.8103016131706,
                "energy_density": 6528.38954147,
            },
            "MnO2": {
                "average_voltage": 1.7127027687901726,
                "capacity_grav": 790.9142070034802,
                "capacity_vol": 3543.202003526853,
                "specific_energy": 1354.6009522103434,
                "energy_density": 6068.451881823329,
            },
        }