Skip to content

vasp

A wrapper around ASE's Vasp calculator that makes it better suited for high-throughput DFT.

Vasp

Vasp(
    input_atoms: Atoms,
    preset: None | str = None,
    use_custodian: bool = _DEFAULT_SETTING,
    incar_copilot: Literal[
        "off", "on", "aggressive"
    ] = _DEFAULT_SETTING,
    copy_magmoms: bool = _DEFAULT_SETTING,
    preset_mag_default: float = _DEFAULT_SETTING,
    mag_cutoff: float = _DEFAULT_SETTING,
    elemental_magmoms: dict[str, float] | None = None,
    pmg_kpts: (
        dict[
            Literal["line_density", "kppvol", "kppa"], float
        ]
        | dict[Literal["length_densities"], list[float]]
        | None
    ) = None,
    auto_dipole: bool | None = None,
    **kwargs
)

Bases: Vasp

This is a wrapper around the ASE Vasp calculator that adjusts INCAR parameters on-the-fly, allows for ASE to run VASP via Custodian, and supports several automatic k-point generation schemes from Pymatgen.

Parameters:

  • input_atoms (Atoms) –

    The input Atoms object to be used for the calculation.

  • preset (None | str, default: None ) –

    The name of a YAML file containing a list of INCAR parameters to use as a "preset" for the calculator. quacc will automatically look in the VASP_PRESET_DIR (default: quacc/calculators/vasp/presets) for the file, such that preset="BulkSet" is supported, for instance. The .yaml extension is not necessary. Any user-supplied calculator **kwargs will override any corresponding preset values.

  • use_custodian (bool, default: _DEFAULT_SETTING ) –

    Whether to use Custodian to run VASP. Default is True in settings.

  • incar_copilot (Literal['off', 'on', 'aggressive'], default: _DEFAULT_SETTING ) –

    Controls VASP co-pilot mode for automated INCAR parameter handling. Options include: off: Do not use co-pilot mode. INCAR parameters will be unmodified. on: Use co-pilot mode. This will only modify INCAR flags not already set by the user. aggressive: Use co-pilot mode in aggressive mode. This will modify INCAR flags even if they are already set by the user.

  • copy_magmoms (bool, default: _DEFAULT_SETTING ) –

    If True, any pre-existing atoms.get_magnetic_moments() will be set in atoms.set_initial_magnetic_moments(). Set this to False if you want to use a preset's magnetic moments every time. Default is True in settings.

  • preset_mag_default (float, default: _DEFAULT_SETTING ) –

    Default magmom value for sites without one explicitly specified in the preset. Only used if a preset is specified with an elemental_mags_dict key-value pair. Default is 1.0 in settings.

  • mag_cutoff (float, default: _DEFAULT_SETTING ) –

    Set all initial magmoms to 0 if all have a magnitude below this value. Default is 0.05 in settings.

  • elemental_magmoms (dict[str, float] | None, default: None ) –

    A dictionary of elemental initial magnetic moments to pass to quacc.schemas.prep.set_magmoms, e.g. {"Fe": 5, "Ni": 4}.

  • pmg_kpts (dict[Literal['line_density', 'kppvol', 'kppa'], float] | dict[Literal['length_densities'], list[float]] | None, default: None ) –

    An automatic k-point generation scheme from Pymatgen. See quacc.utils.kpts.convert_pmg_kpts for details.

  • auto_dipole (bool | None, default: None ) –

    If True, will automatically set dipole moment correction parameters based on the center of mass (in the c dimension by default).

  • **kwargs

    Additional arguments to be passed to the VASP calculator, e.g. xc='PBE', encut=520. Takes all valid ASE calculator arguments.

Returns:

  • None
Source code in quacc/calculators/vasp/vasp.py
def __init__(
    self,
    input_atoms: Atoms,
    preset: None | str = None,
    use_custodian: bool = _DEFAULT_SETTING,
    incar_copilot: Literal["off", "on", "aggressive"] = _DEFAULT_SETTING,
    copy_magmoms: bool = _DEFAULT_SETTING,
    preset_mag_default: float = _DEFAULT_SETTING,
    mag_cutoff: float = _DEFAULT_SETTING,
    elemental_magmoms: dict[str, float] | None = None,
    pmg_kpts: (
        dict[Literal["line_density", "kppvol", "kppa"], float]
        | dict[Literal["length_densities"], list[float]]
        | None
    ) = None,
    auto_dipole: bool | None = None,
    **kwargs,
) -> None:
    """
    Initialize the VASP calculator.

    Parameters
    ----------
    input_atoms
        The input Atoms object to be used for the calculation.
    preset
        The name of a YAML file containing a list of INCAR parameters to use as
        a "preset" for the calculator. quacc will automatically look in the
        `VASP_PRESET_DIR` (default: quacc/calculators/vasp/presets) for the
        file, such that preset="BulkSet" is supported, for instance. The .yaml
        extension is not necessary. Any user-supplied calculator **kwargs will
        override any corresponding preset values.
    use_custodian
        Whether to use Custodian to run VASP. Default is True in settings.
    incar_copilot
        Controls VASP co-pilot mode for automated INCAR parameter handling.
        Options include:
        off: Do not use co-pilot mode. INCAR parameters will be unmodified.
        on: Use co-pilot mode. This will only modify INCAR flags not already set by the user.
        aggressive: Use co-pilot mode in aggressive mode. This will modify INCAR flags even if they are already set by the user.
    copy_magmoms
        If True, any pre-existing `atoms.get_magnetic_moments()` will be set in
        `atoms.set_initial_magnetic_moments()`. Set this to False if you want to
        use a preset's magnetic moments every time. Default is True in settings.
    preset_mag_default
        Default magmom value for sites without one explicitly specified in the
        preset. Only used if a preset is specified with an elemental_mags_dict
        key-value pair. Default is 1.0 in settings.
    mag_cutoff
        Set all initial magmoms to 0 if all have a magnitude below this value.
        Default is 0.05 in settings.
    elemental_magmoms
        A dictionary of elemental initial magnetic moments to pass to
        [quacc.schemas.prep.set_magmoms][], e.g. `{"Fe": 5, "Ni": 4}`.
    pmg_kpts
        An automatic k-point generation scheme from Pymatgen. See
        [quacc.utils.kpts.convert_pmg_kpts][] for details.
    auto_dipole
        If True, will automatically set dipole moment correction parameters
        based on the center of mass (in the c dimension by default).
    **kwargs
        Additional arguments to be passed to the VASP calculator, e.g.
        `xc='PBE'`, `encut=520`. Takes all valid ASE calculator arguments.

    Returns
    -------
    None
    """
    from quacc import SETTINGS

    # Set defaults
    use_custodian = (
        SETTINGS.VASP_USE_CUSTODIAN
        if use_custodian == _DEFAULT_SETTING
        else use_custodian
    )
    incar_copilot = (
        SETTINGS.VASP_INCAR_COPILOT
        if incar_copilot == _DEFAULT_SETTING
        else incar_copilot
    )
    copy_magmoms = (
        SETTINGS.VASP_COPY_MAGMOMS
        if copy_magmoms == _DEFAULT_SETTING
        else copy_magmoms
    )
    preset_mag_default = (
        SETTINGS.VASP_PRESET_MAG_DEFAULT
        if preset_mag_default == _DEFAULT_SETTING
        else preset_mag_default
    )
    mag_cutoff = (
        SETTINGS.VASP_MAG_CUTOFF if mag_cutoff == _DEFAULT_SETTING else mag_cutoff
    )

    # Assign variables to self
    self.input_atoms = input_atoms
    self.preset = preset
    self.use_custodian = use_custodian
    self.incar_copilot = incar_copilot
    self.copy_magmoms = copy_magmoms
    self.preset_mag_default = preset_mag_default
    self.mag_cutoff = mag_cutoff
    self.elemental_magmoms = elemental_magmoms
    self.pmg_kpts = pmg_kpts
    self.auto_dipole = auto_dipole
    self.kwargs = kwargs

    # Initialize for later
    self.user_calc_params = {}

    # Cleanup parameters
    self._cleanup_params()

    # Get VASP executable command, if necessary, and specify child
    # environment variables
    self.command = self._manage_environment()

    # Instantiate the calculator!
    super().__init__(
        atoms=self.input_atoms, command=self.command, **self.user_calc_params
    )

auto_dipole instance-attribute

auto_dipole = auto_dipole

command instance-attribute

command = _manage_environment()

copy_magmoms instance-attribute

copy_magmoms = copy_magmoms

elemental_magmoms instance-attribute

elemental_magmoms = elemental_magmoms

incar_copilot instance-attribute

incar_copilot = incar_copilot

input_atoms instance-attribute

input_atoms = input_atoms

kwargs instance-attribute

kwargs = kwargs

mag_cutoff instance-attribute

mag_cutoff = mag_cutoff

pmg_kpts instance-attribute

pmg_kpts = pmg_kpts

preset instance-attribute

preset = preset

preset_mag_default instance-attribute

preset_mag_default = preset_mag_default

use_custodian instance-attribute

use_custodian = use_custodian

user_calc_params instance-attribute

user_calc_params = {}