Пример #1
0
def test_anapot_growingstring_opt():
    coords = (
        (-1.05274, 1.02776, 0),
        (1.94101, 3.85427, 0),
    )
    calc_getter = AnaPot
    eps = .05
    damp = .05
    images = get_geoms(coords, calc_getter)
    gs_kwargs = {
        "max_nodes": 10,
        "perp_thresh": 0.5,
        # "perp_thresh": 1,
    }
    gs = GrowingString(images, calc_getter, reparam_every=1)
    # from pysisyphus.optimizers.QuickMin import QuickMin
    # opt = QuickMin(gs)
    # self.coords = [c.reshape(-1, 3) for c in self.gs.coords_list]
    # self.tangents = self.gs.tangent_list
    # self.perp_forces = self.gs.perp_force_list

    from pysisyphus.optimizers.SteepestDescent import SteepestDescent
    # opt = SteepestDescent(gs, alpha=0.05, bt_disable=True, max_cycles=175)
    opt = SteepestDescent(gs, alpha=0.05, bt_disable=True, max_cycles=70)
    opt.run()
    xlim = (-2, 2.5)
    ylim = (0, 5)
    levels = (-3, 4, 80)
    ap = AnimPlot(AnaPot(), opt, xlim=xlim, ylim=ylim, levels=levels)
    ap.animate()
Пример #2
0
def test_multi_run():
    # NEB
    geoms = AnaPot().get_path(10)
    cos = NEB(geoms)
    neb_kwargs = {
        "dump": True,
        "h5_group_name": "neb",
    }
    neb_opt = SteepestDescent(cos, **neb_kwargs)
    neb_opt.run()

    # GrowingString
    geoms = AnaPot().get_path(10)
    gsm = GrowingString(geoms, calc_getter=AnaPot, perp_thresh=0.25)
    gsm_kwargs = {
        "dump": True,
        "h5_group_name": "gsm",
        "stop_in_when_full": 0,
    }
    gsm_opt = StringOptimizer(gsm, **gsm_kwargs)
    gsm_opt.run()
    # calc = geoms[0].calculator
    # calc.anim_opt(opt, show=True)

    # Simple Optimization
    geom = AnaPot().get_path(10)[5]
    opt_kwargs = {
        "dump": True,
        "h5_group_name": "opt",
    }
    opt = RFOptimizer(geom, **opt_kwargs)
    opt.run()
Пример #3
0
def test_neb_springs(neb_kwargs, ref_cycle):
    calc = AnaPot()
    geoms = calc.get_path(15)
    neb = NEB(geoms, **neb_kwargs)
    opt = SteepestDescent(neb)
    opt.run()

    # calc.anim_opt(opt, show=True)

    assert (opt.is_converged)
    assert (opt.cur_cycle == ref_cycle)
Пример #4
0
def test_wfo_ref():
    in_path = THIS_DIR / "butadiene_twist"
    geom = geom_from_xyz_file(in_path / "02_buta_twist.xyz")
    turbo = Turbomole(in_path, track=True, wfo_basis="def2-svp")
    geom.set_calculator(turbo)

    opt_kwargs = {
        "max_cycles": 2,
        "dump": True,
    }
    opt = SteepestDescent(geom, **opt_kwargs)
    opt.run()
Пример #5
0
def test_freeend_anapot():
    calc = AnaPot()
    geoms = calc.get_path(15)
    geoms = geoms[3:11]

    fe_neb = FreeEndNEB(geoms)
    opt = SteepestDescent(fe_neb)
    opt.run()

    # calc.anim_opt(opt, show=True)

    assert opt.is_converged
    assert opt.cur_cycle == 31
Пример #6
0
def test_wfo_compare_sto3g():
    in_path = THIS_DIR / "butadiene_twist_sto3g"
    geom = geom_from_xyz_file(in_path / "02_buta_twist.xyz")
    turbo = Turbomole(in_path, track=True, wfo_basis="sto-3g")
    geom.set_calculator(turbo)

    opt_kwargs = {
        "max_cycles": 1,
        "dump": True,
    }
    opt = SteepestDescent(geom, **opt_kwargs)
    opt.run()
    wfow = turbo.wfow
    wfow.compare(wfow)
Пример #7
0
def test_wfo_compare_neon():
    in_path = THIS_DIR / "neon"
    geom = geom_from_xyz_file(in_path / "neon.xyz")
    turbo = Turbomole(in_path, track=True, wfo_basis="def2-svp")
    geom.set_calculator(turbo)

    opt_kwargs = {
        "max_cycles": 1,
        "dump": True,
    }
    opt = SteepestDescent(geom, **opt_kwargs)
    opt.run()
    wfow = turbo.wfow
    wfow.compare(wfow)
Пример #8
0
def test_freeend_freeendpot():
    calc = FreeEndNEBPot()
    geoms = calc.get_path(50)[:35]

    kwargs = {
        "k_min": 5,
        "k_max": 10,
    }
    fe_neb = FreeEndNEB(geoms, **kwargs)
    opt = SteepestDescent(fe_neb, max_cycles=100)
    opt.run()

    # calc.anim_opt(opt, show=True)

    assert opt.is_converged
    assert opt.cur_cycle == 93
Пример #9
0
def test_wfo_compare_neon_dimer():
    in_path = THIS_DIR / "neon_dimer"
    geom = geom_from_xyz_file(in_path / "neon_dimer.xyz")
    turbo = Turbomole(in_path, track=True, wfo_basis="def2-svp")
    geom.set_calculator(turbo)

    opt_kwargs = {
        "max_cycles": 5,
        "dump": True,
        "track": True,
        # "convergence": {
        # "max_force_thresh": 2.5e-8,
        # }
    }
    opt = SteepestDescent(geom, **opt_kwargs)
    #import pdb; pdb.set_trace()
    opt.run()
Пример #10
0
def test_dask():
    with LocalCluster(n_workers=2) as cluster:
        address = cluster.scheduler_address

        geoms = geom_from_library(
            "ala_dipeptide_iso_b3lyp_631gd_10_images.trj")

        for i, geom in enumerate(geoms):
            calc = XTB(pal=1, calc_number=i)
            geom.set_calculator(calc)

        neb = NEB(geoms, scheduler=address)

        max_cycles = 1
        opt = SteepestDescent(neb, align=True, max_cycles=max_cycles)
        opt.run()

    assert opt.cur_cycle == (max_cycles - 1)
Пример #11
0
def test_fs():
    from pysisyphus.calculators.XTB import XTB
    from pysisyphus.cos.FreezingString import FreezingString
    # educt = geom_from_library("ciscis_24hexadiene_xtbopt.xyz")
    # product = geom_from_library("trans34dimethylcyclobutene.xyz")

    educt = AnaPot.get_geom((-1.05274, 1.02776, 0))
    product = AnaPot.get_geom((1.94101, 3.85427, 0))
    images = (educt, product)
    
    def calc_getter():
        return AnaPot()

    fs = FreezingString(images, calc_getter, max_nodes=10)
    from pysisyphus.optimizers.SteepestDescent import SteepestDescent
    sd = SteepestDescent(fs)
    sd.run()
    pot = AnaPot()
    pot.plot()
    crds = fs.allcoords.reshape(-1, 3)
    # pot.ax.plot(c[:,0], c[:,1], "o-")
    pot.ax.plot(*crds[:,:2].T, "o-")
    plt.show()
    from pysisyphus.optimizers.StringOptimizer import StringOptimizer
Пример #12
0
def test_mb_gs_opt():
    coords = (
        (0.614, 0.031, 0),
        (-.563, 1.43, 0),
    )
    calc_getter = MullerBrownPot
    # pot = calc_getter()
    # pot.plot()
    # plt.show()
    images = get_geoms(coords, calc_getter)
    gs_kwargs = {
        "max_nodes": 16,
        "perp_thresh": 50,
        "fix_ends": True,
    }
    gs = GrowingString(images, calc_getter, **gs_kwargs)
    from pysisyphus.optimizers.QuickMin import QuickMin
    from pysisyphus.optimizers.SteepestDescent import SteepestDescent as SD
    # opt = QuickMin(gs)
    opt = SD(gs, alpha=0.4, bt_disable=True)
    opt.run()

    ap = AnimPlot(calc_getter(), opt)
    ap.animate()
Пример #13
0
def test_dump_neb():
    # NEB
    geoms = AnaPot().get_path(10)
    cos = NEB(geoms)
    opt_kwargs = {
        "dump": True,
        # "rms_force": 1.0,
        "h5_group_name": "neb",
    }
    opt = SteepestDescent(cos, **opt_kwargs)
    # opt = SteepestDescent(geoms[7], **opt_kwargs)
    opt.run()

    # GrowingString
    geoms = AnaPot().get_path(10)
    gsm = GrowingString(geoms, calc_getter=AnaPot, perp_thresh=0.25)
    opt_kwargs = {
        "dump": True,
        "h5_group_name": "gsm",
        "gamma": 10.,
        "stop_in_when_full": 0,
    }
    opt = StringOptimizer(gsm, **opt_kwargs)
    opt.run()
    calc = geoms[0].calculator
    # calc.anim_opt(opt, show=True)

    # # Simple Optimization
    # geom = AnaPot().get_path(10)[5]
    # opt_kwargs = {
    # "dump": True,
    # "h5_group_name": "opt",
    # }
    # opt = RFOptimizer(geom, **opt_kwargs)
    # opt.run()
    return

    hei_coords, *_ = cos.get_splined_hei()
    ts_geom = geoms[0].copy()
    ts_geom.coords = hei_coords
    ts_geom.set_calculator(AnaPot())
    ts_opt_kwargs = {
        # "dump": True,
        "thresh": "gau_tight",
    }
    ts_opt = RSIRFOptimizer(ts_geom, **ts_opt_kwargs)
    ts_opt.run()
Пример #14
0
def test_butadiene_track_opt():
    in_path = THIS_DIR / "butadiene"
    geom = geom_from_xyz_file(in_path / "butadiene_hf_sto3g.xyz")
    turbo = Turbomole(in_path, track=True, wfo_basis="def2-svp")
    geom.set_calculator(turbo)

    #fn = "/scratch/programme/pysisyphus/tests/test_turbo_butadien_td_opt/wfo_backup.out"
    #with open(fn) as handle:
    #    stdout = handle.read()
    #wfo = turbo.wfow
    #a = wfo.parse_wfoverlap_out(stdout)
    #print(a)
    #print(a.reshape(-1, 6))

    opt_kwargs = {
        "max_cycles": 10,
        "dump": True,
    }
    opt = ConjugateGradient(geom, **opt_kwargs)
    opt = SteepestDescent(geom, **opt_kwargs)
    opt.run()