VaspInputGenerator#

class atomate2.vasp.sets.base.VaspInputGenerator(user_incar_settings=<factory>, user_kpoints_settings=<factory>, user_potcar_settings=<factory>, user_potcar_functional=None, auto_ismear=True, auto_ispin=False, auto_lreal=False, auto_kspacing=False, auto_metal_kpoints=True, constrain_total_magmom=False, validate_magmom=True, use_structure_charge=False, sort_structure=True, force_gamma=True, symprec=0.1, vdw=None, config_dict=<factory>, inherit_incar=None)[source]#

Bases: InputGenerator

A class to generate VASP input sets.

Note

Get the magmoms using the following precedence.

  1. user incar settings

  2. magmoms in input struct

  3. spins in input struct

  4. job config dict

  5. set all magmoms to 0.6

Parameters:
  • user_incar_settings (dict) – User INCAR settings. This allows a user to override INCAR settings, e.g., setting a different MAGMOM for various elements or species. The config_dict supports EDIFF_PER_ATOM and EDIFF keys. The former scales with # of atoms, the latter does not. If both are present, EDIFF is preferred. To force such settings, just supply user_incar_settings={“EDIFF”: 1e-5, “LDAU”: False} for example. The keys ‘LDAUU’, ‘LDAUJ’, ‘LDAUL’ are special cases since pymatgen defines different values depending on what anions are present in the structure, so these keys can be defined in one of two ways, e.g. either {“LDAUU”:{“O”:{“Fe”:5}}} to set LDAUU for Fe to 5 in an oxide, or {“LDAUU”:{“Fe”:5}} to set LDAUU to 5 regardless of the input structure. To set magmoms, pass a dict mapping the strings of species to magnetic moments, e.g. {“MAGMOM”: {“Co”: 1}} or {“MAGMOM”: {“Fe2+,spin=4”: 3.7}} in the case of a site with Species(“Fe2+”, spin=4). If None is given, that key is unset. For example, {“ENCUT”: None} will remove ENCUT from the incar settings.

  • user_kpoints_settings (dict | pymatgen.io.vasp.inputs.Kpoints) – Allow user to override kpoints setting by supplying a dict. E.g., {"reciprocal_density": 1000}. User can also supply a Kpoints object.

  • user_potcar_settings (dict) – Allow user to override POTCARs. E.g., {“Gd”: “Gd_3”}.

  • user_potcar_functional (str) – Functional to use. Default is to use the functional in the config dictionary. Valid values: “PBE”, “PBE_52”, “PBE_54”, “PBE_64”, “LDA”, “LDA_52”, “LDA_54”, “LDA_64”, “PW91”, “LDA_US”, “PW91_US”.

  • auto_ismear (bool) – If true, the values for ISMEAR and SIGMA will be set automatically depending on the bandgap of the system. If the bandgap is not known (e.g., there is no previous VASP directory) then ISMEAR=0 and SIGMA=0.2; if the bandgap is zero (a metallic system) then ISMEAR=2 and SIGMA=0.2; if the system is an insulator, then ISMEAR=-5 (tetrahedron smearing). Note, this only works when generating the input set from a previous VASP directory.

  • auto_ispin (bool) – If generating input set from a previous calculation, this controls whether to disable magnetisation (ISPIN = 1) if the absolute value of all magnetic moments are less than 0.02.

  • auto_lreal (bool) – If True, automatically use the VASP recommended LREAL based on cell size.

  • auto_metal_kpoints (bool) – If true and the system is metallic, try and use reciprocal_density_metal instead of reciprocal_density for metallic systems. Note, this only works when generating the input set from a previous VASP directory.

  • auto_kspacing (bool | float) – If true, automatically use the VASP recommended KSPACING based on bandgap, i.e. higher kpoint spacing for insulators than metals. Can be boolean or float. If a float, the value will be interpreted as the bandgap in eV to use for the KSPACING calculation.

  • constrain_total_magmom (bool) – Whether to constrain the total magmom (NUPDOWN in INCAR) to be the sum of the initial MAGMOM guess for all species.

  • validate_magmom (bool) – Ensure that missing magmom values are filled in with the default value of 1.0.

  • use_structure_charge (bool) – If set to True, then the overall charge of the structure (structure.charge) is used to set NELECT.

  • sort_structure (bool) – Whether to sort the structure (using the default sort order of electronegativity) before generating input files. Defaults to True, the behavior you would want most of the time. This ensures that similar atomic species are grouped together.

  • force_gamma (bool) – Force gamma centered kpoint generation.

  • vdw (str) – Adds default parameters for van-der-Waals functionals supported by VASP to INCAR. Supported functionals are: DFT-D2, undamped DFT-D3, DFT-D3 with Becke-Jonson damping, Tkatchenko-Scheffler, Tkatchenko-Scheffler with iterative Hirshfeld partitioning, MBD@rSC, dDsC, Dion’s vdW-DF, DF2, optPBE, optB88, optB86b and rVV10.

  • symprec (float) – Tolerance for symmetry finding, used for line mode band structure k-points.

  • config_dict (dict) – The config dictionary to use containing the base input set settings.

  • inherit_incar (bool) – Whether to inherit INCAR settings from previous calculation. This might be useful to port Custodian fixes to child jobs but can also be dangerous e.g. when switching from GGA to meta-GGA or relax to static jobs. Defaults to True.

get_input_set(structure=None, prev_dir=None, potcar_spec=False)[source]#

Get a VASP input set.

Note, if both structure and prev_dir are set, then the structure specified will be preferred over the final structure from the last VASP run.

Parameters:
  • structure (Structure) – A structure.

  • prev_dir (str | Path) – A previous directory to generate the input set from.

  • potcar_spec (bool) – Instead of generating a Potcar object, use a list of potcar symbols. This will be written as a “POTCAR.spec” file. 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.

Returns:

A VASP input set.

Return type:

VaspInputSet

get_incar_updates(structure, prev_incar=None, bandgap=0.0, vasprun=None, outcar=None)[source]#

Get updates to the INCAR for this calculation type.

Parameters:
  • structure (Structure) – A structure.

  • prev_incar (dict) – An incar from a previous calculation.

  • bandgap (float) – The band gap.

  • vasprun (Vasprun) – A vasprun from a previous calculation.

  • outcar (Outcar) – An outcar from a previous calculation.

Returns:

A dictionary of updates to apply.

Return type:

dict

get_kpoints_updates(structure, prev_incar=None, bandgap=0.0, vasprun=None, outcar=None)[source]#

Get updates to the kpoints configuration for this calculation type.

Note, these updates will be ignored if the user has set user_kpoint_settings.

Parameters:
  • structure (Structure) – A structure.

  • prev_incar (dict) – An incar from a previous calculation.

  • bandgap (float) – The band gap.

  • vasprun (Vasprun) – A vasprun from a previous calculation.

  • outcar (Outcar) – An outcar from a previous calculation.

Returns:

A dictionary of updates to apply to the KPOINTS config.

Return type:

dict

get_nelect(structure)[source]#

Get the default number of electrons for a given structure.

Parameters:

structure (Structure) – A structure.

Returns:

Number of electrons for the structure.

Return type:

float