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:
DopedDictSetExtension to
pymatgenVaspInputSetobject forVASPdefect calculations.- Parameters:
structure (Structure) –
pymatgenStructureobject of the defect supercell.charge_state (int) – Charge of the defect (to set
NELECT– total number of electrons).user_incar_settings (dict) – Dictionary of user
INCARsettings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at outputINCARs or theRelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder, to see what the defaultINCARsettings are. Note that any flags that aren’t numbers orTrue/Falseneed to be input as strings with quotation marks (e.g.{"ALGO": "All"}). (default: None)user_kpoints_settings (dict or Kpoints) – Dictionary of user
KPOINTSsettings (inpymatgenVaspInputSetformat) e.g.,{"reciprocal_density": 123}, or aKpointsobject. Default is Gamma-centred,reciprocal_density = 100[Å⁻³].user_potcar_functional (str) –
POTCARfunctional 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"}. Seedoped/VASP_sets/PotcarSet.yamlfor the defaultPOTCARset.poscar_comment (str) – Comment line to use for
POSCARfiles. Default is defect name, fractional coordinates of initial site and charge state.**kwargs – Additional kwargs to pass to
VaspInputSet.
- property incar
Returns the
Incarobject generated fromDopedDictSet, withNELECTandNUPDOWNset accordingly.See https://doped.readthedocs.io/en/latest/Tips.html#spin for discussion about appropriate
NUPDOWN/MAGMOMsettings.
- property nelect
Number of electrons (
NELECT) for the given structure and charge state.This is equal to the sum of valence electrons (
ZVAL) of thePOTCARs for each atom in the structure (supercell), minus the charge state.
- write_input(output_path: str | Path, poscar: bool = True, rattle: bool = False, make_dir_if_not_present: bool = True, include_cif: bool = False, potcar_spec: bool = False, zip_output: bool = False, snb: bool = False, stdev: float | None = None, d_min: float | None = None)[source]
Writes out all input to a directory.
Refactored slightly from
pymatgenVaspInputSet.write_input()to allow checking of userPOTCARsetup, and generation of rattled structures.- Parameters:
output_path (PathLike) – Directory to output the
VASPinput files.poscar (bool) – If True, write the
POSCARto the generated folder as well. Ifrattle=True, this will be a rattled structure, otherwise the unperturbed defect structure. (default: True)rattle (bool) – If writing
POSCAR, apply random displacements to all atomic positions in the structure using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: False)make_dir_if_not_present (bool) – Set to
Trueif 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.specfile, the specific POTCAR file can be re-generated usingpymatgenwith thegenerate_potcarfunction in thepymatgenCLI. (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’) – only really intended for internal use byShakeNBreak. (default: False)stdev (float) – Standard deviation for the Gaussian distribution of displacements for the
ShakeNBreakrattling algorithm. IfNone(default) this is set to 10% of the nearest neighbour distance in the structure.d_min (float) – Minimum interatomic distance (in Angstroms) in the rattled structure. Monte Carlo rattle moves that put atoms at distances less than this will be heavily penalised. Default is to set this to 80% of the nearest neighbour distance in the structure.
- 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:
MSONableClass for generating input files for
VASPdefect relaxation calculations for a singlepymatgenDefectEntryorStructureobject.The supercell structure and charge state are taken from the
DefectEntryattributes, or if aStructureis provided, then from thedefect_supercellandcharge_stateinput parameters.Creates attributes:
DefectRelaxSet.vasp_gam:DefectDictSetfor Gamma-point only relaxation. Usually not needed ifShakeNBreak(or other) structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and novasp_stdcalculations with multiple k-points are required (determined from kpoint settings).
DefectRelaxSet.vasp_nkred_std:DefectDictSetfor relaxation with a kpoint mesh and usingNKRED. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_incar_settings) or if only Gamma k-point sampling is required.
DefectRelaxSet.vasp_std:DefectDictSetfor relaxation with a kpoint mesh, not usingNKRED. Not generated if only Gamma kpoint sampling is required.
DefectRelaxSet.vasp_ncl:DefectDictSetfor single-point (static) energy calculation with SOC included. Generated ifsoc=True. Ifsocis 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
DefectDictSetis an extension ofpymatgen’sVaspInputSetclass for defect calculations, withincar,poscar,kpointsandpotcarattributes for the corresponding VASP defect calculations (see docstring). Also creates the correspondingbulk_vasp_...attributes for single-point (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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.- Parameters:
defect_entry (DefectEntry, Structure) –
doped/pymatgenDefectEntryorStructure(defect supercell) for which to generateDefectDictSets for.charge_state (int) – Charge state of the defect. Overrides
DefectEntry.charge_stateifDefectEntryis input.soc (bool) – Whether to generate
vasp_nclDefectDictSet attribute for spin-orbit coupling single-point (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), otherwiseFalse.user_incar_settings (dict) – Dictionary of user
INCARsettings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at outputINCARs or theRelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder, to see what the defaultINCARsettings are. Note that any flags that aren’t numbers orTrue/Falseneed to be input as strings with quotation marks (e.g.{"ALGO": "All"}). (default: None)user_kpoints_settings (dict or Kpoints) – Dictionary of user
KPOINTSsettings (inpymatgenVaspInputSetformat) e.g.,{"reciprocal_density": 123}, or aKpointsobject, to use for thevasp_std,vasp_nkred_stdandvasp_nclDefectDictSets (Γ-only forvasp_gam). Default is Gamma-centred,reciprocal_density = 100[Å⁻³].user_potcar_functional (str) –
POTCARfunctional 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"}. Seedoped/VASP_sets/PotcarSet.yamlfor the defaultPOTCARset.**kwargs – Additional kwargs to pass to
DefectDictSet.
- Key Attributes:
- vasp_gam (DefectDictSet):
DefectDictSetfor Gamma-point only relaxation. Usually not needed ifShakeNBreak(or other) structure searching has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and novasp_stdcalculations with multiple k-points are required (determined from kpoints settings).- vasp_nkred_std (DefectDictSet):
DefectDictSetfor relaxation with a non-Γ-only kpoint mesh, usingNKRED(X,Y,Z)INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_incar_settings) or if only Gamma kpoint sampling is required.- vasp_std (DefectDictSet):
DefectDictSetfor relaxation with a non-Γ-only kpoint mesh, not usingNKRED. Not generated if only Gamma kpoint sampling is required.- vasp_ncl (DefectDictSet):
DefectDictSetfor single-point (static) energy calculation with SOC included. Generated ifsoc=True. Ifsocis 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).- defect_supercell (Structure):
Supercell structure for defect calculations, taken from
defect_entry.defect_supercell(if defined), otherwise fromdefect_entry.sc_entry.structureif inputting aDefectEntryobject, or the input structure if inputting aStructureobject.- bulk_supercell (Structure):
Supercell structure of the bulk (pristine, defect-free) material, taken from
defect_entry.bulk_supercell(if defined), otherwise fromdefect_entry.bulk_entry.structureif inputting aDefectEntryobject, orNoneif inputting aStructureobject.- poscar_comment (str):
Comment to write at the top of the
POSCARfiles. Default is the defect entry name, defect frac coords and charge state (if inputting aDefectEntryobject), or the formula of the input structure and charge state (if inputting aStructureobject), for defects. For the bulk supercell, it’s"{formula} - Bulk".- bulk_vasp_gam (DefectDictSet):
DefectDictSetfor a bulk Γ-point-only single-point (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 withvasp_stdorvasp_ncl.- bulk_vasp_nkred_std (DefectDictSet):
DefectDictSetfor a single-point (static) bulkvasp_stdsupercell calculation (i.e. with a non-Γ-only kpoint mesh) andNKRED(X,Y,Z)INCARtag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_incar_settings) or if only Gamma kpoint sampling is required.- bulk_vasp_std (DefectDictSet):
DefectDictSetfor a single-point (static) bulkvasp_stdsupercell calculation with a non-Γ-only kpoint mesh, not usingNKRED. Not generated if only Gamma kpoint sampling is required.- bulk_vasp_ncl (DefectDictSet):
DefectDictSetfor single-point (static) energy calculation of the bulk supercell with SOC included. Generated ifsoc=True. Ifsocis 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).
Input parameters are also set as attributes.
- property bulk_vasp_gam: DefectDictSet | None
Returns a
DefectDictSetobject for a VASP bulk Γ-point-only (vasp_gam) single-point (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 isvasp_stdif we have a non-Γ-only final k-point mesh, orvasp_nclif SOC effects are being included. If the final converged k-point mesh is Γ-only, thenbulk_vasp_gamshould be used to calculate the single- point (static) bulk supercell reference energy. Can also sometimes be useful for the purpose of calculating defect formation energies at early stages of the typicalvasp_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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property bulk_vasp_ncl: DefectDictSet | None
Returns a
DefectDictSetobject for VASP bulk supercell single- point calculations with spin-orbit coupling (SOC) included (i.e.LSORBIT = True), usingvasp_ncl. IfDefectRelaxSet.socis False, then this returns None and a warning. If thesocparameter is not set when initializingDefectRelaxSet, 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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property bulk_vasp_nkred_std: DefectDictSet | None
Returns a
DefectDictSetobject for a single-point (static) bulkvasp_stdsupercell calculation (i.e. with a non-Γ-only kpoint mesh) andNKRED(X,Y,Z)INCAR tag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. By default, setsNKRED(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_gamshould be used) or for GGA calculations (ifLHFCALCis set toFalsein user_incar_settings, in which case(bulk_)vasp_stdshould be used).The bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which is
vasp_stdif we have a non-Γ-only final k-point mesh,vasp_nclif SOC effects are being included (in which casebulk_vasp_nclshould be used for the single-point bulk supercell reference calculation), orvasp_gamif the final converged k-point mesh is Γ-only (in which casebulk_vasp_gamshould be used for the single-point bulk supercell reference calculation). Can also sometimes be useful for the purpose of calculating defect formation energies at midway stages of the typicalvasp_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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property bulk_vasp_std: DefectDictSet | None
Returns a
DefectDictSetobject for a single-point (static) bulkvasp_stdsupercell calculation. Returns None and a warning if the input kpoint settings correspond to a Γ-only kpoint mesh (in which case(bulk_)vasp_gamshould be used).The bulk supercell only needs to be calculated once with the same settings as the final defect calculations, which is
vasp_stdif we have a non-Γ-only final k-point mesh,vasp_nclif SOC effects are being included (in which casebulk_vasp_nclshould be used for the single-point bulk supercell reference calculation), orvasp_gamif the final converged k-point mesh is Γ-only (in which casebulk_vasp_gamshould be used for the single-point bulk supercell reference calculation). Can also sometimes be useful for the purpose of calculating defect formation energies at midway stages of the typicalvasp_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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property vasp_gam: DefectDictSet
Returns a
DefectDictSetobject for a VASP Γ-point-only (vasp_gam) defect supercell relaxation. Typically not needed if ShakeNBreak (or other) 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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property vasp_ncl: DefectDictSet | None
Returns a
DefectDictSetobject for a VASP defect supercell single- point calculation with spin-orbit coupling (SOC) included (i.e.LSORBIT = True), usingvasp_ncl. IfDefectRelaxSet.socis False, then this returns None and a warning. If thesocparameter is not set when initializingDefectRelaxSet, 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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property vasp_nkred_std: DefectDictSet | None
Returns a
DefectDictSetobject for a VASP defect supercell relaxation usingvasp_std(i.e. with a non-Γ-only kpoint mesh) andNKRED(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, setsNKRED(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 casevasp_gamshould be used) or for GGA calculations (ifLHFCALCis set toFalsein user_incar_settings, in which casevasp_stdshould be used).See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- property vasp_std: DefectDictSet | None
Returns a
DefectDictSetobject for a VASP defect supercell relaxation usingvasp_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 casevasp_gamshould be used).See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.
- write_all(defect_dir: str | Path | None = None, poscar: bool = False, rattle: bool = True, vasp_gam: bool | None = None, bulk: bool | str = False, **kwargs)[source]
Write all VASP input files to subfolders in the
defect_dirfolder.The following subfolders are generated:
vasp_nkred_std:Defect relaxation with a kpoint mesh and using
NKRED. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_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. Ifsocis 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) orself.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 structure searching has been performed (e.g. with
ShakeNBreak) (recommended).
By default, does not generate a
vasp_gamfolder unlessself.vasp_stdisNone(i.e. only Γ-point sampling required for this system), asvasp_gamcalculations should be performed with defect structure-searching (e.g. withShakeNBreak) and initial relaxations. Ifvasp_gamfiles are desired, setvasp_gam=True.By default,
POSCARfiles are not generated for thevasp_(nkred_)std(andvasp_nclifself.socis True) folders, as these should be taken from structure-searching calculations (e.g.snb-groundstate -d vasp_nkred_std) or, if not following the recommended structure-searching workflow, from theCONTCARs ofvasp_gamcalculations. If including SOC effects (i.e.self.soc = True), then thevasp_stdCONTCARs should be used as thevasp_nclPOSCARs. IfPOSCARfiles are desired for thevasp_(nkred_)std(andvasp_ncl) folders, setposcar=True.Input files for the single-point (static) bulk supercell reference calculation are also written to
"{formula}_bulk/{subfolder}"ifbulkisTrue(Falseby default), wheresubfoldercorresponds to the final (highest accuracy) VASP calculation in the workflow (i.e.vasp_nclifself.soc=True, otherwisevasp_stdorvasp_gamif only Γ-point reciprocal space sampling is required). Ifbulk = "all", then the input files for all VASP calculations in the workflow are written to the bulk supercell folder.See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.The
DefectEntryobject is also written to ajson.gzfile indefect_dirto aid calculation provenance – can be reloaded directly withloadfn()frommonty.serialization, orDefectEntry.from_json().- Parameters:
defect_dir (PathLike) – Folder in which to create the
VASPdefect calculation inputs. Default is to use theDefectEntryname (e.g."Y_i_C4v_O1.92_+2"etc.), fromself.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (usingget_defect_name_from_entry()). Output folder structure is<defect_dir>/<subfolder>wheresubfolderis the name of the corresponding VASP program to run (e.g.vasp_std).poscar (bool) – If
True, writes the defectPOSCARto the generated folders as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching usingShakeNBreak(https://shakenbreak.readthedocs.io) or another approach, then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)), first withNKREDif using hybrid DFT, then withoutNKRED. (default: False)rattle (bool) – If writing
POSCARs, apply random displacements to all atomic positions in the structures using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)vasp_gam (Optional[bool]) – If
True, writes thevasp_gaminput files, with defectPOSCAR. Not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching (e.g. using ShakeNBreak; https://shakenbreak.readthedocs.io), then continue thevasp_stdrelaxations from the ground-state structures. Default isNone, wherevasp_gamfolders are written ifself.vasp_stdisNone(i.e. only Γ-point reciprocal space sampling is required).bulk (bool, str) – If
True, the input files for a single-point calculation of the bulk supercell are also written to"{formula}_bulk/{subfolder}", wheresubfoldercorresponds to the final (highest accuracy)VASPcalculation in the workflow (i.e.vasp_nclifself.soc=True, otherwisevasp_stdorvasp_gamif only Γ-point reciprocal space sampling is required). Ifbulk = "all"then the input files for allVASPcalculations 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 | Path | None = None, subfolder: str | Path | None = 'vasp_gam', poscar: bool = True, rattle: 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 performvasp_gamcalculations usingShakeNBreak(or other approaches) for defect structure-searching and initial relaxations, but should be used if the final, converged k-point mesh is Γ-point-only. Ifbulkis True, the input files for a single-point calculation of the bulk supercell are also written to"{formula}_bulk/{subfolder}".See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.The
DefectEntryobject is also written to ajson.gzfile indefect_dirto aid calculation provenance – can be reloaded directly withloadfn()frommonty.serialization, orDefectEntry.from_json().- Parameters:
defect_dir (PathLike) – Folder in which to create the
VASPdefect calculation inputs. Default is to use theDefectEntryname (e.g."Y_i_C4v_O1.92_+2"etc.), fromself.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (usingget_defect_name_from_entry()).subfolder (PathLike) – Output folder structure is
<defect_dir>/<subfolder>wheresubfolder= ‘vasp_gam’ by default. SettingsubfoldertoNonewill write thevasp_gaminput files directly to the<defect_dir>folder, with no subfolders created.poscar (bool) – If
True(default), writes the defectPOSCARto the generated folder as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching usingShakeNBreak(https://shakenbreak.readthedocs.io) or another approach, then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)). (default: True)rattle (bool) – If writing
POSCAR, apply random displacements to all atomic positions in the structure using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)bulk (bool) – If
True, the input files for a single-point 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 | Path | None = None, subfolder: str | Path | None = 'vasp_ncl', poscar: bool = False, rattle: bool = True, bulk: bool = False, **kwargs)[source]
Write the input files for
VASPdefect supercell single-point calculations with spin-orbit coupling (SOC) (LSORBIT = True) included, usingvasp_ncl.By default, does not generate
POSCAR(input structure) files, as these should be taken from theCONTCARs ofvasp_stdrelaxations (originally from structure-searching relaxations), or directly fromShakeNBreakcalculations (viasnb-groundstate -d vasp_ncl) if only Γ-point reciprocal space sampling is required. IfPOSCARfiles are desired, setposcar=True.If
DefectRelaxSet.socis False, then this returns None and a warning. If thesocparameter is not set when initializingDefectRelaxSet, 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 single-point calculation of the bulk supercell are also written to “{formula}_bulk/{subfolder}”.See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.The
DefectEntryobject is also written to ajson.gzfile indefect_dirto aid calculation provenance – can be reloaded directly withloadfn()frommonty.serialization, orDefectEntry.from_json().- Parameters:
defect_dir (PathLike) – Folder in which to create the
VASPdefect calculation inputs. Default is to use theDefectEntryname (e.g."Y_i_C4v_O1.92_+2"etc.), fromself.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (usingget_defect_name_from_entry()).subfolder (PathLike) – Output folder structure is
<defect_dir>/<subfolder>wheresubfolder= ‘vasp_ncl’ by default. SettingsubfoldertoNonewill write thevasp_nclinput files directly to the<defect_dir>folder, with no subfolders created.poscar (bool) – If
True, writes the defectPOSCARto the generated folder as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching (e.g. usingShakeNBreak(https://shakenbreak.readthedocs.io)), then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)), first withNKREDif using hybrid DFT, then without, then use thevasp_stdCONTCARs as the input structures for finalvasp_nclsingle-point calculations. (default: False)rattle (bool) – If writing
POSCAR, apply random displacements to all atomic positions in the structure using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)bulk (bool) – If
True, the input files for a single-point 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 | Path | None = None, subfolder: str | Path | None = 'vasp_nkred_std', poscar: bool = False, rattle: bool = True, bulk: bool = False, **kwargs)[source]
Write the input files for defect calculations using
vasp_std(i.e. with a non-Γ-only kpoint mesh) andNKRED(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, setsNKRED(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 theCONTCARs of structure-searching calculations (e.g. viasnb-groundstate -d vasp_nkred_std) or, if not following the recommended structure-searching workflow, from theCONTCARs ofvasp_gamcalculations. IfPOSCARfiles are desired, setposcar=True. IfbulkisTrue, the input files for a single-point 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_gamshould be used) or for GGA calculations (ifLHFCALCis set toFalsein user_incar_settings, in which casevasp_stdshould be used).See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.The
DefectEntryobject is also written to ajson.gzfile indefect_dirto aid calculation provenance – can be reloaded directly withloadfn()frommonty.serialization, orDefectEntry.from_json().- Parameters:
defect_dir (PathLike) – Folder in which to create the
VASPdefect calculation inputs. Default is to use theDefectEntryname (e.g."Y_i_C4v_O1.92_+2"etc.), fromself.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (usingget_defect_name_from_entry()).subfolder (PathLike) – Output folder structure is
<defect_dir>/<subfolder>wheresubfolder= ‘vasp_nkred_std’ by default. SettingsubfoldertoNonewill write thevasp_nkred_stdinput files directly to the<defect_dir>folder, with no subfolders created.poscar (bool) – If
True, writes the defectPOSCARto the generated folder as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching usingShakeNBreak(https://shakenbreak.readthedocs.io) or another approach, then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)). (default: False)rattle (bool) – If writing
POSCAR, apply random displacements to all atomic positions in the structure using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)bulk (bool) – If
True, the input files for a single-point 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 | Path | None = None, subfolder: str | Path | None = 'vasp_std', poscar: bool = False, rattle: bool = True, 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 theCONTCARs ofvasp_stdrelaxations usingNKRED(X,Y,Z)(originally from structure-searching relaxations) if using hybrid DFT, or fromShakeNBreakcalculations (viasnb-groundstate -d vasp_std) if using GGA, or, if not following the recommended structure-searching workflow, from theCONTCARs ofvasp_gamcalculations. IfPOSCARfiles are desired, setposcar=True. IfbulkisTrue, the input files for a single-point 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_gamshould be used).See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.The
DefectEntryobject is also written to ajson.gzfile indefect_dirto aid calculation provenance – can be reloaded directly withloadfn()frommonty.serialization, orDefectEntry.from_json().- Parameters:
defect_dir (PathLike) – Folder in which to create the
VASPdefect calculation inputs. Default is to use theDefectEntryname (e.g."Y_i_C4v_O1.92_+2"etc.), fromself.defect_entry.name. If this attribute is not set, it is automatically generated according to the doped convention (usingget_defect_name_from_entry()).subfolder (PathLike) – Output folder structure is
<defect_dir>/<subfolder>wheresubfolder= ‘vasp_std’ by default. SettingsubfoldertoNonewill write thevasp_stdinput files directly to the<defect_dir>folder, with no subfolders created.poscar (bool) – If
True, writes the defectPOSCARto the generated folder as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching usingShakeNBreak(https://shakenbreak.readthedocs.io) or another approach, then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)). (default: False)rattle (bool) – If writing
POSCAR, apply random displacements to all atomic positions in the structure using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)bulk (bool) – If
True, the input files for a single-point 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:
MSONableClass for generating input files for
VASPdefect calculations for a set ofdoped/pymatgenDefectEntryobjects.Creates a dictionary of:
{defect name: DefectRelaxSet}.DefectRelaxSethas the attributes:DefectRelaxSet.vasp_gam:DefectDictSetfor Gamma-point only relaxation. Usually not needed if structure searching (e.g.ShakeNBreak) has been performed (recommended), unless only Γ-point k-point sampling is required (converged) for your system, and novasp_stdcalculations with multiple k-points are required (determined from kpoint settings).
DefectRelaxSet.vasp_nkred_std:DefectDictSetfor relaxation with a kpoint mesh and usingNKRED. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_incar_settings) or if only Gamma k-point sampling is required.
DefectRelaxSet.vasp_std:DefectDictSetfor relaxation with a kpoint mesh, not usingNKRED. Not generated if only Gamma kpoint sampling is required.
DefectRelaxSet.vasp_ncl:DefectDictSetfor single-point (static) energy calculation with SOC included. Generated ifsoc=True. Ifsocis 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
DefectDictSetis an extension ofpymatgen’sVaspInputSetclass for defect calculations, withincar,poscar,kpointsandpotcarattributes for the corresponding VASP defect calculations (see docstring). Also creates the correspondingbulk_vasp_...attributes for single-point (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.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARsettings, andPotcarSet.yamlfor the defaultPOTCARsettings.Note that any changes to the default
INCAR/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.- Parameters:
defect_entries (
DefectsGenerator, dict/list ofDefectEntrys, orDefectEntry) – Either aDefectsGeneratorobject, or a dictionary/list ofDefectEntrys, or a singleDefectEntryobject, for which to generate VASP input files. If aDefectsGeneratorobject or a dictionary (->{defect name: DefectEntry}), the defect folder names will be set equal todefect name. If a list or singleDefectEntryobject is provided, the defect folder names will be set equal toDefectEntry.nameif thenameattribute is set, otherwise generated according to thedopedconvention (seedoped.generation). Defect charge states are taken fromDefectEntry.charge_state.soc (bool) – Whether to generate
vasp_nclDefectDictSetattribute for spin-orbit coupling single-point (static) energy calculations. If not set, then by default is set toTrueif 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
INCARsettings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at outputINCARs or theRelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder, to see what the defaultINCARsettings are. Note that any flags that aren’t numbers orTrue/Falseneed to be input as strings with quotation marks (e.g.{"ALGO": "All"}). (default: None)user_kpoints_settings (dict or Kpoints) – Dictionary of user
KPOINTSsettings (inpymatgenVaspInputSetformat) e.g.,{"reciprocal_density": 123}, or aKpointsobject, to use for thevasp_std,vasp_nkred_stdandvasp_nclDefectDictSets (Γ-only forvasp_gam). Default is Gamma-centred,reciprocal_density = 100[Å⁻³].user_potcar_functional (str) –
POTCARfunctional 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"}. Seedoped/VASP_sets/PotcarSet.yamlfor the defaultPOTCARset.**kwargs – Additional kwargs to pass to each
DefectRelaxSet().
- Key Attributes:
- defect_sets (Dict):
Dictionary of
{defect name: DefectRelaxSet}.- defect_entries (Dict):
Dictionary of
{defect name: DefectEntry}for the input defect species, for which to generateVASPinput files.- bulk_vasp_gam (DefectDictSet):
DefectDictSetfor a bulk Γ-point-only single-point (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 withvasp_stdorvasp_ncl.- bulk_vasp_nkred_std (DefectDictSet):
DefectDictSetfor a single-point (static) bulkvasp_stdsupercell calculation (i.e. with a non-Γ-only kpoint mesh) andNKRED(X,Y,Z)INCARtag(s) to downsample kpoints for the HF exchange part of the hybrid DFT calculation. Not generated for GGA calculations (ifLHFCALCis set toFalseinuser_incar_settings) or if only Gamma kpoint sampling is required.- bulk_vasp_std (DefectDictSet):
DefectDictSetfor a single-point (static) bulkvasp_stdsupercell calculation with a non-Γ-only kpoint mesh, not usingNKRED. Not generated if only Gamma kpoint sampling is required.- bulk_vasp_ncl (DefectDictSet):
DefectDictSetfor single-point (static) energy calculation of the bulk supercell with SOC included. Generated ifsoc=True. Ifsocis 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).- bulk_supercell (Structure):
Supercell structure of the bulk (pristine) material.
- json_obj (Union[Dict, DefectsGenerator]):
Either the
DefectsGeneratorobject if inputdefect_entriesis aDefectsGeneratorobject, otherwise thedefect_entriesdictionary, which will be written to file whenwrite_files()is called, to aid calculation provenance.- json_name (PathLike):
Name of the
JSONfile to save thejson_objto.
Input parameters are also set as attributes.
- write_files(output_path: str | Path = '.', poscar: bool = False, rattle: bool = True, vasp_gam: bool | None = None, 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 inself.defect_sets(same as self.defect_entries keys, seeDefectsSetdocstring).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 (ifLHFCALCis set toFalseinuser_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. Ifsocis 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) orself.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 structure searching has been performed (e.g. with
ShakeNBreak) (recommended).
By default, does not generate a
vasp_gamfolder unlessDefectRelaxSet.vasp_stdisNone(i.e. only Γ-point sampling required for this system), asvasp_gamcalculations should be performed with defect structure-searching (e.g. withShakeNBreak) and initial relaxations. Ifvasp_gamfiles are desired, setvasp_gam=True.By default,
POSCARfiles are not generated for thevasp_(nkred_)std(andvasp_nclifself.socisTrue) folders, as these should be taken from structure-searching calculations (e.g.snb-groundstate -d vasp_nkred_std) or, if not following the recommended structure-searching workflow, from theCONTCARs ofvasp_gamcalculations. If including SOC effects (i.e.self.soc = True), then thevasp_stdCONTCARs should be used as thevasp_nclPOSCARs. IfPOSCARfiles are desired for thevasp_(nkred_)std(andvasp_ncl) folders, setposcar=True.Input files for the single-point (static) bulk supercell reference calculation are also written to
"{formula}_bulk/{subfolder}"ifbulkisTrue(default), wheresubfoldercorresponds to the final (highest accuracy) VASP calculation in the workflow (i.e.vasp_nclifself.soc=True, otherwisevasp_stdorvasp_gamif only Γ-point reciprocal space sampling is required). Ifbulk = "all", then the input files for all VASP calculations (gam/std/ncl) are written to the bulk supercell folder, or ifbulk = False, then no bulk folder is created.The
DefectEntryobjects are also written tojson.gzfiles in the defect folders, as well asself.defect_entries(self.json_obj) in the top folder, to aid calculation provenance – these can be reloaded directly withloadfn()frommonty.serialization, or individually withDefectEntry.from_json().See the
RelaxSet.yamlandDefectSet.yamlfiles in thedoped/VASP_setsfolder for the defaultINCARandKPOINTsettings, andPotcarSet.yamlfor the defaultPOTCARsettings. 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/POTCARsettings should be consistent with those used for all defect and competing phase (chemical potential) calculations – this will be automatically checked upon defect & competing phases parsing indoped.- Parameters:
output_path (PathLike) – Folder in which to create the VASP defect calculation folders. Default is the current directory (“.”). Output folder structure is
<output_path>/<defect name>/<subfolder>wheredefect nameis the key of the DefectRelaxSet inself.defect_sets(same asself.defect_entrieskeys, seeDefectsSetdocstring) andsubfolderis the name of the corresponding VASP program to run (e.g.vasp_std).poscar (bool) – If
True, writes the defectPOSCARto the generated folders as well. Typically not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching usingShakeNBreak(https://shakenbreak.readthedocs.io) or another approach, then continue thevasp(_nkred)_stdrelaxations from the ground-state structures (e.g. using-d vasp_nkred_stdwithsnb-groundstate(CLI) orgroundstate_folder="vasp_nkred_std"withwrite_groundstate_structure(Python API)), first withNKREDif using hybrid DFT, then withoutNKRED. (default: False)rattle (bool) – If writing
POSCARs, apply random displacements to all atomic positions in the structures using theShakeNBreakalgorithm; i.e. with the displacement distances randomly drawn from a Gaussian distribution of standard deviation equal to 10% of the bulk nearest neighbour distance and using a Monte Carlo algorithm to penalise displacements that bring atoms closer than 80% of the bulk nearest neighbour distance.stdevandd_mincan also be given as input kwargs. This is intended to be used as a fallback option for breaking symmetry to partially aid location of global minimum defect geometries, ifShakeNBreakstructure-searching is being skipped. However, rattling still only finds the ground-state structure for <~30% of known cases of energy-lowering reconstructions relative to an unperturbed defect structure. (default: True)vasp_gam (Optional[bool]) – If
True, writes thevasp_gaminput files, with defectPOSCARs. Not recommended, as the recommended workflow is to initially performvasp_gamground-state structure searching (e.g. usingShakeNBreak; https://shakenbreak.readthedocs.io), then continue thevasp_stdrelaxations from the ground-state structures. Default isNone, wherevasp_gamfolders are written ifself.vasp_stdisNone(i.e. only Γ-point reciprocal space sampling is required).bulk (bool, str) – If
True, the input files for a single-point calculation of the bulk supercell are also written to"{formula}_bulk/{subfolder}", wheresubfoldercorresponds to the final (highest accuracy)VASPcalculation in the workflow (i.e.vasp_nclifself.soc=True, otherwisevasp_stdorvasp_gamif only Γ-point reciprocal space sampling is required). Ifbulk = "all"then the input files for allVASPcalculations 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
multiprocessingfor file writing. IfNone(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:
VaspInputSetModified version of
pymatgenVaspInputSet, to have more robustPOTCARhandling, expedited I/O (particularly forPOTCARgeneration, which can be slow when generating many folders), ensurePOSCARatom sorting, avoid encoding issues withKPOINTScomments etc.- Parameters:
structure (Structure) –
pymatgenStructureobject for the input structure file.user_incar_settings (dict) – Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default
INCARsettings. Note that any flags that aren’t numbers orTrue/Falseneed to be input as strings with quotation marks (e.g.{"ALGO": "All"}). (default: None)user_kpoints_settings (dict or Kpoints) – Dictionary of user
KPOINTSsettings (inpymatgenVaspInputSetformat) e.g.,{"reciprocal_density": 123}, or aKpointsobject. Default is Gamma-only.user_potcar_functional (str) –
POTCARfunctional 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”}. Seedoped/VASP_sets/PotcarSet.yamlfor the defaultPOTCARset.auto_kpar (bool) – If
True, andKPARis not set inuser_incar_settings, attempts to setKPARto a reasonable value based on the k-point grid. Specifically, setsKPARto 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 of1). Default isTrue.poscar_comment (str) – Comment line to use for
POSCARfile. Default is structure formula.**kwargs – Additional kwargs to pass to
VaspInputSet.
- property incar
Returns the
Incarobject generated from theVaspInputSetconfig, with a warning ifKPAR > 1and only one k-point.
- property kpoints
Return
kpointsobject with comment.
- class doped.vasp.DopedKpoints(comment: str = 'Default gamma', num_kpts: int = 0, style: KpointsSupportedModes = KpointsSupportedModes.Gamma, kpts: Sequence[Kpoint] = ((1, 1, 1),), kpts_shift: tuple[float, float, float] = (0, 0, 0), kpts_weights: Sequence[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:
KpointsCustom implementation of
Kpointsto 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
KPOINTScomment.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.
The default behavior of the constructor is for a Gamma-centered, 1x1x1 KPOINTS with no shift.
- 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 sequence) – Sequence 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 sequence. e.g. [(20,),] or [(2, 2, 2),].
kpts_shift (3x1 array) – Shift for kpoints.
kpts_weights (Sequence[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]), …]
- 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, ediff_per_atom: float = 2e-07, max_ediff: float = 0.0001) float[source]
Returns a scaled
EDIFFvalue for VASP calculations, based on the number of atoms in the structure.- Parameters:
natoms (int) – Number of atoms in the structure.
ediff_per_atom (float) – Per-atom
EDIFFin eV. Default is 2e-7 (1e-5 per 50 atoms).max_ediff (float) – Maximum
EDIFFvalue. Default is 1e-4 eV.
- Returns:
Scaled
EDIFFvalue.- Return type:
float