def initial_path (f, s, c): """ This is called with pure MM PES f(s) to get some initial path. Somewhat ad-hoc. """ # The input geometry s may be reasonable, but it may not be an # exact minimum. Reoptimize: s, info = minimize (f, s, maxit=100, ftol=5.0e-4, xtol=5.0e-4, algo=1) print ("converged=", info["converged"], "in", info["iterations"]) # The value of reaction coordinate in the initial geometry: c0 = c(s) print ("XXX: rc(0)=", c0) it = 0 ss = [] qs = [] algo = 1 while c(s) > -c0: it += 1 # write_xyz ("in-%03d.xyz" % it, trafo (s)) print ("XXX: rc(0)=", c(s)) s, info = cminimize (f, s, Array (c), maxit=200, ftol=5.0e-3, xtol=5.0e-3, algo=algo) # Collect optimized geometries and the corresponding # values of reaction coordinate: ss.append (s) qs.append (c(s)) print ("converged=", info["converged"], "in", info["iterations"]) print ("XXX: rc(1)=", c(s)) # write_xyz ("out-%03d.xyz" % it, trafo (s)) # Here c.fprime(s) is how much that reaction coordinate # will change if you modify the coordinates. Hacky way to # chage a geometry so that the RC is modified too: s = s - 0.1 * c.fprime (s) ss = asarray (ss) qs = asarray (qs) print ("qs=", qs) p = Path (ss, qs) print ("path=", p) qs = linspace (c0, -c0, 21) print ("qs=", qs) ss = map (p, qs) res = map (lambda s: cminimize (f, s, Array (c), maxit=200, ftol=1.0e-3, xtol=1.0e-3, algo=algo), ss) infos = [inf for _, inf in res] ss = [s for s, _ in res] for info in infos: print ("converged=", info["converged"], "in", info["iterations"]) for i, s in enumerate (ss): write_xyz ("out-%03d.xyz" % i, trafo (s)) return qs, ss
def copt(s, maxit): sm, info = cminimize(e, s, Array(c), maxit=maxit, ftol=1.0e-3, xtol=1.0e-3, algo=0) print("converged=", info["converged"], "in", info["iterations"]) return sm
def initial_path(f, s, c): """ This is called with pure MM PES f(s) to get some initial path. Somewhat ad-hoc. """ # The input geometry s may be reasonable, but it may not be an # exact minimum. Reoptimize: s, info = minimize(f, s, maxit=100, ftol=5.0e-4, xtol=5.0e-4, algo=1) print("converged=", info["converged"], "in", info["iterations"]) # The value of reaction coordinate in the initial geometry: c0 = c(s) print("XXX: rc(0)=", c0) it = 0 ss = [] qs = [] algo = 1 while c(s) > -c0: it += 1 # write_xyz ("in-%03d.xyz" % it, trafo (s)) print("XXX: rc(0)=", c(s)) s, info = cminimize(f, s, Array(c), maxit=200, ftol=5.0e-3, xtol=5.0e-3, algo=algo) # Collect optimized geometries and the corresponding # values of reaction coordinate: ss.append(s) qs.append(c(s)) print("converged=", info["converged"], "in", info["iterations"]) print("XXX: rc(1)=", c(s)) # write_xyz ("out-%03d.xyz" % it, trafo (s)) # Here c.fprime(s) is how much that reaction coordinate # will change if you modify the coordinates. Hacky way to # chage a geometry so that the RC is modified too: s = s - 0.1 * c.fprime(s) ss = asarray(ss) qs = asarray(qs) print("qs=", qs) p = Path(ss, qs) print("path=", p) qs = linspace(c0, -c0, 21) print("qs=", qs) ss = map(p, qs) res = map( lambda s: cminimize( f, s, Array(c), maxit=200, ftol=1.0e-3, xtol=1.0e-3, algo=algo), ss) infos = [inf for _, inf in res] ss = [s for s, _ in res] for info in infos: print("converged=", info["converged"], "in", info["iterations"]) for i, s in enumerate(ss): write_xyz("out-%03d.xyz" % i, trafo(s)) return qs, ss
def copt (s, maxit): sm, info = cminimize (e, s, Array (c), maxit=maxit, ftol=1.0e-3, xtol=1.0e-3, algo=0) print ("converged=", info["converged"], "in", info["iterations"]) return sm