PDHandler#

class PDHandler(phase_diagram)[source]#

Bases: object

Class to generate and handle Pymatgen phase diagram more rapidly.

Parameters:

phase_diagram (PhaseDiagram) – Pymatgen PhaseDiagram object

Methods

calculate_single_chempot

Calculate referenced chemical potential in a given composition and given the chemical potentials of the other elements.

get_all_boundaries_chempots

Get chemical potentials at the corners of the stability ta given composition.

get_chempot_diagram

Get the new interactive plot using pymatgen's new ChemicalPotentialDiagram class.

get_chempots_reference

Gets elemental reference compounds and respective e.p.a with Pymatgen el_ref attribute in PhaseDiagram class.

get_dataframe

Generate pandas DataFrame with columns 'Composition, Structure, Formation energy'.

get_energies_from_comp

Get dictionary of energies for all entries of a given reduced composition.

get_energy_from_stable_comp

Get energy of a target stable composition.

get_entries_from_comp

Get a list of entries corrisponding to the target composition.

get_formation_energies_from_comp

Get dictionary of formation energies for all entries of a given reduced composition.

get_formation_energy_from_stable_comp

Get formation energy of a target stable composition.

get_phase_boundaries_chempots

Given a composition and a fixed chemical potential, this function analises the composition of the boundary phases and the associated chemical potentials at the boundaries.

get_phase_boundaries_compositions

Get compositions of phases in boundary of stability with a target composition given a fixed chemical potential on one component.

get_plot

Get plot with Pymatgen

get_stability_diagram

Method to get stability diagram with 'get_chempot_range_map_plot' method in pymatgen.

get_stable_entry_from_comp

Get the PDEntry of the stable entry of a target composition.

solve_phase_boundary_chempots

Given a fixed chemical potential, gets the values of the remaining two chemical potentials in the boundary between two phases (region where the two phases coexist).

calculate_single_chempot(comp, chempots_ref)[source]#

Calculate referenced chemical potential in a given composition and given the chemical potentials of the other elements.

Parameters:
  • comp (str or Composition) – Compositions of the phase.

  • chempots_ref (Dict) – Dictionary with element symbols as keys and respective chemical potential as value ({el:chempot}). The chemical potentials used here are the ones relative to the reference (delta_mu).

Returns:

mu – Chemical potential.

Return type:

float

get_all_boundaries_chempots(comp)[source]#

Get chemical potentials at the corners of the stability ta given composition.

Parameters:

comp (str or Composition)

Returns:

chempots – Chempots object.

Return type:

Chempots

get_chempot_diagram(elements=None, **kwargs)[source]#

Get the new interactive plot using pymatgen’s new ChemicalPotentialDiagram class.

Plot the 2-dimensional or 3-dimensional chemical potential diagram using an interactive Plotly interface. Elemental axes can be specified; if none provided, will automatically default to first 2-3 elements within the “elements” attribute.

Parameters:
  • elements (list) – List of elements to use as axes in the diagram. If None, automatically defaults to the first 2 or elements within the object’s “elements” attribute.

  • kwargs (dict) – Kwargs to pass to ChemicalPotentialDiagram.get_plot

Return type:

plotly.graph_objects.Figure

get_chempots_reference()[source]#

Gets elemental reference compounds and respective e.p.a with Pymatgen el_ref attribute in PhaseDiagram class.

Returns:

chempots – Chempots object.

Return type:

Chempots

get_dataframe()[source]#

Generate pandas DataFrame with columns ‘Composition, Structure, Formation energy’. To display a string for ‘Structure’ the entry needs to be a ComputedStructureEntry (see pymatgen docs).

get_energies_from_comp(comp)[source]#

Get dictionary of energies for all entries of a given reduced composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

form_energies – Dictionary with PDEntry objects as keys and Energies as values.

Return type:

dict

get_energy_from_stable_comp(comp)[source]#

Get energy of a target stable composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

energy – Energy in eV.

Return type:

float

get_entries_from_comp(comp)[source]#

Get a list of entries corrisponding to the target composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

target_entries – List of Pymatgen PDEntry objects.

Return type:

list

get_formation_energies_from_comp(comp)[source]#

Get dictionary of formation energies for all entries of a given reduced composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

form_energies – Dictionary with PDEntry objects as keys and formation energies in eV as values.

Return type:

dict

get_formation_energy_from_stable_comp(comp)[source]#

Get formation energy of a target stable composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

form_energy – Formation energy in eV (float).

Return type:

float

get_phase_boundaries_chempots(comp, chempot_ref)[source]#

Given a composition and a fixed chemical potential, this function analises the composition of the boundary phases and the associated chemical potentials at the boundaries. Only works for 3 component PD.

Parameters:
  • comp (str or Composition) – Composition of the phase you want to get the chemical potentials at the boundary.

  • chempot_ref (dict) – Dictionary with fixed element symbol as key and respective chemical potential as value ({el:chempot}). The chemical potential here is the referenced value.

Returns:

chempots – Dictionary with compositions at the boundaries as keys and delta chemical potentials as value.

Return type:

dict

get_phase_boundaries_compositions(comp, chempot_ref)[source]#

Get compositions of phases in boundary of stability with a target composition given a fixed chemical potential on one component. Currently only works for 3-component PD (to check). Used Pymatgen GrandPotentialPhaseDiagram class. The fixed chemical potential is the referenced value that is converted in the global value for the analysis with the GrandPotentialPhaseDiagram class.

Parameters:
  • comp (str or Composition) – Target composition for which you want to get the bounday phases.

  • chempot_ref (dict) – Dictionary with fixed element symbol as key and respective chemical potential as value ({el:chempot}). The chemical potential is the referenced value

Returns:

comp1,comp2 – Compositions of the boundary phases given a fixed chemical potential for one element.

Return type:

(Composition objects)

get_plot(**kwargs)[source]#

Get plot with Pymatgen

get_stability_diagram(elements, figsize=None)[source]#

Method to get stability diagram with ‘get_chempot_range_map_plot’ method in pymatgen.

Parameters:
  • elements (list) – List with strings of the elements to be used as free variables.

  • size (tuple) – New size in inches.

Returns:

Matplotlib object.

Return type:

plt

get_stable_entry_from_comp(comp)[source]#

Get the PDEntry of the stable entry of a target composition.

Parameters:

comp (str or Composition) – Composition.

Returns:

entry – Pymatgen PDEntry object.

Return type:

PDEntry

solve_phase_boundary_chempots(comp1, comp2, chempot_ref)[source]#

Given a fixed chemical potential, gets the values of the remaining two chemical potentials in the boundary between two phases (region where the two phases coexist). Only works for 3-component PD (to check).

Given a phase P1 (formula AxByOz) and a phase P2 (formula AiBjOk) the chemical potentials have to satisfy the conditions:

  • form_energy(P1) = x*mu(A) + y*mu(B) +z*mu(O)

  • form_energy(P2) = i*mu(A) + j*mu(B) +k*mu(O)

From these conditions the values of mu(A) and mu(B) are determined given a fixed value of mu(O). All of the chemical potentials used here are delta_mu, i.e. relative to the elemental phase(delta_mu(O) = mu(O) - mu_ref(O))

Parameters:
  • comp1 (str or Composition) – Compositions of the two phases at the boundary.

  • comp2 (str or Composition) – Compositions of the two phases at the boundary.

  • chempot_ref (dict) – Dictionary with fixed element symbol as key and respective chemical potential as value ({el:chempot}). The chemical potential used here is the one relative to the reference (delta_mu).

Returns:

chempots_boundary – Dictionary of chemical potentials.

Return type:

dict