How to use the pyqmc.multiplywf.MultiplyWF function in pyqmc

To help you get started, we’ve selected a few pyqmc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WagnerGroup / pyqmc / tests / test_derivatives.py View on Github external
from pyqmc.slateruhf import PySCFSlaterUHF
    from pyqmc.jastrowspin import JastrowSpin
    from pyqmc.multiplywf import MultiplyWF
    from pyqmc.coord import OpenConfigs
    import pyqmc

    mol = gto.M(atom="Li 0. 0. 0.; H 0. 0. 1.5", basis="cc-pvtz", unit="bohr")
    mf = scf.RHF(mol).run()
    mf_rohf = scf.ROHF(mol).run()
    mf_uhf = scf.UHF(mol).run()
    epsilon = 1e-4
    nconf = 10
    epos = pyqmc.initial_guess(mol, nconf)
    for wf in [
        JastrowSpin(mol),
        MultiplyWF(PySCFSlaterUHF(mol, mf), JastrowSpin(mol)),
        PySCFSlaterUHF(mol, mf_uhf),
        PySCFSlaterUHF(mol, mf),
        PySCFSlaterUHF(mol, mf_rohf),
    ]:
        for k in wf.parameters:
            if k != "mo_coeff":
                wf.parameters[k] = np.random.rand(*wf.parameters[k].shape)
        for fname, func in zip(
            ["gradient", "laplacian", "pgradient"],
            [
                testwf.test_wf_gradient,
                testwf.test_wf_laplacian,
                testwf.test_wf_pgradient,
            ],
        ):
            err = []
github WagnerGroup / pyqmc / tests / unit / test_ecp_cutoff.py View on Github external
atom="""C 0 0 0 
       C 1 0 0 
    """,
        ecp="bfd",
        basis="bfd_vtz",
    )
    mf = scf.RHF(mol).run()
    nconf = 1000
    coords = initial_guess(mol, nconf)
    thresholds = [1e15, 100, 50, 20, 10, 5, 1]
    label = ["S", "J", "SJ"]
    ind = 0
    for wf in [
        PySCFSlater(mol, mf),
        JastrowSpin(mol),
        MultiplyWF(PySCFSlater(mol, mf), JastrowSpin(mol)),
    ]:
        wf.recompute(coords)
        print(label[ind])
        ind += 1
        for threshold in thresholds:
            eacc = EnergyAccumulator(mol, threshold)
            start = time.time()
            eacc(coords, wf)
            end = time.time()
            print("Threshold=", threshold, np.around(end - start, 2), "s")
    mc = mcscf.CASCI(mf, ncas=4, nelecas=(2, 2))
    mc.kernel()

    label = ["MS"]
    ind = 0
    for wf in [MultiSlater(mol, mf, mc)]:
github WagnerGroup / pyqmc / tests / test_derivatives.py View on Github external
from pyqmc.multiplywf import MultiplyWF
    from pyqmc.coord import OpenConfigs
    import pyqmc

    mol = gto.M(
        atom="H 0. 0. 0.; H 1. 1. 1.", basis="sto-3g", unit="bohr", a=np.eye(3) * 4
    )
    mf = scf.KRKS(mol).run()
    # mf_rohf = scf.KROKS(mol).run()
    # mf_uhf = scf.KUKS(mol).run()
    epsilon = 1e-5
    nconf = 10
    supercell = get_supercell(mol, S=np.eye(3))
    epos = pyqmc.initial_guess(supercell, nconf)
    for wf in [
        MultiplyWF(PySCFSlaterPBC(supercell, mf), JastrowSpin(mol)),
        PySCFSlaterPBC(supercell, mf),
        # PySCFSlaterPBC(supercell, mf_uhf),
        # PySCFSlaterPBC(supercell, mf_rohf),
    ]:
        for k in wf.parameters:
            if k != "mo_coeff":
                wf.parameters[k] = np.random.rand(*wf.parameters[k].shape)
        for fname, func in zip(
            ["gradient", "laplacian", "pgradient"],
            [
                testwf.test_wf_gradient,
                testwf.test_wf_laplacian,
                testwf.test_wf_pgradient,
            ],
        ):
            err = []
github WagnerGroup / pyqmc / pyqmc / __init__.py View on Github external
def default_sj(mol, mf, optimize_orbitals=False, twist=None, **jastrow_kws):
    wf1, to_opt1 = default_slater(mol, mf, optimize_orbitals, twist)
    wf2, to_opt2 = default_jastrow(mol, **jastrow_kws)
    wf = MultiplyWF(wf1, wf2)
    to_opt = {"wf1" + x: opt for x, opt in to_opt1.items()}
    to_opt.update({"wf2" + x: opt for x, opt in to_opt2.items()})

    return wf, to_opt
github WagnerGroup / pyqmc / pyqmc / optsr.py View on Github external
mol = gto.M(atom="H 0. 0. 0.; H 0. 0. 1.5", basis="cc-pvtz", unit="bohr", verbose=5)
    mf = scf.RHF(mol).run()
    nconf = 2500
    nsteps = 70
    warmup = 20

    coords = initial_guess(mol, nconf)
    basis = {
        "wf2coeff": [
            GaussianFunction(0.2),
            GaussianFunction(0.4),
            GaussianFunction(0.6),
        ]
    }
    wf = MultiplyWF(PySCFSlaterRHF(mol, mf), Jastrow2B(mol, basis["wf2coeff"]))
    params0 = {"wf2coeff": np.array([-0.8, -0.2, 0.4])}
    for k, p in wf.parameters.items():
        if k in params0:
            wf.parameters[k] = params0[k]

    energy_acc = EnergyAccumulator(mol)
    pgrad_acc = PGradTransform(energy_acc, LinearTransform(wf.parameters))

    # Gradient descent
    wf, data = gradient_descent(
        wf,
        coords,
        pgrad_acc,
        vmcoptions={"nsteps": nsteps},
        warmup=warmup,
        step=0.5,
github WagnerGroup / pyqmc / pyqmc / __init__.py View on Github external
def default_msj(mol, mf, mc, tol=None, freeze_orb=None, ion_cusp=False):
    wf1, to_opt1 = default_multislater(mol, mf, mc, tol, freeze_orb)
    wf2, to_opt2 = default_jastrow(mol, ion_cusp)
    wf = MultiplyWF(wf1, wf2)
    to_opt = {"wf1" + x: opt for x, opt in to_opt1.items()}
    to_opt.update({"wf2" + x: opt for x, opt in to_opt2.items()})

    return wf, to_opt
github WagnerGroup / pyqmc / pyqmc / __init__.py View on Github external
if not isinstance(jastrow, list):
        jastrow = [jastrow]
        jastrow_kws = [jastrow_kws]

    if mc is None:
        wf1, to_opt1 = default_slater(mol, mf, **slater_kws)
    elif hasattr(mol, "a"):
        raise NotImplementedError("No defaults for multislater with PBCs")
    else:
        wf1, to_opt1 = default_multislater(mol, mf, mc, **slater_kws)

    pack = [jast(mol, **kw) for jast, kw in zip(jastrow, jastrow_kws)]
    wfs = [p[0] for p in pack]
    to_opts = [p[1] for p in pack]
    wf = MultiplyWF(wf1, *wfs)
    to_opt = {"wf1" + k: v for k, v in to_opt1.items()}
    for i, to_opt2 in enumerate(to_opts):
        to_opt.update({f"wf{i+2}" + k: v for k, v in to_opt2.items()})
    return wf, to_opt