obackhouse / gdf

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

`RSGDF` does not match `pyscf` for some inputs #2

Open obackhouse opened 11 months ago

obackhouse 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

Originally posted by @abhishekkhedkar09 in https://github.com/obackhouse/gdf/issues/1#issuecomment-1843635266

obackhouse commented 11 months ago

Hotfixed in https://github.com/obackhouse/gdf/commit/21c3bbff5d40ce0da054060db6afbb03ce5fc1bd, my ft.ft_ao code has a bug somewhere so I've fallen back on the PySCF version for now.

obackhouse commented 11 months ago

i'll keep this open until i've made a proper fix