Esempio n. 1
0
def test_run_dimer_irc():
    """Quick test to see if the Dimer method works well with
    the rest."""
    run_dict = {
        "opt": {
            "type": "plbfgs",
            "do_hess": True,
        },
        "irc": {
            "type": "imk",
            "rms_grad_thresh": 0.001,
        },
        "endopt": {
            "fragments": True,
        },
        "calc": {
            "type": "dimer",
            "calc": {
                "type": "pyscf",
                "basis": "321g",
                "pal": 2,
            }
        },
        "xyz": "lib:hcn_ts_hf_321g.xyz",
    }
    results = run_from_dict(run_dict)

    assert results.opt.is_converged
    assert results.irc.backward_is_converged
    assert results.irc.forward_is_converged
    hcn, cnh = results.end_geoms
    assert hcn.energy == pytest.approx(-92.33966200907034)
    assert cnh.energy == pytest.approx(-92.35408370090339)
Esempio n. 2
0
def test_hcn_neb():
    run_dict = {
        "preopt": {
            "max_cycles": 3,
        },
        "interpol": {
            "type": "idpp",
            "between": 3,
        },
        "cos": {
            "type": "neb",
        },
        "opt": {
            "type": "qm",
            "align": True,
        },
        "calc": {
            "type": "pyscf",
            "pal": 2,
            "basis": "321g",
        },
        "xyz": ["lib:hcn.xyz", "lib:hcn_iso_ts.xyz", "lib:nhc.xyz"]
    }
    results = run_from_dict(run_dict)

    assert results.cos_opt.is_converged
    assert results.cos_opt.cur_cycle == 18
Esempio n. 3
0
def test_endopt_barriers():
    run_dict = {
        "geom": {
            "type": "redund",
            "fn": "splined_hei.xyz",
        },
        "tsopt": {
            "type": "rsirfo",
        },
        "irc": {
            "type": "eulerpc",
            "rms_grad_thresh": 0.015,
        },
        "endopt": {
            "thresh": "gau_loose",
        },
        "calc": {
            "type": "xtb",
            "pal": 1,
        },
    }
    results = run_from_dict(run_dict)

    assert results.ts_opt.is_converged
    assert results.ts_opt.cur_cycle == 2
    assert results.ts_geom.energy == pytest.approx(-5.38737424)
Esempio n. 4
0
def test_diels_alder_growing_string():
    run_dict = {
        "preopt": {
            "max_cycles": 5,
        },
        "cos": {
            "type": "gs",
            "fix_ends": True,
            "max_nodes": 8,
            "reparam_check": "rms",
            "climb": True,
            "climb_rms": 0.02,
        },
        "opt": {
            "type": "string",
            "stop_in_when_full": 3,
        },
        "tsopt": {
            "type": "rsirfo",
            "do_hess": True,
            "hessian_recalc": 5,
        },
        "irc": {
            "type": "eulerpc",
            "corr_func": "scipy",
            "rms_grad_thresh": 2.5e-3,
        },
        "endopt": {
            "fragments": True,
        },
        "calc": {
            "type": "pyscf",
            "pal": 2,
            "basis": "321g",
        },
        "xyz": "lib:diels_alder_interpolated.trj",
        "coord_type": "dlc",
    }
    results = run_from_dict(run_dict)

    pprint(results)

    assert len(results.preopt_xyz) == 3
    assert isinstance(results.cos, ChainOfStates)
    assert results.cos_opt.is_converged
    assert results.ts_opt.is_converged
    assert results.ts_geom._energy == pytest.approx(-231.6032000849316)
    assert isinstance(results.ts_geom, Geometry)
    assert results.irc.forward_is_converged
    assert results.irc.backward_is_converged
    assert len(results.end_geoms) == 3
    assert results.calc_getter
Esempio n. 5
0
def test_run_results():
    run_dict = {
        "xyz": "lib:h2o.xyz",
        "calc": {
            "type": "pyscf",
            "basis": "sto3g"
        },
    }
    results = run_from_dict(run_dict)

    calced_geoms = results.calced_geoms
    assert len(calced_geoms) == 1
    assert results.calc_getter
Esempio n. 6
0
def test_oniom3():
    run_dict = {
        "xyz": "lib:oniom3alkyl.pdb",
        "coord_type": "redund",
        "calc": {
            "type": "oniom",
            "calcs": {
                "real": {
                    "type": "pyscf",
                    "basis": "sto3g",
                    "pal": 2,
                },
                "mid": {
                    "type": "pyscf",
                    "basis": "321g",
                    "pal": 2,
                },
                "high": {
                    "type": "pyscf",
                    # "basis": "sto3g",
                    "basis": "431g",
                    "pal": 2,
                },
            },
            "models": {
                "high": {
                    "inds": list(range(7, 16)),
                    "calc": "high",
                },
                "mid": {
                    "inds": list(range(4, 19)),
                    "calc": "mid",
                },
            }
        },
        "opt": {
            "thresh": "gau_tight",
        },
    }
    res = run_from_dict(run_dict)
    print()

    opt = res.opt
    assert opt.is_converged
    assert opt.cur_cycle == 7

    geom = res.opt_geom
    res = do_final_hessian(geom, save_hessian=False)
    nus = res.nus
    assert nus[-1] == pytest.approx(3747.5594141, abs=1e-2)
    assert nus[-5] == pytest.approx(3563.8997581, abs=1e-2)
Esempio n. 7
0
def test_hcn_neb_dimer_irc():
    run_dict = {
        "preopt": {
            "max_cycles": 3,
        },
        "interpol": {
            "type": "idpp",
            "between": 3,
        },
        "cos": {
            "type": "neb",
        },
        "opt": {
            "type": "qm",
            "align": True,
            "max_cycles": 10,
        },
        "tsopt": {
            "type": "dimer",
            "thresh": "gau_tight",
            "do_hess": True,
        },
        "irc": {
            "type": "eulerpc",
            "rms_grad_thresh": 1e-3,
        },
        "calc": {
            "type": "pyscf",
            "pal": 2,
            "basis": "321g",
        },
        "xyz": ["lib:hcn.xyz", "lib:hcn_iso_ts.xyz", "lib:nhc.xyz"]
    }
    results = run_from_dict(run_dict)

    assert results.ts_opt.is_converged
    assert results.ts_opt.cur_cycle == 6
    assert results.ts_geom.energy == pytest.approx(-92.2460427)

    irc = results.irc
    assert irc.forward_is_converged
    assert irc.forward_cycle == 29
    assert irc.backward_is_converged
    assert irc.backward_cycle == 36
Esempio n. 8
0
def test_oniom_microiters():
    run_dict = {
        "xyz": "lib:oniom_microiters_test.pdb",
        # "xyz": "lib:acetaldehyd_oniom.xyz",
        "coord_type": "cart",
        "calc": {
            # "type": "pyscf",
            # "basis": "sto-3g",
            "type": "oniom",
            "calcs": {
                "real": {
                    "type": "pyscf",
                    "basis": "sto3g",
                    "pal": 2,
                },
                "high": {
                    "type": "pyscf",
                    "basis": "321g",
                    "pal": 2,
                },
            },
            "models": {
                "high": {
                    "inds": [10, 11, 12, 13, 14],
                    # "inds": [4, 5, 6],
                    "calc": "high",
                },
            }
        },
        "opt": {
            "micro_cycles": [3, 1],
            "type": "oniom",
            # "rms_force": 0.0025,
            # "rms_force": 0.005,
            # "max_cycles": 7,
            # "max_cycles": 3,
        },
    }
    res = run_from_dict(run_dict)
    print()
Esempio n. 9
0
def test_run():
    run_dict = {
        "preopt": {
            "max_cycles": 5,
            "coord_type": "cart",
        },
        "interpol": {
            "type": "linear",
            "between": 12,
            "align": False,
        },
        "cos": {
            "type": "neb",
        },
        "opt": {
            "type": "sd",
            "align": False,
            "rms_force": 1.0,
            "dump": False,
        },
        "tsopt": {
            "type": "rsirfo",
            "thresh": "gau_tight",
        },
        "calc": {
            "type": "anapot",
        },
        # Inline xyz
        "xyz": """
         1
         
         X -1.2 1.4 0.0
         1
         
         X 2.0 4.0 0.0
         """,
        "coord_type": "cart",
    }
    results = run_from_dict(run_dict)
Esempio n. 10
0
def test_oniomopt_water_dimer():
    run_dict = {
        "xyz": "lib:water_dimer_oniomopt_test.pdb",
        "coord_type": "cart",
        "calc": {
            # "type": "pyscf",
            # "basis": "sto-3g",
            "type": "oniom",
            "calcs": {
                "real": {
                    "type": "pyscf",
                    "basis": "sto3g",
                    "pal": 2,
                },
                "high": {
                    "type": "pyscf",
                    "basis": "321g",
                    "pal": 2,
                },
            },
            "models": {
                "high": {
                    "inds": [0, 1, 2],
                    "calc": "high",
                },
            }
        },
        "opt": {
            "micro_cycles": [3, 1],
            "type": "oniom",
            # "rms_force": 0.0025,
            "rms_force": 0.005,
            "max_cycles": 10,
        },
    }
    res = run_from_dict(run_dict)
    print()
Esempio n. 11
0
def test_hcn_neb():
    run_dict = {
        "preopt": {
            "max_cycles": 3,
        },
        "interpol": {
            "type": "idpp",
            "between": 3,
        },
        "cos": {
            "type": "neb",
        },
        "opt": {
            "type": "qm",
            "align": True,
        },
        "tsopt": {
            "type": "rsirfo",
        },
        "calc": {
            "type": "pyscf",
            "pal": 1,
            "basis": "321g",
        },
        "xyz": ["lib:hcn.xyz", "lib:hcn_iso_ts.xyz", "lib:nhc.xyz"]
    }
    results = run_from_dict(run_dict)

    assert results.cos_opt.is_converged
    assert results.cos_opt.cur_cycle == 18
    assert results.ts_opt.is_converged
    assert results.ts_opt.cur_cycle == 1

    with h5py.File("optimization.h5", "r") as handle:
        groups = list(handle.keys())
    ref_groups = ("first_pre", "last_pre", "opt", "tsopt")
    assert set(groups) == set(ref_groups)
Esempio n. 12
0
def test_yaml_oniom():

    run_dict = {
        "xyz": "lib:acetaldehyd_oniom.xyz",
        "coord_type": "redund",
        "calc": {
            "type": "oniom",
            "calcs": {
                "real": {
                    "type": "g16",
                    "route": "hf sto-3g",
                    "pal": 2,
                },
                "high": {
                    "type": "g16",
                    "route": "b3lyp d95v",
                    "pal": 2,
                },
            },
            "models": {
                "high": {
                    "inds": [4, 5, 6],
                    "calc": "high",
                }
            }
        },
        "opt": {
            "thresh": "gau_tight",
        }
    }
    res = run_from_dict(run_dict)

    opt = res.opt
    assert opt.is_converged
    assert opt.cur_cycle == 7
    assert res.opt_geom.energy == pytest.approx(-153.07526171)
Esempio n. 13
0
def test_so3hcl_yaml_mdp():
    """See
    https://aip.scitation.org/doi/pdf/10.1063/1.5082885
    """
    run_dict = {
        "geom": {
            "type": "cart",
            "fn": "lib:so3hcl_diss_ts_opt.xyz",
        },
        "calc": {
            "type": "xtb",
            "pal": 2,
            "quiet": True,
        },
        "mdp": {
            # About 5 kcal/mol as given in the paper
            "E_excess": 0.0079,
            "epsilon": 5e-4,
            "ascent_alpha": 0.025,
            "term_funcs": {
                "hcl_diss": "5,0 > 4.6",
                "oh_formed": "1,4 < 1.9",
            },
            "steps_init": 40,
            "steps": 200,
            "dt": 0.5,
            "seed": 9081302,
            "external_md": False,
            "max_init_trajs": 1,
        },
    }
    results = run_from_dict(run_dict)
    res = results.mdp_result

    assert res.md_fin_plus_term == "hcl_diss"
    assert res.md_fin_minus_term == "oh_formed"
Esempio n. 14
0
 def run_assert(run_dict, prim_len):
     res = run_from_dict(run_dict)
     geom = res.calced_geoms[0]
     assert geom.energy == pytest.approx(ref_energy)
     int_ = geom.internal
     assert len(int_.prim_indices_set) == prim_len