pymatgen.entries.entry_tools module

This module implements functions to perform various useful operations on entries, such as grouping entries by structure.

class EntrySet(entries: List[Union[pymatgen.analysis.phase_diagram.PDEntry, pymatgen.entries.computed_entries.ComputedEntry, pymatgen.entries.computed_entries.ComputedStructureEntry]])[source]

Bases: collections.abc.MutableSet, monty.json.MSONable

A convenient container for manipulating entries. Allows for generating subsets, dumping into files, etc.

Parameters

entries – All the entries.

add(element)[source]

Add an element.

as_dict()[source]

A JSON serializable dict representation of an object.

chemsys

Returns: set representing the chemical system, e.g., {“Li”, “Fe”, “P”, “O”}

discard(element)[source]

Remove an element. Do not raise an exception if absent.

classmethod from_csv(filename: str)[source]

Imports PDEntries from a csv.

Parameters

filename – Filename to import from.

Returns

List of Elements, List of PDEntries

get_subset_in_chemsys(chemsys: List[str])[source]

Returns an EntrySet containing only the set of entries belonging to a particular chemical system (in this definition, it includes all sub systems). For example, if the entries are from the Li-Fe-P-O system, and chemsys=[“Li”, “O”], only the Li, O, and Li-O entries are returned.

Parameters

chemsys – Chemical system specified as list of elements. E.g., [“Li”, “O”]

Returns

EntrySet

remove_non_ground_states()[source]

Removes all non-ground state entries, i.e., only keep the lowest energy per atom entry at each composition.

to_csv(filename: str, latexify_names: bool = False)[source]

Exports PDEntries to a csv

Parameters
  • filename – Filename to write to.

  • entries – PDEntries to export.

  • latexify_names – Format entry names to be LaTex compatible, e.g., Li_{2}O

group_entries_by_structure(entries, species_to_remove=None, ltol=0.2, stol=0.4, angle_tol=5, primitive_cell=True, scale=True, comparator=<pymatgen.analysis.structure_matcher.SpeciesComparator object>, ncpus=None)[source]

Given a sequence of ComputedStructureEntries, use structure fitter to group them by structural similarity.

Parameters
  • entries – Sequence of ComputedStructureEntries.

  • species_to_remove – Sometimes you want to compare a host framework (e.g., in Li-ion battery analysis). This allows you to specify species to remove before structural comparison.

  • ltol (float) – Fractional length tolerance. Default is 0.2.

  • stol (float) – Site tolerance in Angstrom. Default is 0.4 Angstrom.

  • angle_tol (float) – Angle tolerance in degrees. Default is 5 degrees.

  • primitive_cell (bool) – If true: input structures will be reduced to primitive cells prior to matching. Defaults to True.

  • scale – Input structures are scaled to equivalent volume if true; For exact matching, set to False.

  • comparator – A comparator object implementing an equals method that declares equivalency of sites. Default is SpeciesComparator, which implies rigid species mapping.

  • ncpus – Number of cpus to use. Use of multiple cpus can greatly improve fitting speed. Default of None means serial processing.

Returns

Sequence of sequence of entries by structural similarity. e.g, [[ entry1, entry2], [entry3, entry4, entry5]]