def get_entries(self, chemsys_formula_id, compatible_only=True, inc_structure=None): """ Get a list of ComputedEntries or ComputedStructureEntries corresponding to a chemical system, formula, or materials_id. Args: chemsys_formula_id (str): A chemical system (e.g., Li-Fe-O), or formula (e.g., Fe2O3) or materials_id (e.g., mp-1234). compatible_only (bool): Whether to return only "compatible" entries. Compatible entries are entries that have been processed using the MaterialsProjectCompatibility class, which performs adjustments to allow mixing of GGA and GGA+U calculations for more accurate phase diagrams and reaction energies. inc_structure (str): If None, entries returned are ComputedEntries. If inc_structure="final", ComputedStructureEntries with final structures are returned. Otherwise, ComputedStructureEntries with initial structures are returned. Returns: List of ComputedEntry or ComputedStructureEntry objects. """ # TODO: This is a very hackish way of doing this. It should be fixed # on the REST end. if compatible_only: data = self.get_data(chemsys_formula_id, prop="entry") entries = [d["entry"] for d in data] if inc_structure: for i, e in enumerate(entries): s = self.get_structure_by_material_id( e.entry_id, inc_structure == "final") entries[i] = ComputedStructureEntry( s, e.energy, e.correction, e.parameters, e.data, e.entry_id) entries = MaterialsProjectCompatibility().process_entries(entries) else: entries = [] for d in self.get_data(chemsys_formula_id, prop="task_ids"): for i in d["task_ids"]: e = self.get_task_data(i, prop="entry") e = e[0]["entry"] if inc_structure: s = self.get_task_data( i, prop="structure")[0]["structure"] e = ComputedStructureEntry(s, e.energy, e.correction, e.parameters, e.data, e.entry_id) entries.append(e) return entries
def get_entries(self, chemsys_formula_id, compatible_only=True, inc_structure=None): """ Get a list of ComputedEntries or ComputedStructureEntries corresponding to a chemical system, formula, or materials_id. Args: chemsys_formula_id (str): A chemical system (e.g., Li-Fe-O), or formula (e.g., Fe2O3) or materials_id (e.g., mp-1234). compatible_only (bool): Whether to return only "compatible" entries. Compatible entries are entries that have been processed using the MaterialsProjectCompatibility class, which performs adjustments to allow mixing of GGA and GGA+U calculations for more accurate phase diagrams and reaction energies. inc_structure (str): If None, entries returned are ComputedEntries. If inc_structure="final", ComputedStructureEntries with final structures are returned. Otherwise, ComputedStructureEntries with initial structures are returned. Returns: List of ComputedEntry or ComputedStructureEntry objects. """ # TODO: This is a very hackish way of doing this. It should be fixed # on the REST end. if compatible_only: data = self.get_data(chemsys_formula_id, prop="entry") entries = [d["entry"] for d in data] if inc_structure: for i, e in enumerate(entries): s = self.get_structure_by_material_id( e.entry_id, inc_structure == "final") entries[i] = ComputedStructureEntry( s, e.energy, e.correction, e.parameters, e.data, e.entry_id) entries = MaterialsProjectCompatibility().process_entries(entries) else: entries = [] for d in self.get_data(chemsys_formula_id, prop="task_ids"): for i in d["task_ids"]: e = self.get_task_data(i, prop="entry") e = e[0]["entry"] if inc_structure: s = self.get_task_data(i, prop="structure")[0]["structure"] e = ComputedStructureEntry( s, e.energy, e.correction, e.parameters, e.data, e.entry_id) entries.append(e) return entries
def get_entries(self, chemsys_formula_id_criteria, compatible_only=True, inc_structure=None, property_data=None): """ Get a list of ComputedEntries or ComputedStructureEntries corresponding to a chemical system, formula, or materials_id or full criteria. Args: chemsys_formula_id_criteria (str/dict): A chemical system (e.g., Li-Fe-O), or formula (e.g., Fe2O3) or materials_id (e.g., mp-1234) or full Mongo-style dict criteria. compatible_only (bool): Whether to return only "compatible" entries. Compatible entries are entries that have been processed using the MaterialsProjectCompatibility class, which performs adjustments to allow mixing of GGA and GGA+U calculations for more accurate phase diagrams and reaction energies. inc_structure (str): If None, entries returned are ComputedEntries. If inc_structure="final", ComputedStructureEntries with final structures are returned. Otherwise, ComputedStructureEntries with initial structures are returned. property_data (list): Specify additional properties to include in entry.data. If None, no data. Should be a subset of supported_properties. Returns: List of ComputedEntry or ComputedStructureEntry objects. """ # TODO: This is a very hackish way of doing this. It should be fixed # on the REST end. params = ["run_type", "is_hubbard", "pseudo_potential", "hubbards", "potcar_symbols"] if compatible_only: props = ["energy", "unit_cell_formula", "task_id"] + params if property_data: props += property_data if inc_structure: if inc_structure == "final": props.append("structure") else: props.append("initial_structure") if not isinstance(chemsys_formula_id_criteria, dict): criteria = MPRester.parse_criteria(chemsys_formula_id_criteria) else: criteria = chemsys_formula_id_criteria data = self.query(criteria, props) entries = [] for d in data: d["potcar_symbols"] = [ "%s %s" % (d["pseudo_potential"]["functional"], l) for l in d["pseudo_potential"]["labels"]] data = {k: d[k] for k in property_data} if property_data else None if not inc_structure: e = ComputedEntry(d["unit_cell_formula"], d["energy"], parameters={k: d[k] for k in params}, data=data, entry_id=d["task_id"]) else: s = d["structure"] if inc_structure == "final" else d[ "initial_structure"] e = ComputedStructureEntry( s, d["energy"], parameters={k: d[k] for k in params}, data=data, entry_id=d["task_id"]) entries.append(e) from pymatgen.entries.compatibility import \ MaterialsProjectCompatibility entries = MaterialsProjectCompatibility().process_entries(entries) else: entries = [] for d in self.get_data(chemsys_formula_id_criteria, prop="task_ids"): for i in d["task_ids"]: e = self.get_task_data(i, prop="entry") e = e[0]["entry"] if inc_structure: s = self.get_task_data(i, prop="structure")[0]["structure"] e = ComputedStructureEntry( s, e.energy, e.correction, e.parameters, e.data, e.entry_id) entries.append(e) return entries