# pymatgen.analysis.defects.core module¶

class Defect(structure, defect_site, charge=0.0)[source]

Bases: monty.json.MSONable

Abstract class for a single point defect

Initializes an abstract defect

Parameters
• structure – Pymatgen Structure without any defects

• defect_site (Site) – site for defect within structure must have same lattice as structure

• charge – (int or float) defect charge default is zero, meaning no change to NELECT after defect is created in the structure (assuming use_structure_charge=True in vasp input set)

bulk_structure

Returns the structure without any defects.

charge

Returns the charge of a defect

copy()[source]

Convenience method to get a copy of the defect.

Returns

A copy of the Defect.

defect_composition

Returns the defect composition as a Composition object

generate_defect_structure(supercell=(1, 1, 1))[source]

Given structure and defect_site (and type of defect) should return a defect_structure that is charged :param supercell: supercell integer, vector, or scaling matrix :type supercell: int, [3x1], or [[]] (3x3)

multiplicity

Returns the multiplicity of a defect site within the structure (needed for concentration analysis)

name

Returns a name for this defect

set_charge(new_charge=0.0)[source]

Sets the overall charge :param charge: new charge to set :type charge: float

site

Returns the defect position as a site object

class DefectCorrection[source]

Bases: monty.json.MSONable

A Correction class modeled off the computed entry correction format

correct_entry(entry)[source]

Corrects a single entry.

Parameters

entry – A DefectEntry object.

Returns

An processed entry.

Raises

CompatibilityError if entry is not compatible.

get_correction(entry)[source]

Returns correction for a single entry.

Parameters

entry – A DefectEntry object.

Returns

A single dictionary with the format correction_name: energy_correction

Raises

CompatibilityError if entry is not compatible.

class DefectEntry(defect, uncorrected_energy, corrections=None, parameters=None, entry_id=None)[source]

Bases: monty.json.MSONable

An lightweight DefectEntry object containing key computed data for many defect analysis.

Parameters
• defect – A Defect object from pymatgen.analysis.defects.core

• uncorrected_energy (float) – Energy of the defect entry. Usually the difference between the final calculated energy for the defect supercell - the perfect supercell energy

• corrections ([Correction]) – List of Correction classes (from pymatgen.analysis.defects.corrections) which correct energy due to charge (e.g. Freysoldt or Kumagai) or other factors (e.g. Shallow level shifts)

• parameters (dict) – An optional dict of calculation parameters and data to use with correction schemes (examples of parameter keys: supercell_size, axis_grid, bulk_planar_averages defect_planar_averages )

• entry_id (obj) – An id to uniquely identify this defect, can be any MSONable type

Optional:

note that if you intend to use this defect entry with Charge Corrections but the bulk_structure stored in defect is not the final supercell, then ‘scaling_matrix’ must be stored in parameters

for example: parameters = {‘scaling_matrix’: [3,3,3]}

as_dict()[source]

Json-serializable dict representation of DefectEntry

bulk_structure
charge
copy()[source]

Convenience method to get a copy of the DefectEntry.

Returns

A copy of the DefectEntry.

defect_concentration(chemical_potentials, temperature=300, fermi_level=0.0)[source]

Get the defect concentration for a temperature and Fermi level. :param temperature: the temperature in K :param fermi_level: the fermi level in eV (with respect to the VBM)

Returns

defects concentration in cm^-3

energy

Returns the corrected energy of the entry

formation_energy(chemical_potentials=None, fermi_level=0)[source]

Computes the formation energy for a defect taking into account a given chemical potential and fermi_level

classmethod from_dict(d)[source]

Reconstitute a DefectEntry object from a dict representation created using as_dict().

Args:

d (dict): dict representation of DefectEntry.

Returns:

DefectEntry object

multiplicity
name

Returms the defect name

site
class Interstitial(structure, defect_site, charge=0.0, site_name='', multiplicity=None)[source]

Subclass of Defect to capture essential information for a single Interstitial defect structure.

Initializes an interstial defect. User must specify multiplity. Default is 1 :param structure: Pymatgen Structure without any defects :param defect_site: the site for the interstitial :type defect_site: Site :param charge: (int or float) defect charge

default is zero, meaning no change to NELECT after defect is created in the structure (assuming use_structure_charge=True in vasp input set)

Parameters
• site_name

allows user to give a unique name to defect, since Wyckoff symbol/multiplicity is sometimes insufficient to categorize the defect type.

default is no name beyond multiplicity.

• multiplicity (int) –

multiplicity of defect within the supercell can be supplied by user. if not specified, then space group symmetry is used to generator interstitial sublattice

NOTE: multiplicity generation will not work for interstitial complexes, where multiplicity may depend on additional factors (ex. orientation etc.) If defect is not a complex, then this process will yield the correct multiplicity, provided that the defect does not undergo significant relaxation.

defect_composition

Returns the defect composition as a Composition object

generate_defect_structure(supercell=(1, 1, 1))[source]

Returns Defective Interstitial structure, decorated with charge :param supercell: supercell integer, vector, or scaling matrix :type supercell: int, [3x1], or [[]] (3x3)

multiplicity

Returns the multiplicity of a defect site within the structure (needed for concentration analysis)

name

Returns a name for this defect

class Substitution(structure, defect_site, charge=0.0)[source]

Subclass of Defect to capture essential information for a single Substitution defect structure.

Initializes an abstract defect

Parameters
• structure – Pymatgen Structure without any defects

• defect_site (Site) – site for defect within structure must have same lattice as structure

• charge – (int or float) defect charge default is zero, meaning no change to NELECT after defect is created in the structure (assuming use_structure_charge=True in vasp input set)

defect_composition

Returns the defect composition as a Composition object

generate_defect_structure(supercell=(1, 1, 1))[source]

Returns Defective Substitution structure, decorated with charge :param supercell: supercell integer, vector, or scaling matrix :type supercell: int, [3x1], or [[]] (3x3)

multiplicity

Returns the multiplicity of a defect site within the structure (needed for concentration analysis)

name

Returns a name for this defect

class Vacancy(structure, defect_site, charge=0.0)[source]

Subclass of Defect to capture essential information for a single Vacancy defect structure.

Initializes an abstract defect

Parameters
• structure – Pymatgen Structure without any defects

• defect_site (Site) – site for defect within structure must have same lattice as structure

• charge – (int or float) defect charge default is zero, meaning no change to NELECT after defect is created in the structure (assuming use_structure_charge=True in vasp input set)

defect_composition

Returns the defect composition as a Composition object

generate_defect_structure(supercell=(1, 1, 1))[source]

Returns Defective Vacancy structure, decorated with charge :param supercell: supercell integer, vector, or scaling matrix :type supercell: int, [3x1], or [[]] (3x3)

multiplicity

Returns the multiplicity of a defect site within the structure (needed for concentration analysis)

name

Returns a name for this defect

create_saturated_interstitial_structure(interstitial_def, dist_tol=0.1)[source]

this takes a Interstitial defect object and generates the sublattice for it based on the structure’s space group. Useful for understanding multiplicity of an interstitial defect in thermodynamic analysis.

NOTE: if large relaxation happens to interstitial or

defect involves a complex then there maybe additional degrees of freedom that need to be considered for the multiplicity.

Parameters

dist_tol – changing distance tolerance of saturated structure, allowing for possibly overlapping sites but ensuring space group is maintained

Returns

Structure object decorated with interstitial site equivalents