phase_diagram#
Compute chemical potentials from phase diagrams
Classes
|
Class to generate and handle Pymatgen phase diagram more rapidly. |
|
Class with tools to add features to default PD plots generated by Pymatgen. |
- class PDHandler(phase_diagram)[source]#
Bases:
objectClass to generate and handle Pymatgen phase diagram more rapidly.
- Parameters:
phase_diagram (PhaseDiagram) – Pymatgen PhaseDiagram object
- 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:
- 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:
- 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_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
- class StabilityDiagram(phase_diagram=None, size=1)[source]#
Bases:
objectClass with tools to add features to default PD plots generated by Pymatgen.
- Parameters:
phase_diagram (PhaseDiagram) – Pymatgen PhaseDiagram object.
size (float) – Multiplier for the size of the objects added in the plot.
- add_constant_chempot_line(comp, variable_element, chempots_ref, **kwargs)[source]#
Add line of constant chemical potential (at a given composition) to the plot. Only works for 3 component PD.
- Parameters:
comp (str or Composition) – Composition of the phase.
variable_element (str) – Element chosen as indipendent variable.
chempots_ref (dict) – Dictionary with fixed chemical potentials (values relative to reference phase). The format is {Element:chempot}.
**kwargs – kwargs passed to Matplotlib plot function.
- Returns:
plt – Matplotlib object.
- Return type:
matlotlib
- add_heatmap(comp, elements, cbar_label='$\\Delta \\mu_{O}$', cbar_values=True, **kwargs)[source]#
Add heatmap that shows the value of the last chemical potential based on the values of the other two “free” chemical potentials and the composition of interest. Currently works only for 3 component PDs.
- Parameters:
comp (str or Composition) – Composition of interest to compute the chemical potential.
elements (list) – List of strings with elements with free chemical potentials.
cbar_label (str) – String with label of the colormap. The default is ‘’.
cbar_values (tuple or bool) – Show max e min chempot values on colorbar. If tuple the values are used, if not the minimum chempot and 0 are used. The default is True.
**kwargs (dict) – kwargs for “pcolormesh” function.
- Returns:
plt – Matplotlib object.
- Return type:
matplotlib
- add_points(points, size=1, label_size=1, color=[], edgecolor='k', label_color='k', linewidths=3, **kwargs)[source]#
Add points to plot representing reservoirs.
- Parameters:
points (dict) – Dictionary with points labels as keys and tuples or list with coordinates as values.
size (float) – Float multiplier for points size. Default is 1, which would yield a default size of 450*self.size
label_size (float) – Float multiplier for labels size. Default is 1, which would yield a default size of 30*self.size
color (str) – Color of filling of points
edgecolor (str) – Color of point edge
label_color (str) – Color of labels
linewidths (int) – line width of point edge
kwargs (dict) – kwargs to pass to matplotlib scatter function.
- Returns:
plt – Matplotlib object.
- Return type:
matplotlib
- add_reservoirs(reservoirs, elements, size=1, label_size=1, color=[], edgecolor='k', label_color='k', linewidths=3, **kwargs)[source]#
Add reservoirs as points on the stability diagram.
- Parameters:
reservoirs (Reservoirs) – Reservoirs object.
elements (list) – List with strings of the elements to be used as free variables.
size (float) – Float multiplier for points size. Default is 1, which would yield a default size of 450*self.size
label_size (float) – Float multiplier for labels size. Default is 1, which would yield a default size of 30*self.size
color (str) – Color of filling of points
edgecolor (str) – Color of point edge
label_color (str) – Color of labels
linewidths (3) – line width of point edge
kwargs (dict) – kwargs to pass to matplotlib scatter function.
- Returns:
plt – Matplotlib object.
- Return type:
matplotlib
- constant_chempot_line(mu, comp, variable_element, chempots_ref)[source]#
Function that expresses line of constant chemical potential of a given composition. Only works for 3-component PD.
- Parameters:
mu (float) – Indipendent variable of chemical potential.
comp (str or Composition) – Composition of the phase.
variable_element (Pymatgen Element object) – Element chosen as indipendent variable.
chempots_ref (dict) – Dictionary with fixed chemical potentials (values relative to reference phase). The format is {Element:chempot}.
- Returns:
chempot – Chemical potential in eV.
- Return type:
float
- get_plot(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.
figsize (tuple) – New size in inches.
- Returns:
plt – Matplotlib object.
- Return type:
matplotlib