Critic2

Example

 Critic2  is a code to do charge partitioning analyses. I put a copy on Tiger, which is already included in your PATH by calling critic2, but it is trivial to install on any of the supercomputers. The Critic2 code can be run interactively or with an input file that has a .cri extension (i.e. critic2 filename.cri).
An example .cri file is shown below that will integrate the charge density in all ELF basins with non-nuclear maxima that are at least 2.5 bohr units away from the nearest atom. It will also output a criticals.xyz file showing where all the non-nuclear maxima are located. You may need to tune the value of ratom to only get critical points in the void spaces of interest, or you can simply manually pick out the entries of interest in the output as needed. For more information, read the YT  keyword documentation .
crystal CONTCAR
load ELFCAR id elf
load CHGCAR id rho
reference elf
integrable rho
yt nnm ratom 2.5
cpreport criticals.xyz
When you run the above example. the $rho column in the output will show the integrated charge in each basin. The basins marked with ?? are not associated with a given atom. If you're unsure which basin corresponds to what, add wcube to the yt command to output .cube files for each basin that can be viewed in a program like VESTA.
If needed, the criticals.xyz file can be rewritten as a .cif with periodic boundary conditions as follows:
from ase.io import read, write

with open("criticals.xyz", "r") as f:
content = f.read()

content = content.replace("Xn", "X")
with open("criticals.xyz", 'w') as f:
f.write(content)

atoms = read("CONTCAR")
criticals = read("criticals.xyz")
criticals.pbc = True
criticals.cell = atoms.cell
write("criticals.cif", criticals)