def setUp(self): self.entry_Li = ComputedEntry("Li", -1.90753119) self.entry_Ca = ComputedEntry("Ca", -1.99689568) with open( os.path.join(PymatgenTest.TEST_FILES_DIR, "LiTiO2_batt.json"), "r") as f: self.entries_LTO = json.load(f, cls=MontyDecoder) with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "MgVO_batt.json"), "r") as file: self.entries_MVO = json.load(file, cls=MontyDecoder) with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "Mg_batt.json"), "r") as file: self.entry_Mg = json.load(file, cls=MontyDecoder) with open( os.path.join(PymatgenTest.TEST_FILES_DIR, "CaMoO2_batt.json"), "r") as f: self.entries_CMO = json.load(f, cls=MontyDecoder) self.ie_LTO = InsertionElectrode.from_entries(self.entries_LTO, self.entry_Li) self.ie_MVO = InsertionElectrode.from_entries(self.entries_MVO, self.entry_Mg) self.ie_CMO = InsertionElectrode.from_entries(self.entries_CMO, self.entry_Ca)
def test_init_no_structure(self): def remove_structure(entries): ents = [] for ient in entries: dd = ient.as_dict() ent = ComputedEntry.from_dict(dd) ent.data["volume"] = ient.structure.volume ents.append(ent) return ents ie_CMO_no_struct = InsertionElectrode.from_entries( remove_structure(self.entries_CMO), self.entry_Ca) d = ie_CMO_no_struct.as_dict_summary() self.assertAlmostEqual(d["stability_charge"], 0.2346574583333325) self.assertAlmostEqual(d["stability_discharge"], 0.33379544031249786) self.assertAlmostEqual(d["muO2_data"]["mp-714969"][0]["chempot"], -4.93552791875) ie_LTO_no_struct = InsertionElectrode.from_entries( self.entries_LTO, self.entry_Li, strip_structures=True) vols_no_struct = [ ient.data["volume"] for ient in ie_LTO_no_struct.get_all_entries() ] vols_struct = [ ient.structure.volume for ient in self.ie_LTO.get_all_entries() ] self.assertAlmostEqual(vols_no_struct, vols_struct)
def from_entries( cls, grouped_entries: List[ComputedEntry], working_ion_entry: ComputedEntry, battery_id: str, host_structure: Structure, ) -> Union["InsertionElectrodeDoc", None]: try: ie = InsertionElectrode.from_entries( entries=grouped_entries, working_ion_entry=working_ion_entry, strip_structures=True, ) except IndexError: return None d = ie.get_summary_dict() d["material_ids"] = d["stable_material_ids"] + d[ "unstable_material_ids"] d["num_steps"] = d.pop("nsteps", None) d["last_updated"] = datetime.utcnow() elements = sorted(host_structure.composition.elements) chemsys = "-".join(sorted(map(str, elements))) framework = Composition(d["framework_formula"]) return cls(battery_id=battery_id, host_structure=host_structure.as_dict(), framework=framework, electrode_object=ie.as_dict(), elements=elements, nelements=len(elements), chemsys=chemsys, formula_anonymous=framework.anonymized_formula, **d)
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)
def insertion_elec(test_dir): """ Recycle the test cases from pymatgen """ entry_Li = ComputedEntry("Li", -1.90753119) # more cases can be added later if problems are found entries_LTO = loadfn(test_dir / "LiTiO2_batt.json") ie_LTO = InsertionElectrode.from_entries(entries_LTO, entry_Li) d = { "LTO": (ie_LTO, entries_LTO[0].structure, entry_Li), } return d
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.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) 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))