entries#
Store data for individual defect calculation
Classes
|
Object to store the results of a defect calculation. |
Functions
Returns the defect occupation as a function of the formation energy, using the Fermi-Dirac distribution with chemical potential equal to 0. |
|
Maxwell-Boltzmann distribution function. |
- class DefectEntry(defect, energy_diff=None, corrections={}, data=None, formation_energy_function=None, defect_concentration_function=None)[source]#
Bases:
MSONableObject to store the results of a defect calculation. This object is usually created automatically when importing results, either from directories or DataFrame.
- Parameters:
defect (Defect) – Defect object (Vacancy, Interstitial, Substitution, Polaron or DefectComplex)
energy_diff (float) – Difference btw energy of defect structure and energy of pristine (bulk) structure in eV.
corrections (dict) – Dictionary of corrections in eV to apply to defect formation energy. All values will be added to the defect formation energy. Keys indicate the correction type.
data (dict) – Store additional data in dict format.
label (str) – Additional label to add to defect specie.
formation_energy_function (function) – Custom function for calculation of defect formation energy. Check documentation in formation_energy function for more details.
defect_concentration_function (function) – Custom function for calculation of defect concentration. Check documentation in defect_concentration function for more details.
- property bulk_structure#
Structure of pristine material.
- property charge#
- property corrections#
Dictionary with corrections to the defect energy. Its values will be added to the formation energy.
- property data#
Dictionary containing additional data.
- property defect#
Defect object.
- defect_concentration(vbm=0, chemical_potentials=None, temperature=300, fermi_level=0.0, per_unit_volume=True, eform_kwargs={}, **kwargs)[source]#
Compute the defect concentration. If defect_concentration_function is set, the custom function is called, otherwise, the concentration is computed in the dilute limit as:
n = N * (1 / e^(Ef/kT) + 1), where:
N is the site multiplicity (in cm^-3 or per unit cell)
Ef is the formation energy of the defect.
k is the Boltzmann constant.
T is the temperature.
A custom function can be set when initializing the DefectEntry or by using the ‘set_defect_concentration_function` method. Use reset_defect_concentration_function to restore the default behaviour. If a custom function is given, the input must have the same args as this function, with the possibility to add more kwargs.
- Parameters:
vbm (float) – Valence band maximum of bulk calculation in eV
chemical_potentials (dict) – Chemical potentials of the elements involved in the defect.
temperature (float) – Temperature in Kelvin.
fermi_level (float) – Fermi level in eV (with respect to the VBM).
per_unit_volume (bool) – Compute concentrations per unit volume using self.defect.bulk_volume.
eform_kwargs (dict) – Kwargs to pass to self.formation_energy.
kwargs (dict) – Kwargs to pass to custom function.
Returns
--------
conc (float) – Defect concentration in cm^-3 or per unit cell.
- property defect_concentration_function#
- property defect_specie#
Species involved in defect.
- property defect_type#
Defect type.
- property delta_atoms#
Dictionary with Element as keys and particle difference between defect structure and bulk structure as values.
- property energy_diff#
- formation_energy(vbm=0, chemical_potentials=None, fermi_level=0, temperature=0, **kwargs)[source]#
Compute the formation energy of the defect. If formation_energy_function is set, the custom function is called, otherwise, the formation energy is computed as:
Ef = E_D - E_B + q(eVBM + fermi_level) + Ecorr - sum_i [(ni(D) - ni(B))* mu_i]
where:
E_D is the energy of the defective cell
- E_B is the energy of the pristine (bulk) cell
Note: E_D - E_B is self.energy_diff
eVBM is the valence band maximum energy
fermi_level is the chemical potential of electrons
Ecorr are correction terms
ni are the number of particles in the defective and pristine cells
mu_i are the chemical potentials of the elements.
A custom function can be set when initializing the DefectEntry or by using the ‘set_formation_energy_function` method. Use reset_formation_energy_function to restore the default behaviour. If a custom function is given, the input must have the same args as this function, with the possibility to add more kwargs.
- Parameters:
vbm (float) – Valence band maximum of bulk calculation in eV
chemical_potentials (dict) – Chemical potentials of the elements involved in the defect.
fermi_level (float) – Fermi level in eV (with respect to the VBM).
temperature (float) – Temperature in Kelvin. If a custom function is not passed, this parameter has no effect.
kwargs (dict) – Kwargs to pass to custom function.
- Returns:
formation_energy – Formation energy in eV.
- Return type:
float
- property formation_energy_function#
- static from_computed_entries(computed_entry_defect, computed_entry_bulk, corrections, multiplicity=1, data=None, label=None, initial_structure=False, **kwargs)[source]#
Generate DefectEntry object from Pymatgen’s ComputedStructureEntry objects.
- Parameters:
computed_entry_defect (VaspJob) – ComputedStructureEntry of the defect calculation.
computed_entry_bulk (VaspJob) – ComputedStructureEntry of the bulk calculation.
corrections (dict) – Dict of corrections for defect formation energy. All values will be summed and added to the defect formation energy.
multiplicity (int) – Multiplicity of defect within the supercell. If set to None is attempted to be determined automatically.
data (dict) – Store additional data in dict format.
label (str) – Additional label to add to defect specie. Does not influence non equilibrium calculations.
initial_structure (bool) – Use initial structure for defect recognition. Useful when relaxations are large and defect_finder struggles to find the right defects.
kwargs (dict) – Kwargs to pass to defect_finder.
- Returns:
entry – DefectEntry object
- Return type:
- classmethod from_dict(d)[source]#
Reconstitute a DefectEntry object from a dict representation created using as_dict().
- Parameters:
d (dict) – Dictionary representation of DefectEntry.
- Returns:
entry – DefectEntry object
- Return type:
- static from_structures(defect_structure, bulk_structure, energy_diff, corrections, charge=0, multiplicity=1, data=None, label=None, **kwargs)[source]#
Generate DefectEntry object from Structure objects.
- Parameters:
defect_structure (Structure) – Defect structure.
bulk_structure (Structure) – Bulk structure.
energy_diff (float) – Difference btw energy of defect structure and energy of pristine structure
corrections (dict) – Dict of corrections in eV for defect formation energy. All values will be summed and added to the defect formation energy.
charge (int or float) – Charge of the defect system. The default is 0.
multiplicity (int) – multiplicity of defect within the supercell. If set to None is attempted to be determined automatically with Pymatgen. The default is 1.
data (dict) – Store additional data in dict format.
label (str) – Additional label to add to defect specie. Does not influence non equilibrium calculations.
kwargs (dict) – Kwargs to pass to defect_finder. ‘verbose’ is set to True by default.
- Returns:
entry – DefectEntry object
- Return type:
- static from_vasp_directories(path_defect, computed_entry_bulk=None, path_bulk=None, corrections={}, multiplicity=1, data=None, label=None, initial_structure=False, function=None, function_kwargs={}, computed_entry_kwargs={}, finder_kwargs={})[source]#
Generate DefectEntry object from VASP directories read with Pymatgen.
- Parameters:
path_defect (str) – Path of VASP defect calculation.
computed_entry_bulk (VaspJob) – ComputedStructureEntry of the bulk calculation.
path_bulk (str) – If computed_entry_bulk is not provided, read directly from VASP directory.
corrections (dict) – Dict of corrections for defect formation energy. All values will be summed and added to the defect formation energy.
multiplicity (int) – Multiplicity of defect within the supercell. If set to None is attempted to be determined automatically with Pymatgen. The default is 1.
data (dict) – Store additional data in dict format.
label (str) – Additional label to add to defect specie. Does not influence non equilibrium calculations.
initial_structure (bool) – Use initial structure for defect recognition. Useful when relaxations are large and defect_finder struggles to find the right defects.
function (function) – Function to apply to DefectEntry. Useful to automate custom entry modification. The function can modify entry attributes and returns None.
function_kwargs (dict) – Kwargs to pass to custom function.
computed_entr_kwargs (dict) – Kwargs to pass to Vasprun.get_computed_entry.
finder_kwargs (dict) – Kwargs to pass to defect_finder.
- Returns:
entry – DefectEntry object
- Return type:
- property label#
- property multiplicity#
- property name#
- relaxation_volume(stress_bulk, bulk_modulus, stress_defect=None, corrections={})[source]#
Calculate relaxation volume from stresses. Stress of defect calculation needs to be provided either directly or in data dict with “stress” key.
- Parameters:
stress_bulk (np.array) – Stresses from bulk calculation in kbar (units of VASP output)
bulk_volume (float) – Cell volume of bulk calculation in A°^3.
bulk_modulus (float) – Bulk modulus in GPa.
stress_defect (np.array) – Stresses from defect calculation in kbar (units of VASP output)
corrections (bool) – Add correction terms to the residual stress tensor.
- Returns:
rel_volume – Relaxation volume in A°^3.
- Return type:
float
- set_multiplicity(new_multiplicity=None)[source]#
Sets the Multiplicity of the defect. If new_multiplicity is not provided it is determined with self.defect.get_multiplicity
- property structure#
- property symbol#
- property symbol_charge#
Defect symbol with charge formatted with numbers.
- property symbol_kroger#
Defect symbol with charge formatted with Kröger-Vink notation.
- fermi_dirac(E, T)[source]#
Returns the defect occupation as a function of the formation energy, using the Fermi-Dirac distribution with chemical potential equal to 0.
- Parameters:
E (float) – Energy in eV
T (float) – Temperature in Kelvin.
- maxwell_boltzmann(E, T, clip=True)[source]#
Maxwell-Boltzmann distribution function. Can be clipped to prevent divergence.
- Parameters:
E (float) – Energy in eV.
fermi (float) – Fermi level in eV.
T (float) – Temperature in kelvin.
clip (bool) – Clip exponential factor to 700 to avoid divergence, returns 1e304.
- Returns:
occupation – Maxwell-Boltzmann occupation probability at energy E.
- Return type:
float