def test_augment_coordinates_silyl(augment, ref_cycle):
    geom = geom_from_library("baker_ts/18_silyene_insertion.xyz",
                             coord_type="redund")

    opt_kwargs = {
        "thresh": "baker",
        "max_cycles": 100,
        "dump": True,
        "trust_radius": 0.3,
        "trust_max": 0.3,
        "augment_bonds": augment,
    }
    calc_kwargs = {
        "charge": 0,
        "mult": 1,
        "pal": 4,
    }
    calc = PySCF(basis="321g", **calc_kwargs)

    geom.set_calculator(calc)

    opt = RSIRFOptimizer(geom, **opt_kwargs)
    opt.run()

    assert opt.is_converged
    assert opt.cur_cycle == ref_cycle

    ref_en = -367.20778
    assert opt.geometry.energy == pytest.approx(ref_en)
Exemplo n.º 2
0
def test_afir():
    """Example (R1) from
        https://aip.scitation.org/doi/pdf/10.1063/1.3457903?class=pdf

    See Fig. 2 and Fig. 4
    """

    geom = geom_loader("lib:ohch3f_anion_cs.xyz")
    # OH group is a fragment
    fragment_indices = [
        (5, 6),
    ]
    calc = PySCF(basis="6-31g*", xc="b3lyp", pal=2, charge=-1)
    gamma = 100
    afir = AFIR(calc, fragment_indices, gamma)
    geom.set_calculator(afir)

    opt = RFOptimizer(geom, dump=True, trust_max=.3)
    opt.run()

    assert opt.is_converged
    assert opt.cur_cycle == 47

    # Broken C-Cl bond
    c3d = geom.coords3d
    assert np.linalg.norm(c3d[0] - c3d[4]) == pytest.approx(4.805665, abs=1e-4)
    # Formed O-C bond
    assert np.linalg.norm(c3d[0] - c3d[5]) == pytest.approx(2.674330, abs=1e-4)
Exemplo n.º 3
0
 def calc_getter(calc_number):
     calc_kwargs = {
         "charge": +1,
         "mult": 1,
         "pal": 2,
         "basis": "321g",
         "calc_number": calc_number,
     }
     calc = PySCF(**calc_kwargs)
     return calc
Exemplo n.º 4
0
def test_baker_tsopt(name, results_bag):
    charge, mult, ref_energy = get_baker_ts_data()[name]
    geom = geom_loader(
        f"lib:baker_ts/{name}",
        coord_type="redund",
        coord_kwargs={
            "rebuild": True,
        },
    )
    # geom.jmol()
    calc_kwargs = {
        "charge": charge,
        "mult": mult,
        "pal": 1,
    }

    print(f"@Running {name}")
    geom.set_calculator(PySCF(basis="321g", **calc_kwargs))
    # geom.set_calculator(ORCA(keywords="HF 3-21G", **calc_kwargs))
    if geom.coord_type != "cart":
        geom = augment_bonds(geom)

    opt_kwargs = {
        "thresh": "baker",
        "max_cycles": 50,
        "trust_radius": 0.1,
        "trust_max": 0.3,
        "min_line_search": True,
        "max_line_search": True,
    }
    opt = RSPRFOptimizer(geom, **opt_kwargs)
    # opt = RSIRFOptimizer(geom, **opt_kwargs)
    # opt = TRIM(geom, **opt_kwargs)
    opt.run()

    # Without symmetry restriction this lower lying TS will be obtained.
    # if name.startswith("22_"):
        # ref_energy = -242.25695787

    results_bag.cycles = opt.cur_cycle + 1
    results_bag.is_converged = opt.is_converged
    results_bag.energy = geom.energy
    results_bag.ref_energy = ref_energy

    print(f"\t@Converged: {opt.is_converged}, {opt.cur_cycle+1} cycles")

    assert geom.energy == pytest.approx(ref_energy)
    print("\t@Energies match!")

    return opt.cur_cycle + 1
Exemplo n.º 5
0
def test_opt_load_save_hessian(this_dir):
    geom = geom_loader("lib:acetaldehyd.xyz", coord_type="redund")
    calc = PySCF(basis="321g", pal=2)
    geom.set_calculator(calc)

    opt_kwargs = {
        "hessian_recalc": 1,
        "hessian_init": this_dir / "inp_hess_calc_cyc_0.h5",
    }
    opt = RFOptimizer(geom, **opt_kwargs)
    opt.run()

    assert opt.is_converged
    assert opt.cur_cycle == 2
    assert geom.energy == pytest.approx(-152.05524620313963)
Exemplo n.º 6
0
def test_irc_load_save_hessian(this_dir):
    geom = geom_loader("lib:hcn_iso_hf_sto3g_ts_opt.xyz")
    calc = PySCF(basis="sto3g", pal=2)
    geom.set_calculator(calc)

    irc_kwargs = {
        "rms_grad_thresh": 1e-3,
        "hessian_init": this_dir / "inp_hess_init_irc.h5",
        "hessian_recalc": 2,
        "max_cycles": 5,
    }
    irc = EulerPC(geom, **irc_kwargs)
    irc.run()

    assert irc.forward_cycle == 5
    assert irc.backward_cycle == 5
def water():
    geom = geom_loader("lib:h2o.xyz")
    init_logging()
    calc_kwargs = {
        "xc": "pbe0",
        "method": "tddft",
        "basis": "sto3g",
        "nstates": 2,
        "root": 1,
        # OverlapCalculator specific
        "track": True,
        "cdds": "calc",
        "ovlp_type": "tden",
    }
    calc = PySCF(**calc_kwargs)
    geom.set_calculator(calc)
    return geom
Exemplo n.º 8
0
def test_diels_alder_neb(opt_cls):
    geoms = geom_from_library("diels_alder_interpolated.trj")
    for i, geom in enumerate(geoms):
        calc_kwargs = {
            "basis": "sto3g",
            "pal": 2,
            "calc_number": i,
        }
        calc = PySCF(**calc_kwargs)
        geom.set_calculator(calc)
    neb = NEB(geoms)

    opt_kwargs = {
        "dump": True,
        "align": True,
        "max_cycles": 15,
    }
    opt = opt_cls(neb, **opt_kwargs)
    opt.run()