obackhouse / gdf

Gaussian density fitting for periodic solids
0 stars 1 forks source link

getting TypeError: KPoints.__array__() takes 1 positional argument but 2 were given #1

Closed abhishekkhedkar09 closed 11 months ago

abhishekkhedkar09 commented 11 months ago

Here's my input:

import numpy as np
import pyscf, pyscf.pbc, vayesta, vayesta.ewf
from pyscf.pbc.gto import Cell
from pyscf.pbc import scf as pbcscf
from vayesta.misc import solids

mortyscratch = "/scratch/grp/morty/k2262473"
basis, pseudo = "gth-dzvp-molopt-sr","gth-pade"
kmesh = [2,2,2]

cell = Cell()
cell.a, cell.atom = solids.diamond(atoms=["Si", "Si"], a=5.31)
cell.basis = basis

cell.verbose = 5
if pseudo is not None:
    cell.pseudo = pseudo
cell.exp_to_discard = 0.1
cell.build()
kpts = cell.make_kpts(kmesh)
mf = pbcscf.KUHF(cell, kpts)
mf = mf.rs_density_fit()
mf.kernel()

mf_  = pbcscf.KUHF(cell, kpts)
from gdf import RSGDF
df = RSGDF(cell, kpts)
df.build()

mf_.with_df = df
mf_.kernel()

With the above output, I get the following error, am I missing something? getting the same error for RSGDF, CCGDF, for KUHF as well as KRHF:

          |    * pygnme      v1.0.0     location: /users/k2262473/dev/pygnme/pygnme
          |  Git hashes:
          |    * Vayesta:  ec027524
          |    * PySCF:    e90d8342e
          |    * EBCC:     cec2afd
          |  System:  node= erc-hpc-comp062  processor= x86_64
          |  Environment variables:
          |    OMP_NUM_THREADS= 16
Traceback (most recent call last):
  File "/users/k2262473/Calculations/Si/testing_OB_GDF/RSGDF/gthbasis/k222/arrinput.py", line 70, in <module>
    mf_.kernel()
  File "<string>", line 2, in kernel
  File "/users/k2262473/dev/optimized_pyscf/pyscf/pyscf/scf/hf.py", line 1726, in scf
    kernel(self, self.conv_tol, self.conv_tol_grad,
  File "/users/k2262473/dev/optimized_pyscf/pyscf/pyscf/scf/hf.py", line 180, in kernel
    mo_occ = mf.get_occ(mo_energy, mo_coeff)
  File "/users/k2262473/dev/optimized_pyscf/pyscf/pyscf/pbc/scf/khf.py", line 206, in get_occ
    for k,kpt in enumerate(mf.cell.get_scaled_kpts(mf.kpts)):
  File "/users/k2262473/dev/optimized_pyscf/pyscf/pyscf/pbc/gto/cell.py", line 1705, in get_scaled_kpts
    return 1./(2*np.pi)*np.dot(abs_kpts, self.lattice_vectors().T)
TypeError: KPoints.__array__() takes 1 positional argument but 2 were given
obackhouse commented 11 months ago

Should be fixed on https://github.com/obackhouse/gdf/commit/3d57f60bb99f92c3aa8aa40ed19ed09232aa0839 -- can you test correctness? it's hitting the KPoints.__array__ interface and not sure if that's covered by tests, would be nice to know if everything is still good.

abhishekkhedkar09 commented 11 months ago

I checked with a similar input... I get different energies from pyscf ones..

print(mf.e_tot, mf_.e_tot, mf.converged, mf_.converged)
-7.565857404732421 -7.907788012100459 True True

here's my input

import numpy as np
import pyscf, pyscf.pbc, vayesta, vayesta.ewf
from pyscf.pbc.gto import Cell
from pyscf.pbc import scf as pbcscf
from vayesta.misc import solids

mortyscratch = "/scratch/grp/morty/k2262473"
basis, pseudo = "gth-dzvp-molopt-sr", "gth-pade"
kmesh = [2, 2, 2]

cell = Cell()
cell.a, cell.atom = solids.diamond(atoms=["Si", "Si"], a=5.31)
cell.basis = basis

cell.verbose = 5
if pseudo is not None:
    cell.pseudo = pseudo
cell.exp_to_discard = 0.1
cell.build()

kpts = cell.make_kpts(kmesh)
mf = pbcscf.KUHF(cell, kpts)
mf = mf.rs_density_fit(auxbasis="weigend")
mf.max_cycle = 200
mf.kernel()

mf_ = pbcscf.KUHF(cell, kpts)
from gdf import RSGDF

df = RSGDF(cell, kpts, auxbasis="weigend")
df.build()

mf_.with_df = df
mf_.max_cycle = 200
mf_.kernel()

if not mf_.converged:
    mf_ = mf_.newton()
    mf_.kernel(mf_.make_rdm1())
print(mf.e_tot, mf_.e_tot, mf.converged, mf_.converged)

with open("pyscf_RSGDF", "w") as f:
    f.write(f"With_df_dict={mf.with_df.__dict__}\n")
    f.write(f"mfdict={mf.__dict__}\n")
with open("gdf_RSGDF", "w") as f:
    f.write(f"With_df_dict={mf_.with_df.__dict__}\n")
    f.write(f"mfdict={mf_.__dict__}\n")

pyscf_RSGDF.txt gdf_RSGDF.txt

obackhouse commented 11 months ago

Ok, that's a much bigger issue. Will look into it, thanks

obackhouse commented 11 months ago

Closing this as the original issue is now fixed, opened a new issue for your comment in #2