Using ASE to run VASP

ASE

If you are learning to use the  Atomic Simulation Environment  ( ASE ), the following script can be used to carry out the same calculation as in  Exercise: Comparing Fe Polymorphs . A submission script can be found in  🔔Submitting Jobs .

Fe.cif
816Bytes, Uploaded 3 weeks ago

Regular Approach

from ase.calculators.vasp import Vasp
from ase.io import read

# Read in the structure to make an Atoms object
atoms = read("Fe.cif")

# Set up the VASP calculator
calc = Vasp(
encut=520, # plane-wave kinetic energy cutoff (convergence parameter)
kpts=[10, 10, 10], # k-points in each dimension
xc="PBE", # exchange-correlation functional ("level of theory"); sets GGA = PE here
algo="fast", # SCF convergence algorithm
ediff=1e-5, # SCF convergence criterion (eV)
ismear=0, # smearing method (0 = Gaussian smearing)
sigma=0.05, # smearing width (eV)
lasph=True, # non-spherical corrections for 3d elements
prec="accurate", # high-precision calculations
ediffg=-0.03, # relaxation convergence criterion (eV/A)
ibrion=2, # relaxation algorithm (2 = conjugate-gradient)
isif=3, # relaxation degrees of freedom (3 = relax positions+cell shape+cell volume)
nsw=100, # maximum number of relaxation steps
lorbit=11, # print out magnetic moments
)

# Set the calculator for the Atoms object
atoms.calc = calc

# Set the initial magnetic moments (will auto-set ISPIN and MAGMOM)
atoms.set_initial_magnetic_moments([4.0, 4.0])

# Run the VASP calculation
atoms.get_potential_energy()

Supercharged Calculator

A modified version of the Vasp calculator is available with the  quacc package . It serves as (mostly) a drop-in replacement for the ASE calculator and comes with several benefits, including: 1) Useful automatic updates to input parameters via the "incar copilot"; 2) Automated error correction handling via  Custodian ; 3) Several additional keyword arguments to simplify calculator setup. In general, there is no reason not to use this supercharged calculator.
To use the quacc-based Vasp calculator, simply replace from ase.calculators.vasp import Vasp with from quacc.calculators.vasp import Vasp. You can use all the same ASE Vasp calculator input arguments except now the first positional argument to the calculator is the Atoms object. For instance:
from quacc.calculators.vasp import Vasp
from ase.io import read

# Read in the structure to make an Atoms object
atoms = read("Fe.cif")

# Set up the VASP calculator
calc = Vasp(
atoms, # input Atoms object
encut=520, # plane-wave kinetic energy cutoff (convergence parameter)
kpts=[10, 10, 10], # k-points in each dimension
xc="PBE", # exchange-correlation functional ("level of theory"); sets GGA = PE here
algo="fast", # SCF convergence algorithm
ediff=1e-5, # SCF convergence criterion (eV)
ismear=0, # smearing method (0 = Gaussian smearing)
sigma=0.05, # smearing width (eV)
lasph=True, # non-spherical corrections for 3d elements
prec="accurate", # high-precision calculations
ediffg=-0.03, # relaxation convergence criterion (eV/A)
ibrion=2, # relaxation algorithm (2 = conjugate-gradient)
isif=3, # relaxation degrees of freedom (3 = relax positions+cell shape+cell volume)
nsw=100, # maximum number of relaxation steps
lorbit=11, # print out magnetic moments
)

# Set the calculator for the Atoms object
atoms.calc = calc

# Set the initial magnetic moments (will auto-set ISPIN and MAGMOM)
atoms.set_initial_magnetic_moments([4.0, 4.0])

# Run the VASP calculation
atoms.get_potential_energy()