def make_waters(xs): # All waters will be rigid objects with the same geometry: w = Rigid(read_xyz("spc.xyz")) # print xs # print read_xyz ("spc.xyz") # But at different locations and orientation: ss = [w.pinv(x) for x in xs] return [Rigid(w(s)) for s in ss]
def make_waters (xs): # All waters will be rigid objects with the same geometry: w = Rigid (read_xyz ("spc.xyz")) # print xs # print read_xyz ("spc.xyz") # But at different locations and orientation: ss = [w.pinv (x) for x in xs] return [Rigid (w (s)) for s in ss]
def make_uranyl (x, flexible=6): """ Return the "best" linear approximation to the uranyl geometry as a Fixed() func. """ from pts.zmat import ZMat # Make uranyl linear: zmt = ZMat ([(None, None, None), (1, None, None), (1, 2, None)], base=1) # Bond length and the bond angle for uranyl, use the same Z-matrix # for uranyl: s = zmt.pinv (x) # Set the bond lengths equal and 180 degrees angle. Note that if # you plug these internal variables into z-matrix you will not get # zmt(s) ~ x even when s was derived from x. That is because of # the default orientation z-matrix chooses: s_bond = 1.79 # A or sum (s[:2]) / 2 s = [s_bond, s_bond, pi] # Uranyl may or may not be fixed, but to adjust orientation, # rotate a rigid object: Y = Rigid (zmt (s)) y = Y (Y.pinv (x)) if flexible == 0: return Fixed (y) # 0 dof elif flexible == 2: # liear uranyl with flexible bonds: def f (x): ra, rb = x return array ([[0., 0., 0.], [0., 0., ra], [0., 0., -rb]]) return Affine (f, array ([0., 0.])) # 2 dof elif flexible == 6: # return Move (relate (x, zmt (s)), zmt) return ManyBody (Fixed (x[0:1]), Cartesian (x[1:3]), dof=[0, 6]) else: assert False
def make_uranyl(x, flexible=6): """ Return the "best" linear approximation to the uranyl geometry as a Fixed() func. """ from pts.zmat import ZMat # Make uranyl linear: zmt = ZMat([(None, None, None), (1, None, None), (1, 2, None)], base=1) # Bond length and the bond angle for uranyl, use the same Z-matrix # for uranyl: s = zmt.pinv(x) # Set the bond lengths equal and 180 degrees angle. Note that if # you plug these internal variables into z-matrix you will not get # zmt(s) ~ x even when s was derived from x. That is because of # the default orientation z-matrix chooses: s_bond = 1.79 # A or sum (s[:2]) / 2 s = [s_bond, s_bond, pi] # Uranyl may or may not be fixed, but to adjust orientation, # rotate a rigid object: Y = Rigid(zmt(s)) y = Y(Y.pinv(x)) if flexible == 0: return Fixed(y) # 0 dof elif flexible == 2: # liear uranyl with flexible bonds: def f(x): ra, rb = x return array([[0., 0., 0.], [0., 0., ra], [0., 0., -rb]]) return Affine(f, array([0., 0.])) # 2 dof elif flexible == 6: # return Move (relate (x, zmt (s)), zmt) return ManyBody(Fixed(x[0:1]), Cartesian(x[1:3]), dof=[0, 6]) else: assert False
waters = [X] * 5 atoms = read ("uo22+,5h2o.xyz") xa = atoms.get_positions () # Bond length and the bond angle for uranyl, use the same Z-matrix for # uranyl: s = zmt.pinv (xa[:3]) # Average bond length and 180 degrees angle: s_bond = sum (s[:2]) / 2 s = [s_bond, s_bond, pi] # Uranyl will be fixed, but to adjust orientation, rotate a rigid # object: Y = Rigid (zmt (s)) uranyl = Fixed (Y (Y.pinv (xa[:3]))) trafo = ManyBody (uranyl, *waters) # Here initial positions and orientation of 5 rigid waters are # computed to approximate the geometry from the xyz-file. Uranyl is # fixed: s = trafo.pinv (xa) calc = ParaGauss (cmdline=command, input="uranyl+water.scm") clean () with QFunc (atoms, calc) as f: f = Memoize (f, DirStore (salt="uranyl+water, qm"))
f = Memoize(f, DirStore(salt="h2o, qm")) e = compose(f, zmt) print s, e(s) s, info = minimize(e, s, algo=1, ftol=1.0e-2, xtol=1.0e-2) print s, e(s), info["converged"] # # Internal coordinates: # # In: 0.97843364 0.97826543 1.87152024 # Out: 0.98477091 0.98477695 1.88111918 # # Rigid water with optimized internal coordinates: # X = Rigid(zmt(s)) # Five optimized rigid waters, actual location and orientation to be # specified ... waters = [X] * 5 atoms = read("uo22+,5h2o.xyz") xa = atoms.get_positions() # Bond length and the bond angle for uranyl, use the same Z-matrix for # uranyl: s = zmt.pinv(xa[:3]) # Average bond length and 180 degrees angle: s_bond = sum(s[:2]) / 2 s = [s_bond, s_bond, pi]