Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)