def DMC(dft_checkfile, output, nconfig=1000, start_from=None, S=None, client=None, npartitions=None, jastrow_kws=None, slater_kws=None, dmc_kws=None, accumulators=None): if dmc_kws is None: dmc_kws = {} mol, mf = pyqmc.recover_pyscf(dft_checkfile) if S is not None: mol = pyqmc.get_supercell(mol, np.asarray(S)) wf, _ = pyqmc.generate_wf(mol, mf, jastrow_kws=jastrow_kws, slater_kws=slater_kws) if start_from is not None: pyqmc.read_wf(wf, start_from) configs = pyqmc.initial_guess(mol, nconfig) pyqmc.rundmc(wf, configs, accumulators=generate_accumulators(mol, mf, **accumulators), verbose=True, hdf_file=output, client=client, npartitions=npartitions, **dmc_kws)
def OPTIMIZE( dft_checkfile, output, anchors=None, nconfig=1000, ci_checkfile=None, start_from=None, S=None, client=None, npartitions=None, jastrow_kws=None, slater_kws=None, linemin_kws=None, ): if linemin_kws is None: linemin_kws = {} target_root = 0 if ci_checkfile is None: mol, mf = pyqmc.recover_pyscf(dft_checkfile) mc = None else: mol, mf, mc = pyqmc.recover_pyscf(dft_checkfile, ci_checkfile=ci_checkfile) mc.ci = mc.ci[target_root] if S is not None: mol = pyqmc.get_supercell(mol, np.asarray(S)) wf, to_opt = pyqmc.generate_wf(mol, mf, mc=mc, jastrow_kws=jastrow_kws, slater_kws=slater_kws) if start_from is not None: pyqmc.read_wf(wf, start_from) configs = pyqmc.initial_guess(mol, nconfig) acc = pyqmc.gradient_generator(mol, wf, to_opt) if anchors is None: pyqmc.line_minimization(wf, configs, acc, verbose=True, hdf_file=output, client=client, npartitions=npartitions, **linemin_kws) else: wfs = [pyqmc.read_wf(copy.deepcopy(wf), a) for a in anchors] wfs.append(wf) pyqmc.optimize_orthogonal( wfs, configs, acc, # verbose=True, hdf_file=output, client=client, npartitions=npartitions, **linemin_kws)
def OPTIMIZE( dft_checkfile, output, nconfig=1000, start_from=None, S=None, client=None, npartitions=None, jastrow_kws=None, slater_kws=None, linemin_kws=None, ): if linemin_kws is None: linemin_kws = {} mol, mf = pyqmc.recover_pyscf(dft_checkfile) if S is not None: mol = pyqmc.get_supercell(mol, np.asarray(S)) wf, to_opt = pyqmc.generate_wf(mol, mf, jastrow_kws=jastrow_kws, slater_kws=slater_kws) if start_from is not None: pyqmc.read_wf(wf, start_from) configs = pyqmc.initial_guess(mol, nconfig) acc = pyqmc.gradient_generator(mol, wf, to_opt) pyqmc.line_minimization(wf, configs, acc, verbose=True, hdf_file=output, client=client, npartitions=npartitions, **linemin_kws)
def VMC( dft_checkfile, output, nconfig=1000, ci_checkfile=None, start_from=None, S=None, client=None, npartitions=None, jastrow_kws=None, slater_kws=None, vmc_kws=None, accumulators=None, ): if vmc_kws is None: vmc_kws = {} target_root = 0 if ci_checkfile is None: mol, mf = pyqmc.recover_pyscf(dft_checkfile) mc = None else: mol, mf, mc = pyqmc.recover_pyscf(dft_checkfile, ci_checkfile=ci_checkfile) mc.ci = mc.ci[target_root] if S is not None: print("S", S) mol = pyqmc.get_supercell(mol, np.asarray(S)) if accumulators is None: accumulators = {} wf, _ = pyqmc.generate_wf(mol, mf, mc=mc, jastrow_kws=jastrow_kws, slater_kws=slater_kws) if start_from is not None: pyqmc.read_wf(wf, start_from) configs = pyqmc.initial_guess(mol, nconfig) pyqmc.vmc(wf, configs, accumulators=generate_accumulators(mol, mf, **accumulators), verbose=True, hdf_file=output, client=client, npartitions=npartitions, **vmc_kws)
def test(): chkfile = "h2.hdf5" optfile = "linemin.hdf5" run_scf(chkfile) mol, mf = pyqmc.recover_pyscf(chkfile) noise = (np.random.random(mf.mo_coeff.shape) - 0.5) * 0.2 mf.mo_coeff = mf.mo_coeff * 1j + noise slater_kws = {"optimize_orbitals": True} wf, to_opt = pyqmc.generate_wf(mol, mf, slater_kws=slater_kws) configs = pyqmc.initial_guess(mol, 100) acc = pyqmc.gradient_generator(mol, wf, to_opt) pyqmc.line_minimization(wf, configs, acc, verbose=True, hdf_file=optfile, max_iterations=5) assert os.path.isfile(optfile) os.remove(chkfile) os.remove(optfile)