doped.vasp module

Code to generate VASP defect calculation input files.

class doped.vasp.DefectDictSet(structure: Structure, charge_state: int = 0, user_incar_settings: dict | None = None, user_kpoints_settings: dict | Kpoints | None = None, user_potcar_functional: str = 'PBE', user_potcar_settings: dict | None = None, poscar_comment: str | None = None, **kwargs)[source]

Bases: DopedDictSet

Extension to pymatgen VaspInputSet object for VASP defect calculations.

Parameters:
  • structure (Structure) – pymatgen Structure object of the defect supercell

  • charge_state (int) – Charge of the defect structure

  • user_incar_settings (dict) – Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at output INCAR s or the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder, to see what the default INCAR settings are. Note that any flags that aren’t numbers or True/False need to be input as strings with quotation marks (e.g. {"ALGO": "All"}). (default: None)

  • user_kpoints_settings (dict or Kpoints) – Dictionary of user KPOINTS settings (in pymatgen VaspInputSet format) e.g., {"reciprocal_density": 123}, or a Kpoints object. Default is Gamma-centred, reciprocal_density = 100 [Å⁻³].

  • user_potcar_functional (str) – POTCAR functional to use. Default is “PBE” and if this fails, tries “PBE_52”, then “PBE_54”.

  • user_potcar_settings (dict) – Override the default POTCARs, e.g. {"Li": "Li_sv"}. See doped/VASP_sets/PotcarSet.yaml for the default POTCAR set.

  • poscar_comment (str) – Comment line to use for POSCAR files. Default is defect name, fractional coordinates of initial site and charge state.

  • **kwargs – Additional kwargs to pass to VaspInputSet.

property incar

Returns the Incar object generated from DopedDictSet, with NELECT and NUPDOWN set accordingly.

See https://doped.readthedocs.io/en/latest/Tips.html#spin-polarisation for discussion about appropriate NUPDOWN/MAGMOM settings.

property nelect

Number of electrons (NELECT) for the given structure and charge state.

This is equal to the sum of valence electrons (ZVAL) of the POTCARs for each atom in the structure (supercell), minus the charge state.

write_input(output_path: str, unperturbed_poscar: bool = True, make_dir_if_not_present: bool = True, include_cif: bool = False, potcar_spec: bool = False, zip_output: bool = False, snb: bool = False)[source]

Writes out all input to a directory. Refactored slightly from pymatgen VaspInputSet.write_input() to allow checking of user POTCAR setup.

Parameters:
  • output_path (str) – Directory to output the VASP input files.

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCAR to the generated folder as well. (default: True)

  • make_dir_if_not_present (bool) – Set to True if you want the directory (and the whole path) to be created if it is not present. (default: True)

  • include_cif (bool) – Whether to write a CIF file in the output directory for easier opening by VESTA. (default: False)

  • potcar_spec (bool) – Instead of writing the POTCAR, write a “POTCAR.spec”. This is intended to help sharing an input set with people who might not have a license to specific Potcar files. Given a “POTCAR.spec”, the specific POTCAR file can be re-generated using pymatgen with the “generate_potcar” function in the pymatgen CLI. (default: False)

  • zip_output (bool) – Whether to zip each VASP input file written to the output directory. (default: False)

  • snb (bool) – If input structures are from ShakeNBreak (so POSCARs aren’t ‘unperturbed’). (default: False)

class doped.vasp.DefectRelaxSet(defect_entry: DefectEntry | Structure, charge_state: int | None = None, soc: bool | None = None, user_incar_settings: dict | None = None, user_kpoints_settings: dict | Kpoints | None = None, user_potcar_functional: str = 'PBE', user_potcar_settings: dict | None = None, **kwargs)[source]

Bases: MSONable

An object for generating input files for VASP defect relaxation calculations from pymatgen DefectEntry (recommended) or Structure objects.

The supercell structure and charge state are taken from the DefectEntry attributes, or if a Structure is provided, then from the defect_supercell and charge_state input parameters.

Creates attributes:

  • DefectRelaxSet.vasp_gam:

    DefectDictSet for Gamma-point only relaxation. Usually not needed if ShakeNBreak structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and no vasp_std calculations with multiple k-points are required (determined from kpoints settings).

  • DefectRelaxSet.vasp_nkred_std:

    DefectDictSet for relaxation with a kpoint mesh and using NKRED. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Gamma k-point sampling is required.

  • DefectRelaxSet.vasp_std:

    DefectDictSet for relaxation with a kpoint mesh, not using NKRED. Not generated if only Gamma kpoint sampling is required.

  • DefectRelaxSet.vasp_ncl:

    DefectDictSet for singlepoint (static) energy calculation with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

where DefectDictSet is an extension of pymatgen’s VaspInputSet class for defect calculations, with incar, poscar, kpoints and potcar attributes for the corresponding VASP defect calculations (see docstring). Also creates the corresponding bulk_vasp_... attributes for singlepoint (static) energy calculations of the bulk (pristine, defect-free) supercell. This needs to be calculated once with the same settings as the defect calculations, for the later calculation of defect formation energies.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase (chemical potential) calculations.

Parameters:
  • defect_entry (DefectEntry, Structure) – doped/pymatgen DefectEntry or Structure (defect supercell) for which to generate DefectDictSets for.

  • charge_state (int) – Charge state of the defect. Overrides DefectEntry.charge_state if DefectEntry is input.

  • soc (bool) – Whether to generate vasp_ncl DefectDictSet attribute for spin-orbit coupling singlepoint (static) energy calculations. If not set, then by default is set to True if the max atomic number (Z) in the structure is >= 31 (i.e. further down the periodic table than Zn), otherwise False.

  • user_incar_settings (dict) – Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at output INCARs or the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder, to see what the default INCAR settings are. Note that any flags that aren’t numbers or True/False need to be input as strings with quotation marks (e.g. {"ALGO": "All"}). (default: None)

  • user_kpoints_settings (dict or Kpoints) – Dictionary of user KPOINTS settings (in pymatgen VaspInputSet format) e.g. {“reciprocal_density”: 123}, or a Kpoints object, to use for the vasp_std, vasp_nkred_std and vasp_ncl DefectDictSets (Γ-only for vasp_gam). Default is Gamma-centred, reciprocal_density = 100 [Å⁻³].

  • user_potcar_functional (str) – POTCAR functional to use. Default is “PBE” and if this fails, tries “PBE_52”, then “PBE_54”.

  • user_potcar_settings (dict) – Override the default POTCARs, e.g. {“Li”: “Li_sv”}. See doped/VASP_sets/PotcarSet.yaml for the default POTCAR set.

  • **kwargs – Additional kwargs to pass to DefectDictSet.

vasp_gam

DefectDictSet for Gamma-point only relaxation. Usually not needed if ShakeNBreak structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and no vasp_std calculations with multiple k-points are required (determined from kpoints settings).

Type:

DefectDictSet

vasp_nkred_std

DefectDictSet for relaxation with a non-Γ-only kpoint mesh, using NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Gamma kpoint sampling is required.

Type:

DefectDictSet

vasp_std

DefectDictSet for relaxation with a non-Γ-only kpoint mesh, not using NKRED. Not generated if only Gamma kpoint sampling is required.

Type:

DefectDictSet

vasp_ncl

DefectDictSet for singlepoint (static) energy calculation with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

Type:

DefectDictSet

defect_supercell

Supercell structure for defect calculations, taken from defect_entry.defect_supercell (if defined), otherwise from defect_entry.sc_entry.structure if inputting a DefectEntry object, or the input structure if inputting a Structure object.

Type:

Structure

bulk_supercell

Supercell structure of the bulk (pristine, defect-free) material, taken from defect_entry.bulk_supercell (if defined), otherwise from defect_entry.bulk_entry.structure if inputting a DefectEntry object, or None if inputting a Structure object.

Type:

Structure

poscar_comment

Comment to write at the top of the POSCAR files. Default is the defect entry name, defect frac coords and charge state (if inputting a DefectEntry object), or the formula of the input structure and charge state (if inputting a Structure object), for defects. For the bulk supercell, it’s “{formula} - Bulk”.

Type:

str

bulk_vasp_gam

DefectDictSet for a bulk Γ-point-only singlepoint (static) supercell calculation. Often not used, as the bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which may be with vasp_std or vasp_ncl.

Type:

DefectDictSet

bulk_vasp_nkred_std

DefectDictSet for a singlepoint (static) bulk vasp_std supercell calculation (i.e. with a non-Γ-only kpoint mesh) and NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Gamma kpoint sampling is required.

Type:

DefectDictSet

bulk_vasp_std

DefectDictSet for a singlepoint (static) bulk vasp_std supercell calculation with a non-Γ-only kpoint mesh, not using NKRED. Not generated if only Gamma kpoint sampling is required.

Type:

DefectDictSet

bulk_vasp_ncl

DefectDictSet for singlepoint (static) energy calculation of the bulk supercell with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

Type:

DefectDictSet

Input parameters are also set as attributes.
property bulk_vasp_gam: DefectDictSet | None

Returns a DefectDictSet object for a VASP bulk Γ-point-only (vasp_gam) singlepoint (static) supercell calculation. Often not used, as the bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which is vasp_std if we have a non-Γ-only final k-point mesh, or vasp_ncl if SOC effects are being included. If the final converged k-point mesh is Γ-only, then bulk_vasp_gam should be used to calculate the singlepoint (static) bulk supercell reference energy. Can also sometimes be useful for the purpose of calculating defect formation energies at early stages of the typical vasp_gam -> vasp_nkred_std (if hybrid & non-Γ-only k-points) -> vasp_std (if non-Γ-only k-points) -> vasp_ncl (if SOC included) workflow, to obtain rough formation energy estimates and flag any potential issues with defect calculations early on.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property bulk_vasp_ncl: DefectDictSet | None

Returns a DefectDictSet object for VASP bulk supercell singlepoint calculations with spin-orbit coupling (SOC) included (LSORBIT = True), using vasp_ncl. If DefectRelaxSet.soc is False, then this returns None and a warning. If the soc parameter is not set when initializing DefectRelaxSet, then this is set to True for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn), otherwise False.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property bulk_vasp_nkred_std: DefectDictSet | None

Returns a DefectDictSet object for a singlepoint (static) bulk vasp_std supercell calculation (i.e. with a non-Γ-only kpoint mesh) and NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. By default, sets NKRED(X,Y,Z) to 2 or 3 in the directions for which the k-point grid is divisible by this factor. Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case (bulk_)vasp_gam should be used) or for GGA calculations (if LHFCALC is set to False in user_incar_settings, in which case (bulk_)vasp_std should be used).

The bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which is vasp_std if we have a non-Γ-only final k-point mesh, vasp_ncl if SOC effects are being included (in which case bulk_vasp_ncl should be used for the singlepoint bulk supercell reference calculation), or vasp_gam if the final converged k-point mesh is Γ-only (in which case bulk_vasp_gam should be used for the singlepoint bulk supercell reference calculation). Can also sometimes be useful for the purpose of calculating defect formation energies at midway stages of the typical vasp_gam -> vasp_nkred_std (if hybrid & non-Γ-only k-points) -> vasp_std (if non-Γ-only k-points) -> vasp_ncl (if SOC included) workflow, to obtain rough formation energy estimates and flag any potential issues with defect calculations early on.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property bulk_vasp_std: DefectDictSet | None

Returns a DefectDictSet object for a singlepoint (static) bulk vasp_std supercell calculation. Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case (bulk_)vasp_gam should be used).

The bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which is vasp_std if we have a non-Γ-only final k-point mesh, vasp_ncl if SOC effects are being included (in which case bulk_vasp_ncl should be used for the singlepoint bulk supercell reference calculation), or vasp_gam if the final converged k-point mesh is Γ-only (in which case bulk_vasp_gam should be used for the singlepoint bulk supercell reference calculation). Can also sometimes be useful for the purpose of calculating defect formation energies at midway stages of the typical vasp_gam -> vasp_nkred_std (if hybrid & non-Γ-only k-points) -> vasp_std (if non-Γ-only k-points) -> vasp_ncl (if SOC included) workflow, to obtain rough formation energy estimates and flag any potential issues with defect calculations early on.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property vasp_gam: DefectDictSet

Returns a DefectDictSet object for a VASP Γ-point-only (vasp_gam) defect supercell relaxation. Typically not needed if ShakeNBreak structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and no vasp_std calculations with multiple k-points are required (determined from kpoints settings).

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property vasp_ncl: DefectDictSet | None

Returns a DefectDictSet object for a VASP defect supercell singlepoint calculation with spin-orbit coupling (SOC) included (LSORBIT = True), using vasp_ncl. If DefectRelaxSet.soc is False, then this returns None and a warning. If the soc parameter is not set when initializing DefectRelaxSet, then this is set to True for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn), otherwise False.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property vasp_nkred_std: DefectDictSet | None

Returns a DefectDictSet object for a VASP defect supercell relaxation using vasp_std (i.e. with a non-Γ-only kpoint mesh) and NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of hybrid DFT calculations, following the doped recommended defect calculation workflow (see docs). By default, sets NKRED(X,Y,Z) to 2 or 3 in the directions for which the k-point grid is divisible by this factor. Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case vasp_gam should be used) or for GGA calculations (if LHFCALC is set to False in user_incar_settings, in which case vasp_std should be used).

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

property vasp_std: DefectDictSet | None

Returns a DefectDictSet object for a VASP defect supercell relaxation using vasp_std (i.e. with a non-Γ-only kpoint mesh). Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case vasp_gam should be used).

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

write_all(defect_dir: str | None = None, unperturbed_poscar: bool = False, vasp_gam: bool = False, bulk: bool | str = False, **kwargs)[source]

Write all VASP input files to subfolders in the defect_dir folder.

The following subfolders are generated:

  • vasp_nkred_std:

    Defect relaxation with a kpoint mesh and using NKRED. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Γ-point sampling required.

  • vasp_std:

    Defect relaxation with a kpoint mesh, not using NKRED. Not generated if only Γ-point sampling required.

  • vasp_ncl:

    Singlepoint (static) energy calculation with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

If vasp_gam=True (not recommended) or self.vasp_std = None (i.e. Γ-only k-point sampling converged for the kpoints settings used), then also outputs:

  • vasp_gam:

    Γ-point only defect relaxation. Usually not needed if ShakeNBreak structure searching has been performed (recommended).

By default, does not generate a vasp_gam folder unless self.vasp_std is None (i.e. only Γ-point sampling required for this system), as vasp_gam calculations should be performed using ShakeNBreak for defect structure-searching and initial relaxations. If vasp_gam files are desired, set vasp_gam=True.

By default, POSCAR files are not generated for the vasp_(nkred_)std (and vasp_ncl if self.soc is True) folders, as these should be taken from ShakeNBreak calculations (via snb-groundstate -d vasp_nkred_std) or, if not following the recommended structure-searching workflow, from the CONTCARs of vasp_gam calculations. If including SOC effects (self.soc = True), then the vasp_std CONTCARs should be used as the vasp_ncl POSCARs. If unperturbed POSCAR files are desired for the vasp_(nkred_)std (and vasp_ncl) folders, set unperturbed_poscar=True.

Input files for the singlepoint (static) bulk supercell reference calculation are also written to “{formula}_bulk/{subfolder}” if bulk is True (False by default), where subfolder corresponds to the final (highest accuracy) VASP calculation in the workflow (i.e. vasp_ncl if self.soc=True, otherwise vasp_std or vasp_gam if only Γ-point reciprocal space sampling is required). If bulk = "all", then the input files for all VASP calculations in the workflow are written to the bulk supercell folder.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

The DefectEntry object is also written to a json file in defect_dir to aid calculation provenance.

Parameters:
  • defect_dir (str) – Folder in which to create the VASP defect calculation inputs. Default is to use the DefectEntry name (e.g. “Y_i_C4v_O1.92_+2” etc.), from self.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (using get_defect_name_from_entry()). Output folder structure is <defect_dir>/<subfolder> where subfolder is the name of the corresponding VASP program to run (e.g. vasp_std).

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCARs to the generated folders as well. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)) first with NKRED if using hybrid DFT, then without, then use the vasp_std CONTCARs as the input structures for the final vasp_ncl singlepoint calculations. (default: False)

  • vasp_gam (bool) – If True, write the vasp_gam input files, with unperturbed defect POSCAR. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp_std relaxations from the SnB ground-state structures. (default: False)

  • bulk (bool, str) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”, where subfolder corresponds to the final (highest accuracy) VASP calculation in the workflow (i.e. vasp_ncl if self.soc=True, otherwise vasp_std or vasp_gam if only Γ-point reciprocal space sampling is required). If bulk = "all" then the input files for all VASP calculations in the workflow (vasp_gam, vasp_nkred_std, vasp_std, vasp_ncl (if applicable)) are written to the bulk supercell folder. (Default: False)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

write_gam(defect_dir: str | None = None, subfolder: str | None = 'vasp_gam', unperturbed_poscar: bool = True, bulk: bool = False, **kwargs)[source]

Write the input files for VASP Γ-point-only (vasp_gam) defect supercell relaxation. Typically not recommended for use, as the recommended workflow is to perform vasp_gam calculations using ShakeNBreak for defect structure-searching and initial relaxations, but should be used if the final, converged k-point mesh is Γ-point- only. If bulk is True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

The DefectEntry object is also written to a json file in defect_dir to aid calculation provenance.

Parameters:
  • defect_dir (str) – Folder in which to create the VASP defect calculation inputs. Default is to use the DefectEntry name (e.g. “Y_i_C4v_O1.92_+2” etc.), from self.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (using get_defect_name_from_entry()).

  • subfolder (str) – Output folder structure is <defect_dir>/<subfolder> where subfolder = ‘vasp_gam’ by default. Setting subfolder to None will write the vasp_gam input files directly to the <defect_dir> folder, with no subfolders created.

  • unperturbed_poscar (bool) – If True (default), write the unperturbed defect POSCAR to the generated folder as well. Typically not recommended for use, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)). (default: True)

  • bulk (bool) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”. (Default: False)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

write_ncl(defect_dir: str | None = None, subfolder: str | None = 'vasp_ncl', unperturbed_poscar: bool = False, bulk: bool = False, **kwargs)[source]

Write the input files for VASP defect supercell singlepoint calculations with spin-orbit coupling (SOC) included (LSORBIT = True), using vasp_ncl. By default, does not generate POSCAR (input structure) files, as these should be taken from the CONTCARs of vasp_std relaxations (originally from ShakeNBreak structure- searching relaxations), or directly from ShakeNBreak calculations (via snb-groundstate -d vasp_ncl) if only Γ-point reciprocal space sampling is required. If unperturbed POSCAR files are desired, set unperturbed_poscar=True.

If DefectRelaxSet.soc is False, then this returns None and a warning. If the soc parameter is not set when initializing DefectRelaxSet, then it is set to True for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn), otherwise False. If bulk is True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

The DefectEntry object is also written to a json file in defect_dir to aid calculation provenance.

Parameters:
  • defect_dir (str) – Folder in which to create the VASP defect calculation inputs. Default is to use the DefectEntry name (e.g. “Y_i_C4v_O1.92_+2” etc.), from self.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (using get_defect_name_from_entry()).

  • subfolder (str) – Output folder structure is <defect_dir>/<subfolder> where subfolder = ‘vasp_ncl’ by default. Setting subfolder to None will write the vasp_ncl input files directly to the <defect_dir> folder, with no subfolders created.

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCAR to the generated folder as well. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)), first with NKRED if using hybrid DFT, then without, then use the vasp_std CONTCARs as the input structures for the final vasp_ncl singlepoint calculations. (default: False)

  • bulk (bool) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”. (Default: False)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

write_nkred_std(defect_dir: str | None = None, subfolder: str | None = 'vasp_nkred_std', unperturbed_poscar: bool = False, bulk: bool = False, **kwargs)[source]

Write the input files for defect calculations using vasp_std (i.e. with a non-Γ-only kpoint mesh) and NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of hybrid DFT calculations, following the doped recommended defect calculation workflow (see docs). By default, sets NKRED(X,Y,Z) to 2 or 3 in the directions for which the k-point grid is divisible by this factor.

By default, does not generate POSCAR (input structure) files, as these should be taken from the CONTCARs of ShakeNBreak calculations (via snb-groundstate -d vasp_nkred_std) or, if not following the recommended structure-searching workflow, from the CONTCARs of vasp_gam calculations. If unperturbed POSCAR files are desired, set unperturbed_poscar=True. If bulk is True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”.

Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case vasp_gam should be used) or for GGA calculations (if LHFCALC is set to False in user_incar_settings, in which case vasp_std should be used).

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

The DefectEntry object is also written to a json file in defect_dir to aid calculation provenance.

Parameters:
  • defect_dir (str) – Folder in which to create the VASP defect calculation inputs. Default is to use the DefectEntry name (e.g. “Y_i_C4v_O1.92_+2” etc.), from self.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (using get_defect_name_from_entry()).

  • subfolder (str) – Output folder structure is <defect_dir>/<subfolder> where subfolder = ‘vasp_nkred_std’ by default. Setting subfolder to None will write the vasp_nkred_std input files directly to the <defect_dir> folder, with no subfolders created.

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCAR to the generated folder as well. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)). (default: False)

  • bulk (bool) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”. (Default: False)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

write_std(defect_dir: str | None = None, subfolder: str | None = 'vasp_std', unperturbed_poscar: bool = False, bulk: bool = False, **kwargs)[source]

Write the input files for a VASP defect supercell calculation using vasp_std (i.e. with a non-Γ-only kpoint mesh). By default, does not generate POSCAR (input structure) files, as these should be taken from the CONTCARs of vasp_std relaxations using NKRED(X,Y,Z) (originally from ShakeNBreak relaxations) if using.

hybrid DFT, or from ShakeNBreak calculations (via snb-groundstate -d vasp_std) if using GGA, or, if not following the recommended structure-searching workflow, from the CONTCARs of vasp_gam calculations. If unperturbed POSCAR files are desired, set unperturbed_poscar=True. If bulk is True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”.

Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case vasp_gam should be used).

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

The DefectEntry object is also written to a json file in defect_dir to aid calculation provenance.

Parameters:
  • defect_dir (str) – Folder in which to create the VASP defect calculation inputs. Default is to use the DefectEntry name (e.g. “Y_i_C4v_O1.92_+2” etc.), from self.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (using get_defect_name_from_entry()).

  • subfolder (str) – Output folder structure is <defect_dir>/<subfolder> where subfolder = ‘vasp_std’ by default. Setting subfolder to None will write the vasp_std input files directly to the <defect_dir> folder, with no subfolders created.

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCAR to the generated folder as well. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)), first with NKRED if using hybrid DFT, then without NKRED. (default: False)

  • bulk (bool) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”. (Default: False)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

class doped.vasp.DefectsSet(defect_entries: DefectsGenerator | dict[str, DefectEntry] | list[DefectEntry] | DefectEntry, soc: bool | None = None, user_incar_settings: dict | None = None, user_kpoints_settings: dict | Kpoints | None = None, user_potcar_functional: str = 'PBE', user_potcar_settings: dict | None = None, **kwargs)[source]

Bases: MSONable

An object for generating input files for VASP defect calculations from doped/pymatgen DefectEntry objects.

Creates a dictionary of: {defect_species: DefectRelaxSet}.

DefectRelaxSet has the attributes:

  • DefectRelaxSet.vasp_gam:

    DefectDictSet for Gamma-point only relaxation. Usually not needed if ShakeNBreak structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and no vasp_std calculations with multiple k-points are required (determined from kpoints settings).

  • DefectRelaxSet.vasp_nkred_std:

    DefectDictSet for relaxation with a kpoint mesh and using NKRED. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Gamma kpoint sampling is required.

  • DefectRelaxSet.vasp_std:

    DefectDictSet for relaxation with a kpoint mesh, not using NKRED. Not generated if only Gamma kpoint sampling is required.

  • DefectRelaxSet.vasp_ncl:

    DefectDictSet for singlepoint (static) energy calculation with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

where DefectDictSet is an extension of pymatgen’s VaspInputSet class for defect calculations, with incar, poscar, kpoints and potcar attributes for the corresponding VASP defect calculations (see docstring). Also creates the corresponding bulk_vasp_... attributes for singlepoint (static) energy calculations of the bulk (pristine, defect-free) supercell. This needs to be calculated once with the same settings as the final defect calculations, for the later calculation of defect formation energies.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR settings, and PotcarSet.yaml for the default POTCAR settings.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase (chemical potential) calculations.

Parameters:
  • defect_entries (DefectsGenerator, dict/list of DefectEntrys, or DefectEntry) – Either a DefectsGenerator object, or a dictionary/list of DefectEntrys, or a single DefectEntry object, for which to generate VASP input files. If a DefectsGenerator object or a dictionary (-> {defect_species: DefectEntry}), the defect folder names will be set equal to defect_species. If a list or single DefectEntry object is provided, the defect folder names will be set equal to DefectEntry.name if the name attribute is set, otherwise generated according to the doped convention (see doped.generation). Defect charge states are taken from DefectEntry.charge_state.

  • soc (bool) – Whether to generate vasp_ncl DefectDictSet attribute for spin-orbit coupling singlepoint (static) energy calculations. If not set, then by default is set to True if the max atomic number (Z) in the structure is >= 31 (i.e. further down the periodic table than Zn).

  • user_incar_settings (dict) – Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at output INCARs or the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder, to see what the default INCAR settings are. Note that any flags that aren’t numbers or True/False need to be input as strings with quotation marks (e.g. {"ALGO": "All"}). (default: None)

  • user_kpoints_settings (dict or Kpoints) – Dictionary of user KPOINTS settings (in pymatgen VaspInputSet format) e.g. {“reciprocal_density”: 123}, or a Kpoints object, to use for the vasp_std, vasp_nkred_std and vasp_ncl DefectVaspInputSets (Γ-only for vasp_gam). Default is Gamma-centred, reciprocal_density = 100 [Å⁻³].

  • user_potcar_functional (str) – POTCAR functional to use. Default is “PBE” and if this fails, tries “PBE_52”, then “PBE_54”.

  • user_potcar_settings (dict) – Override the default POTCARs, e.g. {“Li”: “Li_sv”}. See doped/VASP_setsPotcarSet.yaml for the default POTCAR set.

  • **kwargs – Additional kwargs to pass to each DefectRelaxSet().

defect_sets

Dictionary of {defect_species: DefectRelaxSet}.

Type:

Dict

defect_entries

Dictionary of {defect_species: DefectEntry} for the input defect species, for which to generate VASP input files.

Type:

Dict

bulk_vasp_gam

DefectDictSet for a bulk Γ-point-only singlepoint (static) supercell calculation. Often not used, as the bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which may be with vasp_std or vasp_ncl.

Type:

DefectDictSet

bulk_vasp_nkred_std

DefectDictSet for a singlepoint (static) bulk vasp_std supercell calculation (i.e. with a non-Γ-only kpoint mesh) and NKRED(X,Y,Z) INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Gamma kpoint sampling is required.

Type:

DefectDictSet

bulk_vasp_std

DefectDictSet for a singlepoint (static) bulk vasp_std supercell calculation with a non-Γ-only kpoint mesh, not using NKRED. Not generated if only Gamma kpoint sampling is required.

Type:

DefectDictSet

bulk_vasp_ncl

DefectDictSet for singlepoint (static) energy calculation of the bulk supercell with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

Type:

DefectDictSet

json_obj

Either the DefectsGenerator object if input defect_entries is a DefectsGenerator object, otherwise the defect_entries dictionary, which will be written to file when write_files() is called, to aid calculation provenance.

Type:

Union[Dict, DefectsGenerator]

json_name

Name of the JSON file to save the json_obj to.

Type:

str

Input parameters are also set as attributes.
write_files(output_path: str = '.', unperturbed_poscar: bool = False, vasp_gam: bool = False, bulk: bool | str = True, processes: int | None = None, **kwargs)[source]

Write VASP input files to folders for all defects in self.defect_entries. Folder names are set to the key of the DefectRelaxSet in self.defect_sets (same as self.defect_entries keys, see DefectsSet docstring).

For each defect folder, the following subfolders are generated:

  • vasp_nkred_std:

    Defect relaxation with a kpoint mesh and using NKRED. Not generated for GGA calculations (if LHFCALC is set to False in user_incar_settings) or if only Γ-point sampling required.

  • vasp_std:

    Defect relaxation with a kpoint mesh, not using NKRED. Not generated if only Γ-point sampling required.

  • vasp_ncl:

    Singlepoint (static) energy calculation with SOC included. Generated if soc=True. If soc is not set, then by default is only generated for systems with a max atomic number (Z) >= 31 (i.e. further down the periodic table than Zn).

If vasp_gam=True (not recommended) or self.vasp_std = None (i.e. Γ-only k-point sampling converged for the kpoints settings used), then also outputs:

  • vasp_gam:

    Γ-point only defect relaxation. Usually not needed if ShakeNBreak structure searching has been performed (recommended).

By default, does not generate a vasp_gam folder unless DefectRelaxSet.vasp_std is None (i.e. only Γ-point sampling required for this system), as vasp_gam calculations should be performed using ShakeNBreak for defect structure-searching and initial relaxations. If vasp_gam files are desired, set vasp_gam=True.

By default, POSCAR files are not generated for the vasp_(nkred_)std (and vasp_ncl if self.soc is True) folders, as these should be taken from vasp_gam ShakeNBreak calculations (via snb-groundstate -d vasp_nkred_std), some other structure-searching approach or, if not following the recommended structure-searching workflow, from the CONTCARs of vasp_gam calculations. If including SOC effects (self.soc = True), then the vasp_std CONTCARs should be used as the vasp_ncl POSCARs. If unperturbed POSCAR files are desired for the vasp_(nkred_)std (and vasp_ncl) folders, set unperturbed_poscar=True.

Input files for the singlepoint (static) bulk supercell reference calculation are also written to “{formula}_bulk/{subfolder}” if bulk is True (default), where subfolder corresponds to the final (highest accuracy) VASP calculation in the workflow (i.e. vasp_ncl if self.soc=True, otherwise vasp_std or vasp_gam if only Γ-point reciprocal space sampling is required). If bulk = "all", then the input files for all VASP calculations (gam/std/ncl) are written to the bulk supercell folder, or if bulk = False, then no bulk folder is created.

The DefectEntry objects are also written to json files in the defect folders, as well as self.defect_entries (self.json_obj) in the top folder, to aid calculation provenance.

See the RelaxSet.yaml and DefectSet.yaml files in the doped/VASP_sets folder for the default INCAR and KPOINT settings, and PotcarSet.yaml for the default POTCAR settings. These are reasonable defaults that _roughly_ match the typical values needed for accurate defect calculations, but usually will need to be modified for your specific system, such as converged ENCUT and KPOINTS, and NCORE / KPAR matching your HPC setup.

Note that any changes to the default INCAR/POTCAR settings should be consistent with those used for all defect and competing phase ( chemical potential) calculations.

Parameters:
  • output_path (str) – Folder in which to create the VASP defect calculation folders. Default is the current directory (“.”). Output folder structure is <output_path>/<defect_species>/<subfolder> where defect_species is the key of the DefectRelaxSet in self.defect_sets (same as self.defect_entries keys, see DefectsSet docstring) and subfolder is the name of the corresponding VASP program to run (e.g. vasp_std).

  • unperturbed_poscar (bool) – If True, write the unperturbed defect POSCARs to the generated folders as well. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp(_nkred)_std relaxations from the ground-state structures (e.g. using -d vasp_nkred_std with snb-groundstate (CLI) or groundstate_folder="vasp_nkred_std" with write_groundstate_structure (Python API)) first with NKRED if using hybrid DFT, then without, then use the vasp_std CONTCARs as the input structures for the final vasp_ncl singlepoint calculations. (default: False)

  • vasp_gam (bool) – If True, write the vasp_gam input files, with unperturbed defect POSCARs. Not recommended, as the recommended workflow is to initially perform vasp_gam ground-state structure searching using ShakeNBreak (https://shakenbreak.readthedocs.io), then continue the vasp_std relaxations from the SnB ground-state structures. (default: False)

  • bulk (bool, str) – If True, the input files for a singlepoint calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”, where subfolder corresponds to the final (highest accuracy) VASP calculation in the workflow (i.e. vasp_ncl if self.soc=True, otherwise vasp_std or vasp_gam if only Γ-point reciprocal space sampling is required). If bulk = "all" then the input files for all VASP calculations in the workflow (vasp_gam, vasp_nkred_std, vasp_std, vasp_ncl (if applicable)) are written to the bulk supercell folder. (Default: False)

  • processes (int) – Number of processes to use for multiprocessing for file writing. If not specified (default), then is dynamically set to the optimal value for the number of folders to write. (Default: None)

  • **kwargs – Keyword arguments to pass to DefectDictSet.write_input().

class doped.vasp.DopedDictSet(structure: Structure, user_incar_settings: dict | None = None, user_kpoints_settings: dict | Kpoints | None = None, user_potcar_functional: str = 'PBE', user_potcar_settings: dict | None = None, auto_kpar: bool = True, poscar_comment: str | None = None, **kwargs)[source]

Bases: VaspInputSet

Modified version of pymatgen VaspInputSet, to have more robust POTCAR handling, expedited I/O (particularly for POTCAR generation, which can be slow when generating many folders), ensure POSCAR atom sorting, avoid encoding issues with KPOINTS comments etc.

Parameters:
  • structure (Structure) – pymatgen Structure object

  • user_incar_settings (dict) – Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default INCAR settings. Note that any flags that aren’t numbers or True/False need to be input as strings with quotation marks (e.g. {"ALGO": "All"}). (default: None)

  • user_kpoints_settings (dict or Kpoints) – Dictionary of user KPOINTS settings (in pymatgen VaspInputSet format) e.g., {"reciprocal_density": 123}, or a Kpoints object. Default is Gamma-only.

  • user_potcar_functional (str) – POTCAR functional to use. Default is “PBE” and if this fails, tries “PBE_52”, then “PBE_54”.

  • user_potcar_settings (dict) – Override the default POTCARs, e.g. {“Li”: “Li_sv”}. See doped/VASP_sets/PotcarSet.yaml for the default POTCAR set.

  • auto_kpar (bool) – If True, and KPAR is not set in user_incar_settings, attempts to set KPAR to a reasonable value based on the k-point grid. Specifically, sets KPAR to 2 if there are 2 or >=4 k-points in any direction, or 4 if there are at least 2 directions with 2 or >=4 k-points (otherwise remains as the default of 1). Default is True.

  • poscar_comment (str) – Comment line to use for POSCAR file. Default is structure formula.

  • **kwargs – Additional kwargs to pass to VaspInputSet.

property incar

Returns the Incar object generated from the VaspInputSet config, with a warning if KPAR > 1 and only one k-point.

property kpoints

Return kpoints object with comment.

property poscar: Poscar

Return Poscar object with comment, ensuring atom sorting.

property potcar: Potcar

Potcar object.

Redefined to intelligently handle pymatgen POTCAR issues.

class doped.vasp.DopedKpoints(comment: str = 'Default gamma', num_kpts: int = 0, style: KpointsSupportedModes = KpointsSupportedModes.Gamma, kpts: Sequence[Kpoint] = ((1, 1, 1),), kpts_shift: Vector3D = (0, 0, 0), kpts_weights: list[float] | None = None, coord_type: Literal['Reciprocal', 'Cartesian'] | None = None, labels: list[str] | None = None, tet_number: int = 0, tet_weight: float = 0, tet_connections: list[tuple] | None = None)[source]

Bases: Kpoints

Custom implementation of Kpoints to handle encoding errors that can happen on some old HPCs/Linux systems.

If an encoding error occurs upon file writing, then changes Γ to Gamma and Å to Angstrom in the KPOINTS comment.

Highly flexible constructor for Kpoints object. The flexibility comes at the cost of usability and in general, it is recommended that you use the default constructor only if you know exactly what you are doing and requires the flexibility. For most usage cases, the three automatic schemes can be constructed far more easily using the convenience static constructors (automatic, gamma_automatic, monkhorst_automatic) and it is recommended that you use those.

Parameters:
  • comment (str) – String comment for Kpoints. Defaults to “Default gamma”.

  • num_kpts – Following VASP method of defining the KPOINTS file, this parameter is the number of kpoints specified. If set to 0 (or negative), VASP automatically generates the KPOINTS.

  • style – Style for generating KPOINTS. Use one of the Kpoints.supported_modes enum types.

  • kpts (2D array) – Array of kpoints. Even when only a single specification is required, e.g. in the automatic scheme, the kpts should still be specified as a 2D array. e.g. [(20,),] or [(2, 2, 2),].

  • kpts_shift (3x1 array) – Shift for kpoints.

  • kpts_weights (list[float]) – Optional weights for explicit kpoints.

  • coord_type – In line-mode, this variable specifies whether the Kpoints were given in Cartesian or Reciprocal coordinates.

  • labels – In line-mode, this should provide a list of labels for each kpt. It is optional in explicit kpoint mode as comments for k-points.

  • tet_number – For explicit kpoints, specifies the number of tetrahedrons for the tetrahedron method.

  • tet_weight – For explicit kpoints, specifies the weight for each tetrahedron for the tetrahedron method.

  • tet_connections – For explicit kpoints, specifies the connections of the tetrahedrons for the tetrahedron method. Format is a list of tuples, [ (sym_weight, [tet_vertices]), …]

The default behavior of the constructor is for a Gamma centered, 1x1x1 KPOINTS with no shift.

doped.vasp.deep_dict_update(d: dict, u: dict) dict[source]

Recursively update nested dictionaries without overwriting existing keys.

doped.vasp.scaled_ediff(natoms: int) float[source]

Returns a scaled EDIFF value for VASP calculations, based on the number of atoms in the structure.

EDIFF is set to 2e-7 per atom (-> 1e-5 per 50 atoms), with a maximum EDIFF of 1e-4.