doped.utils.legacy_pmg package
Submodules
doped.utils.legacy_pmg.thermodynamics module
This code has been copied over from pymatgen==2022.7.25, as it was deleted in later versions. This is a temporary measure while refactoring to use the new pymatgen-analysis-defects package takes place.
Defect thermodynamics, such as defect phase diagrams, etc.
- class doped.utils.legacy_pmg.thermodynamics.DefectPhaseDiagram(entries, vbm, band_gap, metadata=None)[source]
Bases:
MSONableClass for analysing the thermodynamics of defects in solids. Similar to a pymatgen PhaseDiagram object, having the ability to quickly analyse defect formation energies when fed DefectEntry objects.
- This class is able to get:
stability of charge states for a given defect,
list of all formation energies,
transition levels in the gap,
used as input to doped plotting/analysis functions
- Parameters:
entries ([DefectEntry]) –
- A list of DefectEntry objects. Note that DefectEntry.name attributes
are used for grouping and plotting purposes! These should end be in the format “{defect_name}_{optional_site_info}_{charge_state}”. If the DefectEntry.name attribute is not defined or does not end with the charge state, then the entry will be renamed with the doped default name.
vbm (float) – VBM energy to use as Fermi level reference point for all defect entries.
band_gap (float) – Band gap value to use for all defect entries.
metadata (dict) – Dictionary of metadata to store with the PhaseDiagram. Has no impact on calculations.
- property all_stable_entries
List all stable entries (defect+charge) in the DefectPhaseDiagram.
- property all_unstable_entries
List all unstable entries (defect+charge) in the DefectPhaseDiagram.
- defect_concentrations(chemical_potentials, temperature=300, fermi_level=0.0)[source]
Give list of all concentrations at specified efermi in the DefectPhaseDiagram :param chemical_potentials = {Element: number} is dict of chemical potentials to provide formation
energies for temperature = temperature to produce concentrations from
- Parameters:
fermi_level – (float) is fermi level relative to valence band maximum Default efermi = 0 = VBM energy
- Returns:
list of dictionaries of defect concentrations.
- property defect_types
List types of defects existing in the DefectPhaseDiagram.
- find_stable_charges()[source]
Sets the stable charges and transition states for a series of defect entries. Defect entries are grouped together based on their DefectEntry.name attributes. These should end be in the format “{defect_name}_{optional_site_info}_{charge_state}”. If the DefectEntry.name attribute is not defined or does not end with the charge state, then the entry will be renamed with the doped default name.
This function uses scipy’s HalfspaceIntersection to construct the polygons corresponding to defect stability as a function of the Fermi-level. The Halfspace Intersection constructs N-dimensional hyperplanes, in this case N=2, based on the equation of defect formation energy with considering chemical potentials:
E_form = E_0^{Corrected} + Q_{defect}*(E_{VBM} + E_{Fermi}).
Extra hyperplanes are constructed to bound this space so that the algorithm can actually find enclosed region.
This code was modeled after the Halfspace Intersection code for the Pourbaix Diagram
- classmethod from_dict(d)[source]
Reconstitute a DefectPhaseDiagram object from a dict representation created using as_dict().
- Parameters:
d (dict) – dict representation of DefectPhaseDiagram.
- Returns:
DefectPhaseDiagram object
- get_dopability_limits(chemical_potentials)[source]
Find Dopability limits for a given chemical potential. This is defined by the defect formation energies which first cross zero in formation energies. This determine bounds on the fermi level.
Does this by computing formation energy for every stable defect with non-zero charge. If the formation energy value changes sign on either side of the band gap, then compute the fermi level value where the formation energy is zero (formation energies are lines and basic algebra shows: x_crossing = x1 - (y1 / q) for fermi level, x1, producing formation energy y1)
- Parameters:
chemical_potentials – dict of chemical potentials to use for calculation fermi level
- Returns:
lower dopability limit, upper dopability limit
(returns None if no limit exists for upper or lower i.e. no negative defect crossing before +/- 20 of band edges OR defect formation energies are entirely zero)
- plot(mu_elts=None, xlim=None, ylim=None, ax_fontsize=1.3, lg_fontsize=1.0, lg_position=None, fermi_level=None, title=None, saved=False)[source]
Produce defect Formation energy vs Fermi energy plot.
- Parameters:
mu_elts – a dictionary of {Element:value} giving the chemical potential of each element
xlim – Tuple (min,max) giving the range of the x (fermi energy) axis
ylim – Tuple (min,max) giving the range for the formation energy axis
ax_fontsize – float multiplier to change axis label fontsize
lg_fontsize – float multiplier to change legend label fontsize
lg_position – Tuple (horizontal-position, vertical-position) giving the position to place the legend. Example: (0.5,-0.75) will likely put it below the x-axis.
saved – Boolean to save the figure as a png file
fermi_level – float to plot a vertical line at a specific fermi level
title – string to set the title of the plot
- Returns:
a matplotlib object
- solve_for_fermi_energy(temperature, chemical_potentials, bulk_dos)[source]
Solve for the Fermi energy self-consistently as a function of T Observations are Defect concentrations, electron and hole conc :param temperature: Temperature to equilibrate fermi energies for :param chemical_potentials: dict of chemical potentials to use for calculation fermi level :param bulk_dos: bulk system dos (pymatgen Dos object).
- Returns:
Fermi energy dictated by charge neutrality.
- solve_for_non_equilibrium_fermi_energy(temperature, quench_temperature, chemical_potentials, bulk_dos)[source]
Solve for the Fermi energy after quenching in the defect concentrations at a higher temperature (the quench temperature), as outlined in P. Canepa et al (2017) Chemistry of Materials (doi: 10.1021/acs.chemmater.7b02909).
- Parameters:
temperature – Temperature to equilibrate fermi energy at after quenching in defects
quench_temperature – Temperature to equilibrate defect concentrations at (higher temperature)
chemical_potentials – dict of chemical potentials to use for calculation fermi level
bulk_dos – bulk system dos (pymatgen Dos object)
- Returns:
Fermi energy dictated by charge neutrality with respect to frozen in defect concentrations
Module contents
This code has been copied over from pymatgen==2022.7.25, as it was deleted in later versions.
This is a temporary measure while refactoring to use the new pymatgen-analysis- defects package takes place.
- class doped.utils.legacy_pmg.PointDefectComparator(check_charge=False, check_primitive_cell=False, check_lattice_scale=False)[source]
Bases:
MSONableA class that matches pymatgen Point Defect objects even if their Cartesian coordinates are different (compares sublattices for the defect).
NOTE: for defect complexes (more than a single defect), this comparator will break.
- Parameters:
check_charge (bool) – Gives option to check if charges are identical. Default is False (different charged defects can be same)
check_primitive_cell (bool) – Gives option to compare different supercells of bulk_structure, rather than directly compare supercell sizes Default is False (requires bulk_structure in each defect to be same size)
check_lattice_scale (bool) – Gives option to scale volumes of structures to each other identical lattice constants. Default is False (enforces same lattice constants in both structures).