from ASE import Atom, ListOfAtoms
from Dacapo import Dacapo
from ASE.Utilities.Wannier.Wannier import Wannier
atoms = Dacapo.ReadAtoms('Benzene.nc')

calc = atoms.GetCalculator()
# Initialize the Wannier class
wannier = Wannier(numberofwannier=18,calculator=calc)

# Perform the localization with specified convergence criterion
wannier.Localize(tolerance=1.0e-8)


for n in range(0,wannier.GetNumberOfWannierFunctions()):
    wannier.WriteCube(n,'WF_'+str(n)+'.cube',real=True)


# Read the centers, (quicker than plotting the cube files)
for center in  wannier.GetCenters():
    print center

centers = wannier.GetCentersAsAtoms()

# plot centers together with atoms
from ASE.Visualization.VMD import VMD
VMD(atoms,centers)
