def main(args): """Convert FCIDUMP to QMCPACK readable Hamiltonian format. Parameters ---------- args : list of strings command-line arguments. """ options = parse_args(args) (hcore, eri, ecore, nelec) = read_fcidump(options.input_file, symmetry=options.symm, verbose=options.verbose) norb = hcore.shape[-1] # If the ERIs are complex then we need to form M_{(ik),(lj}} which is # Hermitian. For real integrals we will have 8-fold symmetry so trasposing # will have no effect. eri = numpy.transpose(eri, (0, 1, 3, 2)) chol = modified_cholesky(eri.reshape(norb**2, norb**2), options.thresh, options.verbose, cmax=20).T.copy() cplx_chol = options.write_complex or numpy.any(abs(eri.imag) > 1e-14) write_qmcpack_dense(hcore, chol, nelec, norb, enuc=ecore, real_chol=(not cplx_chol), filename=options.output_file)
def dump_pauxy(chkfile=None, mol=None, mf=None, hamil_file='afqmc.h5', verbose=True, wfn_file='afqmc.h5', chol_cut=1e-5, sparse_zero=1e-16, cas=None, ortho_ao=True, sparse=False): scf_data = load_from_pyscf_chkfile(chkfile) mol = scf_data['mol'] hcore = scf_data['hcore'] if ortho_ao: oao = scf_data['X'] else: oao = scf_data['mo_coeff'] hcore, chol, nelec, enuc = generate_integrals(mol, hcore, oao, chol_cut=chol_cut, verbose=verbose, cas=cas) nbasis = hcore.shape[-1] msq = nbasis * nbasis # Why did I transpose everything? # QMCPACK expects [M^2, N_chol] # Internally store [N_chol, M^2] chol = chol.T.copy() if sparse: print(" # Writing integrals in sparse format.") write_qmcpack_sparse(hcore, chol, nelec, nbasis, enuc, filename=hamil_file, real_chol=True, verbose=verbose, ortho=oao) else: print(" # Writing integrals in dense format.") write_qmcpack_dense(hcore, chol, nelec, nbasis, enuc, filename=hamil_file, ortho=oao, real_chol=True) write_wfn_mol(scf_data, ortho_ao, wfn_file, mode='a')
def write_integrals(self, filename='hamil.h5'): if self.sparse: write_qmcpack_sparse(self.H1[0], self.chol_vecs.reshape( (-1, self.nbasis * self.nbasis)).T.copy(), self.nelec, self.nbasis, ecuc=self.ecore, filename=filename) else: write_qmcpack_dense(self.H1[0], self.chol_vecs.reshape( (-1, self.nbasis * self.nbasis)).T.copy(), self.nelec, self.nbasis, enuc=self.ecore, filename=filename, real_chol=not self.cplx_chol)
def test_read(): numpy.random.seed(7) nmo = 13 nelec = (4, 3) h1e, chol, enuc, eri = generate_hamiltonian(nmo, nelec, cplx=True, sym=4) from pauxy.utils.io import write_qmcpack_dense chol_ = chol.reshape((-1, nmo * nmo)).T.copy() write_qmcpack_dense(h1e, chol_, nelec, nmo, enuc=enuc, filename='hamil.h5', real_chol=False) options = {'nup': nelec[0], 'ndown': nelec[1], 'integrals': 'hamil.h5'} sys = Generic(inputs=options) schol = sys.chol_vecs assert numpy.linalg.norm(chol - schol) == pytest.approx(0.0)
write_input ) mol = gto.M(atom=[('N', 0, 0, 0), ('N', (0,0,3.0))], basis='sto-3g', verbose=3, unit='Bohr') mf = scf.RHF(mol) mf.chkfile = 'scf.chk' ehf = mf.kernel() M = 6 N = 6 mc = mcscf.CASSCF(mf, M, N) mc.chkfile = 'scf.chk' mc.kernel() e_tot, e_cas, fcivec, mo, mo_energy = mc.kernel() print(ehf, e_tot) # Rotate by casscf mo coeffs. h1e, chol, nelec, enuc = generate_integrals(mol, mf.get_hcore(), mo, chol_cut=1e-5, verbose=True) write_qmcpack_dense(h1e, chol.T.copy(), nelec, h1e.shape[-1], enuc=enuc, filename='afqmc.h5') coeff, occa, occb = zip(*fci.addons.large_ci(fcivec, M, (3,3), tol=0.1, return_strs=False)) core = [i for i in range(mc.ncore)] occa = [numpy.array(core + [o + mc.ncore for o in oa]) for oa in occa] occb = [numpy.array(core + [o + mc.ncore for o in ob]) for ob in occb] coeff = numpy.array(coeff,dtype=numpy.complex128) nmo = mf.mo_coeff.shape[-1] write_qmcpack_wfn('afqmc.h5', (coeff,occa,occb), 'uhf', mol.nelec, nmo, mode='a') write_input('input.json', 'afqmc.h5', 'afqmc.h5', options={'system': {'sparse': False}})