doped.utils package

Subpackages

Submodules

doped.utils.parsing module

Helper functions for parsing VASP supercell defect calculations.

doped.utils.parsing.find_archived_fname(fname, raise_error=True)[source]

Find a suitable filename, taking account of possible use of compression software.

doped.utils.parsing.get_defect_site_idxs_and_unrelaxed_structure(bulk, defect, defect_type, composition_diff, unique_tolerance=1)[source]

Get the defect site and unrelaxed structure, where “unrelaxed structure” corresponds to the pristine defect supercell structure for vacancies/substitutions, and the pristine bulk structure with the _final_ relaxed interstitial site for interstitials.

Initially contributed by Dr. Alex Ganose (@ Imperial Chemistry) and refactored for extrinsic species and code efficiency/robustness improvements.

Returns:

index of the site in the bulk structure that corresponds

to the defect site in the defect structure

defect_site_idx: index of the defect site in the defect structure unrelaxed_defect_structure: pristine defect supercell structure for

vacancies/substitutions (i.e. pristine bulk with unrelaxed vacancy/ substitution), or the pristine bulk structure with the _final_ relaxed interstitial site for interstitials.

Return type:

bulk_site_idx

doped.utils.parsing.get_defect_type_and_composition_diff(bulk, defect)[source]

Get the difference in composition between a bulk structure and a defect structure.

Contributed by Dr. Alex Ganose (@ Imperial Chemistry) and refactored for extrinsic species and code efficiency/robustness improvements.

doped.utils.parsing.get_locpot(locpot_path)[source]

Read the LOCPOT(.gz) file as a pymatgen Locpot object.

doped.utils.parsing.get_outcar(outcar_path)[source]

Read the OUTCAR(.gz) file as a pymatgen Outcar object.

doped.utils.parsing.get_site_mapping_indices(structure_a: Structure, structure_b: Structure, threshold=2.0)[source]

Reset the position of a partially relaxed structure to its unrelaxed positions.

The template structure may have a different species ordering to the input_structure.

doped.utils.parsing.get_vasprun(vasprun_path, **kwargs)[source]

Read the vasprun.xml(.gz) file as a pymatgen Vasprun object.

doped.utils.parsing.reorder_s1_like_s2(s1_structure: Structure, s2_structure: Structure, threshold=5.0)[source]

Reorder the atoms of a (relaxed) structure, s1, to match the ordering of the atoms in s2_structure.

s1/s2 structures may have a different species orderings.

Previously used to ensure correct site matching when pulling site potentials for the eFNV Kumagai correction, though no longer used for this purpose. If threshold is set to a low value, it will raise a warning if there is a large site displacement detected.

doped.utils.wyckoff module

Code to analyse the Wyckoff positions of defects.

The database for Wyckoff analysis (wyckpos.dat) was obtained from code written by JaeHwan Shim @schinavro (ORCID: 0000-0001-7575-4788)(https://gitlab.com/ase/ase/-/merge_requests/1035) based on the tabulated datasets in https://github.com/xtalopt/randSpg (also found at https://github.com/spglib/spglib/blob/develop/database/Wyckoff.csv).

doped.utils.wyckoff.get_BCS_conventional_structure(structure, pbar=None, return_wyckoff_dict=False)[source]

Get the conventional crystal structure of the input structure, according to the Bilbao Crystallographic Server (BCS) definition. Also returns the transformation matrix from the spglib (SpaceGroupAnalyzer) conventional structure definition to the BCS definition.

Parameters:
  • structure (Structure) – pymatgen Structure object for this to get the corresponding BCS conventional crystal structure

  • pbar (ProgressBar) – tqdm progress bar object, to update progress.

  • return_wyckoff_dict (bool) – whether to return the Wyckoff label dict ({Wyckoff label: coordinates})

number.

Returns:

pymatgen Structure object and spglib -> BCS conv cell transformation matrix.

doped.utils.wyckoff.get_conv_cell_site(defect_entry)[source]

Gets an equivalent site of the defect entry in the conventional structure of the host material. If the conventional_structure attribute is not defined for defect_entry, then it is generated using SpaceGroupAnalyzer and then reoriented to match the Bilbao Crystallographic Server’s conventional structure definition.

Parameters:

defect_entry – DefectEntry object.

doped.utils.wyckoff.get_primitive_structure(sga, ignored_species: list | None = None)[source]

Get a consistent/deterministic primitive structure from a SpacegroupAnalyzer object.

For some materials (e.g. zinc blende), there are multiple equivalent primitive cells, so for reproducibility and in line with most structure conventions/definitions, take the one with the lowest summed norm of the fractional coordinates of the sites (i.e. favour Cd (0,0,0) and Te (0.25,0.25,0.25) over Cd (0,0,0) and Te (0.75,0.75,0.75) for F-43m CdTe).

If ignored_species is set, then the sorting function used to determine the ideal primitive structure will ignore sites with species in ignored_species.

doped.utils.wyckoff.get_spglib_conv_structure(sga)[source]

Get a consistent/deterministic conventional structure from a SpacegroupAnalyzer object. Also returns the corresponding SpacegroupAnalyzer (for getting Wyckoff symbols corresponding to this conventional structure definition).

For some materials (e.g. zinc blende), there are multiple equivalent primitive/conventional cells, so for reproducibility and in line with most structure conventions/definitions, take the one with the lowest summed norm of the fractional coordinates of the sites (i.e. favour Cd (0,0,0) and Te (0.25,0.25,0.25) over Cd (0,0,0) and Te (0.75,0.75,0.75) for F-43m CdTe; SGN 216).

doped.utils.wyckoff.get_wyckoff(frac_coords, struct, symm_ops: list | None = None, equiv_sites=False, symprec=0.01)[source]

Get the Wyckoff label of the input fractional coordinates in the input structure. If the symmetry operations of the structure have already been computed, these can be input as a list to speed up the calculation.

Parameters:
  • frac_coords – Fractional coordinates of the site to get the Wyckoff label of.

  • struct – pymatgen Structure object for which frac_coords corresponds to.

  • symm_ops – List of pymatgen SymmOps of the structure. If None (default), will recompute these from the input struct.

  • equiv_sites – If True, also returns a list of equivalent sites in struct.

  • symprec – Symmetry precision for SpacegroupAnalyzer.

doped.utils.wyckoff.get_wyckoff_dict_from_sgn(sgn)[source]

Get dictionary of {Wyckoff label: coordinates} for a given space group number.

doped.utils.wyckoff.get_wyckoff_label_and_equiv_coord_list(defect_entry=None, conv_cell_site=None, sgn=None, wyckoff_dict=None)[source]

Return the Wyckoff label and list of equivalent fractional coordinates within the conventional cell for the input defect_entry or conv_cell_site (whichever is provided, defaults to defect_entry if both), given a dictionary of Wyckoff labels and coordinates (wyckoff_dict).

If wyckoff_dict is not provided, it is generated from the spacegroup number (sgn) using get_wyckoff_dict_from_sgn(sgn). If sgn is not provided, it is obtained from the bulk structure of the defect_entry if provided.

doped.utils.wyckoff.swap_axes(structure, axes)[source]

Swap axes of the given structure.

The new order of the axes is given by the axes parameter. For example, axes=(2, 1, 0) will swap the first and third axes.

Module contents

Submodule for utility functions in doped.