def test_pyscf(): from pyscf import gto, dft from pyscf.geomopt.berny_solver import as_berny_solver mf = dft.RKS(gto.M(atom=list(ethanol), basis='3-21g', verbose=0)) mf.xc = 'pbe' solver = as_berny_solver(mf) final = optimize(solver, ethanol) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([15.39, 54.38, 63.30], rel=1e-3)
def test_cyanogen(mopac, cyanogen): berny = Berny(cyanogen, steprms=0.01, stepmax=0.05, maxsteps=4) final = optimize(berny, mopac) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([0, 107.5, 107.5], rel=1e-3, abs=1e-3)
def test_aniline(mopac, aniline): berny = Berny(aniline, steprms=0.01, stepmax=0.05, maxsteps=8) final = optimize(berny, mopac) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([90.94, 193.1, 283.9], rel=1e-3)
def test_ethanol(mopac, ethanol): berny = Berny(ethanol, steprms=0.01, stepmax=0.05, maxsteps=5) final = optimize(berny, mopac) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([14.95, 52.58, 61.10], rel=1e-3)
from berny import Berny, optimize, geomlib from berny.solvers import MopacSolver from scr_old.gradient_plotter import log_berny_plotter import numpy as np import sys # orig_stdout = sys.stdout srm, smax = 0.05, 0.1 fxyz, logf, fopt = '/home/anastasiia/PycharmProjects/chem_structure/opted_mols/3-MnH2_opted.xyz',\ '3_opted'+str(srm)+'_stepmax_'+str(smax)+'.log', '3_opted_'+str(srm)+'_stepmax_'+str(smax)+'.xyz' f = open(logf, 'w') sys.stdout = f optimizer = Berny(geomlib.readfile(fxyz), steprms=srm, stepmax=smax, maxsteps=150) final = optimize(optimizer, MopacSolver(cmd='/opt/mopac/run_script.sh')) inertia_princpl = np.linalg.eigvalsh(final.inertia) final.dump(open('3_berny_opt_mopac.xyz', 'w'), 'xyz') # final.dump(open('TS-5-6_bopt.xyz', 'w'), 'xyz') f.close() log_berny_plotter(logf, title='3_berny_opt_mopac') # for geom in optimizer: # get energy and gradients for geom # optimizer.send((energy, gradients))
def test_optimize(mopac, test_case): geom, n_ref = test_case() berny = Berny(geom) optimize(berny, mopac) assert berny.converged assert berny._n == n_ref
def test_aniline(): solver = MopacSolver() final = optimize(solver, aniline, steprms=0.01, stepmax=0.05, maxsteps=8) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([90.94, 193.1, 283.9], rel=1e-3)
def test_ethanol(): solver = MopacSolver() final = optimize(solver, ethanol, steprms=0.01, stepmax=0.05, maxsteps=5) inertia_princpl = np.linalg.eigvalsh(final.inertia) assert inertia_princpl == approx([14.95, 52.58, 61.10], rel=1e-3)