WagnerGroup / pyqmc

Python library for real space quantum Monte Carlo
MIT License
81 stars 33 forks source link

Unexpected kpts property generated by RKS() leading to UnboundLocalError in determinant_tools.py #409

Open cychow2 opened 8 months ago

cychow2 commented 8 months ago

With the lastest version (2.4.0) of pyscf, running RKS() results in a mf object with property kpts, which causes an UnboundLocalError in determinant_tools.py when generating a wf

Minimal example to reproduce the error:

import pyscf.pbc
import numpy as np 
import pyscf.pbc.dft
cell = pyscf.pbc.gto.Cell()
cell.atom = '''C     0.      0.      0.    
              C     0.8917  0.8917  0.8917
              C     1.7834  1.7834  0.    
              C     2.6751  2.6751  0.8917
              C     1.7834  0.      1.7834
              C     2.6751  0.8917  2.6751
              C     0.      1.7834  1.7834
              C     0.8917  2.6751  2.6751'''
cell.basis = 'ccecp-ccpvdz'
cell.ecp = 'ccecp'
cell.exp_to_discard = 0.2
cell.a = np.eye(3)*3.5668
cell.verbose=3
cell.build()
mf  = pyscf.pbc.dft.KRKS(cell).density_fit()
mf.kernel()

wf, to_opt = pyq.generate_wf(cell, mf)

The error:

File [~/compiled](https://file+.vscode-resource.vscode-cdn.net/Users/chow/research/orbital_eval/~/compiled) library/pyqmc/pyqmc/wftools.py:28, in generate_slater(mol, mf, optimize_determinants, optimize_orbitals, optimize_zeros, epsilon, **kwargs)
     12 def generate_slater(
     13     mol,
     14     mf,
...
    141     occupation[s][ka].remove(a)
    142     occupation[s][ki].append(i)
--> 143 return occupation

UnboundLocalError: cannot access local variable 'occupation' where it is not associated with a value