I am a newbie using VASP, currently I am trying to calculate the formation energy per atom and pre bandgap using dft with VSAP.
I wrote script for calculating the bandgap
# -*- coding: utf-8 -*-
from ase.io import read
from ase.calculators.vasp import Vasp
from ase.optimize import BFGS
import numpy as np
import os
os.environ['VASP_PP_PATH'] = '/scratch'
# Load the structure from a CIF file
structure = read('mp-1218989.cif')
# Set up VASP calculator for relaxation
calc_relax = Vasp(xc='PBE', # Exchange-correlation functional
encut=400, # Plane-wave cutoff
kpts=(3, 3, 3), # k-point grid for relaxation
ibrion=2, # Ion relaxation: CG algorithm
nsw=50, # Number of steps for ionic relaxation
ismear=0, # Gaussian smearing
sigma=0.05, # Width of smearing in eV
lreal='Auto', # Use real-space projection for GPU acceleration
command='mpirun -np 1 vasp_gpu') # VASP run command
# Attach the calculator to the structure for relaxation
structure.set_calculator(calc_relax)
# Optimize the structure
opt = BFGS(structure)
opt.run(fmax=0.01)
# Now setting up the NSCF calculation for band structure
calc_nscf = Vasp(xc='PBE', # Exchange-correlation functional
encut=400, # Plane-wave cutoff
kpts=(11, 11, 11), # denser k-point mesh for band structure
ismear=0, # Gaussian smearing (must use ISMEAR < -1 or 0)
sigma=0.05,
ibrion=-1, # No ionic relaxation
nsw=0, # No ionic steps
icharg=11, # Non-self-consistent field run
command='mpirun -np 1 vasp_gpu')
# Attach the non-self-consistent calculator
structure.set_calculator(calc_nscf)
# Calculate the electronic structure (no need to run optimize)
structure.calc.calculate(structure)
# Extract eigenvalues
eigenvalues = structure.calc.get_eigenvalues(kpt=0, spin=0) # For the first k-point and spin
# Calculate bandgap
occupied = np.max(eigenvalues[eigenvalues < 0])
unoccupied = np.min(eigenvalues[eigenvalues > 0])
bandgap = unoccupied - occupied
print('Bandgap (PBE):', bandgap, 'eV')
I still didn’t figured out how to calculate the formation energy
The above code is not utilising the gpu properly, I have tried to increase the value here mpirun -np 1 vasp_gpu
to more than 1 but its just showing my system is not capable, but cleary I have 2 gpus and 20 cpus in my system.
- I am planning to perfom this on 100 molecules so any better method ?
please help if any one knows simple method to automate the calculation of the properties using vasp