def gen_water(shift=np.zeros(3), shiftPt=np.zeros(3), theta=0.0, phi=0.0): """Init water molecule, already optimised using 6-311G**""" coords = np.zeros((3,3)) coords[1, 1] += 0.757009 coords[2, 1] += -0.757009 coords[1:3, 2] += 0.593565 names = ["O", "H", "H"] mol = Atoms(names, coords) mol.rotate(theta, phi) mol.shift(np.dot(Pt_basis(), shiftPt)) mol.shift(shift) return mol
for c in combinations(blobnums, 2): combdirname = "Blobs_" + str(c[0]) + "_" + str(c[1]) combdir = os.path.join(maindir, combdirname) if not os.path.isdir(combdir): # create list of subdirs by combination os.makedirs(combdir) print "Created new directory", combdirname blob1 = Atoms().read(blobdir + "/waterblob_" + str(c[0]) + ".xyz") blob2 = Atoms().read(blobdir + "/waterblob_" + str(c[1]) + ".xyz") blob1.shift_com() blob2.shift_com() for d in Drange: # in each combdir, create xyz and gjf files for each blob dist xyzname = "waterblobs_d" + str(d) + ".xyz" xyzpath = os.path.join(combdir, xyzname) if not os.path.exists(xyzpath): blob2.shift([0, 0, d]) blob12 = blob1 + blob2 blob2.shift([0, 0, -d]) # BAD SOLUTION, FIX THIS blob12.save(xyzpath) # header = gen_g09_header(params=g09params) #FIX THIS header = "%nproc=16\n#T B3LYP/6-31G* Test\n\nSome silly text\n\n" output = header + str(blob12) + "\n\n" gjfname = "run_blobs_d" + str(d) + ".gjf" gjfpath = os.path.join(combdir, gjfname) open(gjfpath, "w").write(output) print "g09 input file written into", gjfpath
from numpy.matlib import repmat from scipy.linalg import expm from math import sqrt, acos, radians from xyzlib import Atoms from docopt import docopt if __name__ == "__main__": args = docopt(__doc__,version=1.0) # print args A = Atoms().read(args["<file>"]) if args["--centre"]: n = int(args["--centre"]) s = -A.coords[n-1] A.shift(s) if args["--align"]: n1, n2 = [int(i) for i in args["--align"].split()] if n1 != n2: A.align(n1, n2) if args["--flip"]: n1, n2 = [int(i) for i in args["--flip"].split()] if n1 == n2: print "Please choose two different atoms." else: A.flip(n1, n2) if args["--rotate"]: theta, phi = [radians(float(i)) for i in args["--rotate"].split()]
print "Range of distances: ", Drange for c in combinations(blobnums, 2): combdirname = "Blobs_" + str(c[0]) + "_" + str(c[1]) combdir = os.path.join(maindir, combdirname) if not os.path.isdir(combdir): # create list of subdirs by combination os.makedirs(combdir) print "Created new directory", combdirname blob1 = Atoms().read(blobdir + "/waterblob_" + str(c[0]) + ".xyz") blob2 = Atoms().read(blobdir + "/waterblob_" + str(c[1]) + ".xyz") blob1.shift_com() blob2.shift_com() for d in Drange: # in each combdir, create xyz and gjf files for each blob dist xyzname = "waterblobs_d" + str(d) + ".xyz" xyzpath = os.path.join(combdir, xyzname) if not os.path.exists(xyzpath): blob2.shift([0, 0, d]) blob12 = blob1 + blob2 blob2.shift([0, 0, -d]) # BAD SOLUTION, FIX THIS blob12.save(xyzpath) # header = gen_g09_header(params=g09params) #FIX THIS header = "%nproc=16\n#T B3LYP/6-31G* Test\n\nSome silly text\n\n" output = header + str(blob12) + "\n\n" gjfname = "run_blobs_d" + str(d) + ".gjf" gjfpath = os.path.join(combdir, gjfname) open(gjfpath, "w").write(output) print "g09 input file written into", gjfpath
args = docopt(__doc__) #print args np.random.seed(int(args["--seed"])) sigma = float(args["--sigma"]) A = Atoms().read(args["<infile>"]) if args["--all"]: noise = np.random.randn(len(A), 3)*sigma A.coords += noise if args["--bymol"]: Nmols = len(A)/3 for i in range(Nmols): mol = Atoms(names=A.names[3*i:3*(i+1)], coords=A.coords[3*i:3*(i+1), :]) tempshift = mol.coords[0] #mol.shift(-tempshift) # put oxygen at [0,0,0] theta = np.random.randn()*sigma phi = np.random.randn()*sigma mol.rotate(theta, phi) #mol.shift(tempshift) mol.shift(np.random.randn(3, 3)*sigma) A.coords[3*i:3*(i+1), :] = np.copy(mol.coords) if args["--save"]: A.save(args["--save"]) else: print A
from xyzlib import Atoms args = docopt(__doc__) #print args np.random.seed(int(args["--seed"])) sigma = float(args["--sigma"]) A = Atoms().read(args["<infile>"]) if args["--all"]: noise = np.random.randn(len(A), 3) * sigma A.coords += noise if args["--bymol"]: Nmols = len(A) / 3 for i in range(Nmols): mol = Atoms(names=A.names[3 * i:3 * (i + 1)], coords=A.coords[3 * i:3 * (i + 1), :]) tempshift = mol.coords[0] #mol.shift(-tempshift) # put oxygen at [0,0,0] theta = np.random.randn() * sigma phi = np.random.randn() * sigma mol.rotate(theta, phi) #mol.shift(tempshift) mol.shift(np.random.randn(3, 3) * sigma) A.coords[3 * i:3 * (i + 1), :] = np.copy(mol.coords) if args["--save"]: A.save(args["--save"]) else: print A