Esempio n. 1
0
def test_hcn_iso_dimer(trans_opt, trans_memory):

    calc_kwargs = {
        "route": "PM6",
        "pal": 4,
        "mem": 1000,
    }
    def calc_getter():
        return Gaussian16(**calc_kwargs)

    geom = geom_from_library("hcn_iso_pm6_near_ts.xyz")
    geom.set_calculator(calc_getter())
    geoms = [geom, ]

    N_init = np.array(
        (0.6333, 0.1061, 0.5678, 0.171, 0.11, 0.3373, 0.0308, 0.1721, 0.282)
    )
    dimer_kwargs = {
        "max_step": 0.04,
        "dR_base": 0.01,
        "N_init": N_init,
        # "rot_opt": "mb",
        "trans_opt": trans_opt,
        "trans_memory": trans_memory,
        "angle_tol": 5,
        # "rot_f_thresh": 1e-4,
        # "rot_type": "direct",
        "f_thresh": 1e-4,
        "f_tran_mod": True,
        "multiple_translations": True,
    }
    dimer_result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    return dimer_result
Esempio n. 2
0
def test_anapotcbm():
    calc_getter = AnaPotCBM
    # geom = AnaPotCBM().get_geom((0.818, 0.2233, 0.0))
    geom = AnaPotCBM().get_geom((0.2, 0.2, 0.0))
    # geom = AnaPotCBM().get_geom((0.3, 0.3, 0.0))
    # geom = AnaPotCBM().get_geom((0.4, 0.4, 0.0))
    # geom = AnaPotCBM().get_geom((0.5, 0.2, 0.0))
    geom = AnaPotCBM().get_geom((0.9, 0.8, 0.0))
    # geom = AnaPotCBM().get_geom((0.8, 0.7, 0.0))
    # geom = AnaPotCBM().get_geom((0.65, 0.7, 0.0))
    w, v = np.linalg.eigh(geom.hessian)
    print("eigenvals", w)
    N_imag = v[:,0]
    geoms = [geom, ]
    dimer_kwargs = {
        "ana_2dpot": True,
        "N_init": N_imag,
        "rot_type": "fourier",
        "trans_opt": "lbfgs",
        "f_tran_mod": False,
    }
    true_ts = (0, 0)
    dimer_result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    dimer_cycles = dimer_result.dimer_cycles
    plot_dimer_cycles(dimer_cycles[-10:], pot=AnaPotCBM(), true_ts=true_ts)
Esempio n. 3
0
def test_anapot(trans_opt, trans_memory):
    geoms = get_geoms()
    calc_getter = AnaPot
    dimer_kwargs = {
        "ana_2dpot": True,
        "restrict_step": "max",
        "angle_tol": 0.5,
        "f_thresh": 1e-4,
        "rot_opt": "mb",
        "trans_opt": trans_opt,
        "trans_memory": trans_memory,
        "f_tran_mod": False,
        # "multiple_translations": True,
    }
    result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    return result
Esempio n. 4
0
def test_anapot_rot():
    geoms = get_geoms()
    calc_getter = AnaPot
    dimer_kwargs = {
        "ana_2dpot": True,
        "restrict_step": "max",
        "angle_tol": 0.5,
        "f_thresh": 1e-4,
        "rot_opt": "mb",
        "f_tran_mod": False,
        "rot_type": "direct",
        # "rot_f_thresh": 0.1,
        "multiple_translations": False,
        # "max_cycles": 1,
    }
    result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    return result
def test_baker_ts_dimer(name, geom, charge, mult, ref_energy):
    print(f"@Got geom '{name}'")
    # Load initial dimers
    N_init_dict = make_N_init_dict()

    calc_kwargs = {
        "charge": charge,
        "mult": mult,
        "pal": 2,
        "base_name": Path(name).stem,
    }

    def calc_getter():
        return PySCF(basis="321g", **calc_kwargs)

    # def calc_getter():
    # return Gaussian16(route="HF/3-21G", **calc_kwargs)
    geom.set_calculator(calc_getter())

    dimer_kwargs = {
        "max_step": 0.25,
        # 1e-2 Angstroem in bohr
        "dR_base": 0.0189,
        "rot_opt": "lbfgs",
        # "trans_opt": "mb",
        "trans_opt": "lbfgs",
        # "trans_memory": 10, # bad idea
        "angle_tol": 5,
        "f_thresh": 1e-3,
        "max_cycles": 50,
        "f_tran_mod": True,
        # "rot_type": "direct",
        "multiple_translations": True,
    }
    dimer_kwargs["N_init"] = N_init_dict[name]
    geoms = (geom, )
    results = dimer_method(geoms, calc_getter, **dimer_kwargs)

    same_energy = geom.energy == pytest.approx(ref_energy)
    print(f"@Same energy: {str(same_energy): >5}, {name}, "
          f"{results.force_evals} force evaluations")
    if not same_energy:
        do_final_hessian(geom)

    # This way pytest prints the actual values... instead of just the boolean
    assert geom.energy == pytest.approx(ref_energy)
Esempio n. 6
0
def test_baker_16():
    calc_kwargs = {
        "route": "HF/3-21G",
        "pal": 4,
        "mem": 1000,
        "charge": -1,
        "mult": 1,
    }
    def calc_getter():
        return Gaussian16(**calc_kwargs)
        # return XTB(**calc_kwargs)

    geom = geom_from_library("baker_ts/16_h2po4_anion.xyz")
    geom.set_calculator(calc_getter())
    geoms = [geom, ]

    downhill = geom_from_library("baker_ts/16_h2po4_anion_downhill.xyz")
    N_init = geom.coords - downhill.coords
    N_init /= np.linalg.norm(N_init)

    dimer_kwargs = {
        "max_step": 0.5,
        # 1e-2 Angstroem in bohr
        "dR_base": 0.0189,
        "rot_opt": "lbfgs",
        "trans_opt": "lbfgs",
        # "trans_opt": "mb",
        # "trans_memory": 10,
        "angle_tol": 5,
        "f_thresh": 1e-3,
        "max_cycles": 50,
        "f_tran_mod": True,
        "rot_type": "fourier",
        "multiple_translations": True,
        "N_init": N_init,
        "max_cycles": 15,
        "rot_f_thresh": 1.5e-3,
    }

    # 55 cycles; no multi trans, no f_tran_mod

    # import pdb; pdb.set_trace()
    dimer_result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    return dimer_result
Esempio n. 7
0
def test_anapot_cbm_rot():
    pot = AnaPot()
    geoms = (pot.get_geom((0.44, 1.54, 0)), )
    N_init = (-0.2, 1, 0)
    calc_getter = AnaPot
    dimer_kwargs = {
        "ana_2dpot": True,
        "restrict_step": "max",
        "angle_tol": 0.5,
        "f_thresh": 1e-4,
        "rot_opt": "lbfgs",
        "trans_opt": "lbfgs",
        "trans_memory": 5,
        "f_tran_mod": False,
        "N_init": N_init,
        "rot_f_thresh": 1e-2,
        # "multiple_translations": True,
    }
    result = dimer_method(geoms, calc_getter, **dimer_kwargs)
    true_ts = (0.61173, 1.49297, 0.)
    # plot_dimer_cycles(result.dimer_cycles, pot=AnaPot(), true_ts=true_ts[:2])
    return result