LCHARG = True
and LAECHG = True
to run a Bader analysis. The former writes the CHGCAR
and the latter writes the AECCAR
files.PATH
on Princeton Research Computing machines after loading the VASP module.chgsum.pl AECCAR0 AECCAR2bader CHGCAR -ref CHGCAR_sum
ACF.dat
. You can delete the CHGCAR_sum
file when you are done running the executable.crystal CONTCARload AECCAR0load AECCAR2load as "$1+$2"reference 3load CHGCARintegrable 4yt
POTCAR
. For instance, if you run a calculation with the Br
pseudopotential, you will see in the POTCAR
file that it has 7 electrons treated as valence. Therefore, a Bader charge of 8.0 would indicate that the Br atom has a net charge of -1.from ase.io import read, writeimport numpy as npbader_charges = np.loadtxt("ACF.dat", skiprows = 2, usecols=4).tolist()poscar = read("POSCAR")#grabs line 7, which has the number of each type of elementwith open('POSCAR', 'r') as f:lines = f.readlines()line7 = lines[6].strip()line6 = lines[5].strip()#splits the line up by double space delinerelement_counts = line7.split(' ')elements = line6.split(' ')with open('POTCAR', 'r') as f:potcar_lines = f.readlines()#creates a dictionary of lists (for each element type in POSCAR)partials = {}for el in elements:partials[el] = []valance_electrons = []#gets # of valance electrons for each element from each potcarfor i, line in enumerate(potcar_lines):if "parameters from" in line:valance_electrons.append(potcar_lines[i - 1].strip())#iterates through each element typefor i, el in enumerate(element_counts):#creates a list of all the popped bader charges of a given element typepopped = []for j in range(int(el)):popped.append(bader_charges.pop(0))#iterates through popped bader charges and subtracts the valance electronspartial_charges = []for j in popped:partial_charges.append(j - float(valance_electrons[i]))#replaces empty lists with lists of partial charges for each atompartials[f"{elements[i]}"] = partial_charges