Ejemplo n.º 1
0
def binding2():
    for n in [
            'propanenitrile', 'butanenitrile', 'pentanenitrile',
            'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2',
            'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2',
            'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2'
    ]:
        '''
		try:
			contents = open('lammps/bind3_'+n+'.log').read()
			opls_binding_e = float(re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))
			
			pair = gaussian.parse_atoms('gaussian/'+n+'_opt.log')[0]
			lone1 = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
			lone2 = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
		
			print n, opls_binding_e, 627.5*(pair - lone1 - lone2)
		except: print n
		'''
        #(Optimized pair energy) - 2*(optimized single energy) - (BSSE of optimized pair)
        try:
            contents = open('lammps/bind3_' + n + '.log').read()
            opls_pair = float(re.findall('TotEng\s+=\s+(\S+)', contents)[-1])
            opls_single = float(re.findall('TotEng\s+=\s+(\S+)', contents)[-1])

            pair = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt1.log')[0]
            single = gaussian.parse_atoms('gaussian/' + n + '_0.log')[0]

            print n, opls_binding_e, 627.5 * (pair - lone1 - lone2)
        except:
            print n
Ejemplo n.º 2
0
def binding2():
	for n in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
		'''
		try:
			contents = open('lammps/bind3_'+n+'.log').read()
			opls_binding_e = float(re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))
			
			pair = gaussian.parse_atoms('gaussian/'+n+'_opt.log')[0]
			lone1 = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
			lone2 = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
		
			print n, opls_binding_e, 627.5*(pair - lone1 - lone2)
		except: print n
		'''
		#(Optimized pair energy) - 2*(optimized single energy) - (BSSE of optimized pair)
		try:
			contents = open('lammps/bind3_'+n+'.log').read()
			opls_pair = float(re.findall('TotEng\s+=\s+(\S+)', contents)[-1])
			opls_single = float(re.findall('TotEng\s+=\s+(\S+)', contents)[-1])
			
			pair = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.log')[0]
			single = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
		
			print n, opls_binding_e, 627.5*(pair - lone1 - lone2)
		except: print n
Ejemplo n.º 3
0
def compare_distances_only():
    utils.Molecule.set_params('oplsaa4.prm')
    for f in [
            'propanenitrile', 'butanenitrile', 'pentanenitrile',
            'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2',
            'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2',
            'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2'
    ]:
        atoms0 = utils.Molecule(f + '.arc').atoms
        atoms1 = gaussian.parse_atoms('gaussian/' + f + '_1.log')[1]
        for i in range(len(atoms0)):
            atoms0[i].index = i + 1
            atoms1[i].index = i + 1

            #atoms0[i].x = atoms1[i].xp
            #atoms0[i].y = atoms1[i].y
            #atoms0[i].z = atoms1[i].z

        bonds0 = filetypes.get_bonds(atoms0)
        bonds1 = filetypes.get_bonds(atoms1)

        #filetypes.write_arc(f[:-1]+'3', atoms0)
        #continue

        angles0, dihedrals0 = filetypes.get_angles_and_dihedrals(
            atoms0, bonds0)
        angles1, dihedrals1 = filetypes.get_angles_and_dihedrals(
            atoms1, bonds1)

        bond_error = 0.0
        for i in range(len(bonds0)):
            bond_error += abs(bonds0[i].d - bonds1[i].d)

        angles0.sort(key=lambda a: tuple([n.index for n in a.atoms]))
        angles1.sort(key=lambda a: tuple([n.index for n in a.atoms]))

        angle_error = 0.0
        for i in range(len(angles0)):
            d0 = utils.dist(angles0[i].atoms[0], angles0[i].atoms[2])
            d1 = utils.dist(angles1[i].atoms[0], angles1[i].atoms[2])
            angle_error += abs(d0 - d1)

        dihedrals0.sort(key=lambda a: tuple([n.index for n in a.atoms]))
        dihedrals1.sort(key=lambda a: tuple([n.index for n in a.atoms]))

        if dihedrals0:
            dihedral_error = 0.0
            for i in range(len(dihedrals0)):
                #if dihedral is single-bonded free rotor, ignore comparison
                if (dihedrals0[i].atoms[1].type.index,
                        dihedrals0[i].atoms[1].type.index) == (78, 78):
                    continue
                d0 = utils.dist(dihedrals0[i].atoms[0], dihedrals0[i].atoms[3])
                d1 = utils.dist(dihedrals1[i].atoms[0], dihedrals1[i].atoms[3])
                dihedral_error += abs(d0 - d1)

            print f, bond_error / len(bonds0), angle_error / len(
                angles0), 180 / math.pi * dihedral_error / len(dihedrals0)
        else:
            print f, bond_error / len(bonds0), angle_error / len(angles0), 0.0
Ejemplo n.º 4
0
def analyze_binding():
	for n in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
	
		contents = open('lammps/bind3_'+n+'.log').read()
		
		opls_binding_e = float(re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))
		
		try:
			e_pair = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.1.log', check_convergence=False)[0]
		except:
			e_pair = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.log', check_convergence=False)[0]
			
		try:
			e_pair_scrf = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.1.log', check_convergence=False)[0]
		except:
			e_pair_scrf = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.log', check_convergence=False)[0]

		e_single = gaussian.parse_atoms('gaussian/'+n+'_0.log')[0]
		e_single_scrf = gaussian.parse_atoms('gaussian/'+n+'_1.log')[0]

		try:
			bsse = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a.log')[0] + gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b.log')[0] - gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a_Bq.log')[0] - gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b_Bq.log')[0]
		except:
			print 1, n
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a_Bq.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b_Bq.log') is None
			bsse = 0.0
		
		try:
			bsse_scrf = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a.log')[0] + gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b.log')[0] - gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a_Bq.log')[0] - gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b_Bq.log')[0]
		except:
			print 2, n
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a_Bq.log') is None
			#print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b_Bq.log') is None
			bsse_scrf = 0.0
			
		#No such file or directory: 'gaussian/bind3_aminopentane2_opt2b_Bq.log
		#No such file or directory: 'gaussian/bind3_aminobutane2_opt2a_Bq.log'
		
		
		#print n, opls_binding_e, e_pair, e_single, bsse, e_pair_scrf, e_single_scrf, bsse_scrf
		
		print n, ',', opls_binding_e, ',', (e_pair-2*e_single+bsse)*627, ',',  (e_pair_scrf-2*e_single_scrf+bsse_scrf)*627
Ejemplo n.º 5
0
def compare_distances_only():
	utils.Molecule.set_params('oplsaa4.prm')
	for f in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
		atoms0 = utils.Molecule(f+'.arc').atoms
		atoms1 = gaussian.parse_atoms('gaussian/'+f+'_1.log')[1]
		for i in range(len(atoms0)):
			atoms0[i].index = i+1
			atoms1[i].index = i+1
			
			#atoms0[i].x = atoms1[i].xp
			#atoms0[i].y = atoms1[i].y
			#atoms0[i].z = atoms1[i].z
	
		bonds0 = filetypes.get_bonds(atoms0)
		bonds1 = filetypes.get_bonds(atoms1)
		
		#filetypes.write_arc(f[:-1]+'3', atoms0)
		#continue
		
		angles0, dihedrals0 = filetypes.get_angles_and_dihedrals(atoms0, bonds0)
		angles1, dihedrals1 = filetypes.get_angles_and_dihedrals(atoms1, bonds1)
		
		bond_error = 0.0
		for i in range(len(bonds0)):
			bond_error += abs(bonds0[i].d - bonds1[i].d)
		
		angles0.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		angles1.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		
		angle_error = 0.0
		for i in range(len(angles0)):
			d0 = utils.dist(angles0[i].atoms[0], angles0[i].atoms[2])
			d1 = utils.dist(angles1[i].atoms[0], angles1[i].atoms[2])
			angle_error += abs(d0-d1)
			
		dihedrals0.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		dihedrals1.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		
		if dihedrals0:
			dihedral_error = 0.0
			for i in range(len(dihedrals0)):
				#if dihedral is single-bonded free rotor, ignore comparison
				if (dihedrals0[i].atoms[1].type.index,dihedrals0[i].atoms[1].type.index) == (78,78):
					continue
				d0 = utils.dist(dihedrals0[i].atoms[0], dihedrals0[i].atoms[3])
				d1 = utils.dist(dihedrals1[i].atoms[0], dihedrals1[i].atoms[3])
				dihedral_error += abs(d0-d1)
		
			print f, bond_error/len(bonds0), angle_error/len(angles0), 180/math.pi*dihedral_error/len(dihedrals0)
		else:
			print f, bond_error/len(bonds0), angle_error/len(angles0), 0.0
Ejemplo n.º 6
0
		gaussian.job(atoms, 'HSEH1PBE/cc-pVDZ', 'batch', name, route, previous=previous_job)
	return name

def binding_energy_dz(job_total, job_A, job_B, zero_indexed_atom_indices_A):
	AB = gaussian.atoms(job_total)
	AB_A = copy.deepcopy(AB)
	for i,atom in enumerate(AB_A):
		if i not in zero_indexed_atom_indices_A: atom.element+='-Bq'
	AB_B = copy.deepcopy(AB)
	for i,atom in enumerate(AB_B):
		if i in zero_indexed_atom_indices_A: atom.element+='-Bq'
	#now AB_A is A from AB, AB_B is B from AB
	name1 = job(AB_A, job_total+'_A0', previous_job=job_total)
	name2 = job(AB_B, job_total+'_B0', previous_job=job_total)
	
	#non-rigid correction:
	AB_A = [atom for atom in AB_A if not atom.element.endswith('-Bq')]
	AB_B = [atom for atom in AB_B if not atom.element.endswith('-Bq')]
	name3 = job(AB_A, job_A+'_AB0', previous_job=job_A)
	name4 = job(AB_B, job_B+'_AB0'+('2' if job_A==job_B else ''), previous_job=job_B)
	
	print 'E_binding = %s - %s - %s + %s + %s - %s - %s' % (job_total, name1, name2, name3, name4, job_A, job_B)

#binding_energy_dz('pbi2_6methc_9_Imbs', 'pbi2_5methc_12_Imbs', 'methc_solv_Imbs', range (58))

#binding_energy_dz('pbcl2_3acetone_3_Cmbs', 'pbcl2_2acetone_5_Cmbs', 'acetone_1_Cmbs', range (10,23))


for job in ['pbi2_6methc_9_Imbs','pbi2_6methc_9_Imbs_A0','pbi2_6methc_9_Imbs_B0','pbi2_5methc_12_Imbs_AB0','methc_solv_Imbs_AB4','pbi2_5methc_12_Imbs','methc_solv_Imbs']:
	 print job,gaussian.parse_atoms(job)[0]
Ejemplo n.º 7
0
import math, copy, sys, random, re, os, cPickle, shutil
sys.path.append("/fs/home/jms875/Library")
import gaussian, filetypes, utils

name = sys.argv[1]
if len(sys.argv) == 3:
    low = 0
    count = int(sys.argv[2])
if len(sys.argv) == 4:
    low = int(sys.argv[2])
    count = int(sys.argv[3])

f = open('out.xyz', 'w')
energies = []
for step in range(low, count):
    energy, atoms = gaussian.parse_atoms(name % step, check_convergence=False)
    filetypes.write_xyz('', atoms, f)
    print energy, int(gaussian.parse_atoms(name % step) != None)
    energies.append(energy)


def matplot(y):
    import matplotlib.pyplot as plt
    plt.plot(y, marker='.')
    plt.show()


f.close()
energies = [(e - energies[0]) * 627.5 for e in energies]
matplot(energies)
Ejemplo n.º 8
0
def SVD(dot_size,Niter):
	lattice_start = []
	lattice_end = []
	dot1 = [1, 2, 4, 5, 7, 9, 10]
	dot4 = [4, 5, 6, 8]
	for run in dot4:
		# W is the optimal rotation matrix that minimizes the differences between the start and end coordinates
		# read xyz file and compare the start and end structures
		f = open('/fs/home/ja539/Desktop/C/jovana_test/HSEHsol_test_iter'+str(Niter)+'_'+str(run)+'_'+str(dot_size)+'.xyz')
		Natoms = int(f.readline())
		f.close()
		atoms = filetypes.parse_xyz('/fs/home/ja539/Desktop/C/jovana_test/HSEHsol_test_iter'+str(Niter)+'_'+str(run)+'_'+str(dot_size)+'.xyz')
		start_atoms = atoms[-Natoms:]
		energy, end_atoms = gaussian.parse_atoms('HSEHsol_testopt4_iter'+str(Niter)+'_'+str(run)+'_'+str(dot_size),check_convergence=False)
		#energy, end_atoms = gaussian.parse_atoms('/fs/home/jms875/Documents/nanocrystals/pb_oleate_hydrate/gaussian/dot2_m06_6.log',check_convergence=False)
		#energy, end_atoms = gaussian.parse_atoms('gaussian/HSEHsol_core1_dot6_2.log')
	
		startx,starty,startz,endx,endy,endz,start_com,end_com = unweighted_COM(start_atoms,end_atoms)
		A = np.array([startx,starty,startz])
		#print A.shape
		B = np.array([endx,endy,endz])
		BT = B.transpose()
		C = np.dot(A,BT)
		#print C.shape
		
		U, s, V = np.linalg.svd(C, full_matrices=True)
		#print U.shape, V.shape
		if np.linalg.det(V) < 0:
			for i in range(3):
				V[2][i] =  V[2][i]*-1.0
		#print U.shape, V.shape
		W = np.dot(V.transpose(),U.transpose())	
		A_new = np.dot(W,A)
		
		# piece together an xyz file that has the end and shifted start one after the other
		for i in range(len(start_atoms)):
			start_atoms[i].x = A_new[0][i]
			start_atoms[i].y = A_new[1][i]
			start_atoms[i].z = A_new[2][i]
			end_atoms[i].x = B[0][i]
			end_atoms[i].y = B[1][i]
			end_atoms[i].z = B[2][i]
		
		make_xyz_file('SVD_iter'+str(Niter)+'_'+str(run)+'_'+str(dot_size), end_atoms, 'w')
		make_xyz_file('SVD_iter'+str(Niter)+'_'+str(run)+'_'+str(dot_size), start_atoms, 'a')
		
		# calculate RMS translation
		D = 0.0
		for a,b in zip(start_atoms,end_atoms):
			D += ((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z))**(0.5)
		#procrustes_distance = (D/len(start_atoms))**0.5
		procrustes_distance = D/len(start_atoms)
		#print procrustes_distance
		
		# relative separations
		# for the core:
		coreD = 0.0
		for a1,b1 in zip(start_atoms[0:dot_size*2],end_atoms[0:dot_size*2]):
			for a2,b2 in zip(start_atoms[0:dot_size*2],end_atoms[0:dot_size*2]):
				coreD += abs(((a1.x-a2.x)*(a1.x-a2.x) + (a1.y-a2.y)*(a1.y-a2.y) + (a1.z-a2.z)*(a1.z-a2.z))**(0.5) - ((b1.x-b2.x)*(b1.x-b2.x) + (b1.y-b2.y)*(b1.y-b2.y) + (b1.z-b2.z)*(b1.z-b2.z))**(0.5))
		
		coreD = coreD/(dot_size*2)/(dot_size*2-1)
		print 'core:', coreD
		
		# for the ligands (average over all the ligands)
		ligD = [0.0]*((Natoms-2*dot_size)/10)
		for i in range((Natoms-2*dot_size)/10):
			for a1,b1 in zip(start_atoms[dot_size*2+10*i:dot_size*2+10*(i+1)],end_atoms[dot_size*2+10*i:dot_size*2+10*(i+1)]):
				for a2,b2 in zip(start_atoms[dot_size*2+10*i:dot_size*2+10*(i+1)],end_atoms[dot_size*2+10*i:dot_size*2+10*(i+1)]):
					ligD[i] += abs(((a1.x-a2.x)*(a1.x-a2.x) + (a1.y-a2.y)*(a1.y-a2.y) + (a1.z-a2.z)*(a1.z-a2.z))**(0.5) - ((b1.x-b2.x)*(b1.x-b2.x) + (b1.y-b2.y)*(b1.y-b2.y) + (b1.z-b2.z)*(b1.z-b2.z))**(0.5))
		
			ligD[i] = ligD[i]/10/9
		#print ligD
		ligDavg = (sum(a for a in ligD))/len(ligD)
		print 'lig:', ligDavg
		allD = 0.0
		for a1,b1 in zip(start_atoms,end_atoms):
			for a2,b2 in zip(start_atoms,end_atoms):
				allD += abs(((a1.x-a2.x)*(a1.x-a2.x) + (a1.y-a2.y)*(a1.y-a2.y) + (a1.z-a2.z)*(a1.z-a2.z))**(0.5) - ((b1.x-b2.x)*(b1.x-b2.x) + (b1.y-b2.y)*(b1.y-b2.y) + (b1.z-b2.z)*(b1.z-b2.z))**(0.5))
		
		allD = allD/Natoms/(Natoms-1)
		print 'all:', allD
		
		
		for a1,b1 in zip(start_atoms[0:dot_size],end_atoms[0:dot_size]):
			for a2,b2 in zip(start_atoms[dot_size:dot_size*2],end_atoms[dot_size:dot_size*2]):
				lattice_start += [((a1.x-a2.x)*(a1.x-a2.x) + (a1.y-a2.y)*(a1.y-a2.y) + (a1.z-a2.z)*(a1.z-a2.z))**(0.5)]
				lattice_end += [((b1.x-b2.x)*(b1.x-b2.x) + (b1.y-b2.y)*(b1.y-b2.y) + (b1.z-b2.z)*(b1.z-b2.z))**(0.5)]
Ejemplo n.º 9
0
def analyze_binding():
    for n in [
            'propanenitrile', 'butanenitrile', 'pentanenitrile',
            'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2',
            'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2',
            'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2'
    ]:

        contents = open('lammps/bind3_' + n + '.log').read()

        opls_binding_e = float(
            re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))

        try:
            e_pair = gaussian.parse_atoms('gaussian/bind3_' + n +
                                          '_opt1.1.log',
                                          check_convergence=False)[0]
        except:
            e_pair = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt1.log',
                                          check_convergence=False)[0]

        try:
            e_pair_scrf = gaussian.parse_atoms('gaussian/bind3_' + n +
                                               '_opt2.1.log',
                                               check_convergence=False)[0]
        except:
            e_pair_scrf = gaussian.parse_atoms('gaussian/bind3_' + n +
                                               '_opt2.log',
                                               check_convergence=False)[0]

        e_single = gaussian.parse_atoms('gaussian/' + n + '_0.log')[0]
        e_single_scrf = gaussian.parse_atoms('gaussian/' + n + '_1.log')[0]

        try:
            bsse = gaussian.parse_atoms(
                'gaussian/bind3_' + n +
                '_opt1a.log')[0] + gaussian.parse_atoms(
                    'gaussian/bind3_' + n +
                    '_opt1b.log')[0] - gaussian.parse_atoms(
                        'gaussian/bind3_' + n +
                        '_opt1a_Bq.log')[0] - gaussian.parse_atoms(
                            'gaussian/bind3_' + n + '_opt1b_Bq.log')[0]
        except:
            print 1, n
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1a_Bq.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1b_Bq.log') is None
            bsse = 0.0

        try:
            bsse_scrf = gaussian.parse_atoms(
                'gaussian/bind3_' + n +
                '_opt2a.log')[0] + gaussian.parse_atoms(
                    'gaussian/bind3_' + n +
                    '_opt2b.log')[0] - gaussian.parse_atoms(
                        'gaussian/bind3_' + n +
                        '_opt2a_Bq.log')[0] - gaussian.parse_atoms(
                            'gaussian/bind3_' + n + '_opt2b_Bq.log')[0]
        except:
            print 2, n
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2a_Bq.log') is None
            #print gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2b_Bq.log') is None
            bsse_scrf = 0.0

        #No such file or directory: 'gaussian/bind3_aminopentane2_opt2b_Bq.log
        #No such file or directory: 'gaussian/bind3_aminobutane2_opt2a_Bq.log'

        #print n, opls_binding_e, e_pair, e_single, bsse, e_pair_scrf, e_single_scrf, bsse_scrf

        print n, ',', opls_binding_e, ',', (
            e_pair - 2 * e_single + bsse) * 627, ',', (
                e_pair_scrf - 2 * e_single_scrf + bsse_scrf) * 627
Ejemplo n.º 10
0
def compare():
    utils.Molecule.set_params('oplsaa4.prm')
    for f in [
            'propanenitrile', 'butanenitrile', 'pentanenitrile',
            'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2',
            'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2',
            'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2'
    ]:
        atoms0 = utils.Molecule(f + '.arc').atoms
        atoms1 = gaussian.parse_atoms('gaussian/' + f + '_0.log')[1]
        for i in range(len(atoms0)):
            atoms0[i].index = i + 1
            atoms1[i].index = i + 1

            #atoms0[i].x = atoms1[i].xp
            #atoms0[i].y = atoms1[i].y
            #atoms0[i].z = atoms1[i].z

        bonds0 = filetypes.get_bonds(atoms0)
        bonds1 = filetypes.get_bonds(atoms1)

        #filetypes.write_arc(f[:-1]+'3', atoms0)
        #continue

        angles0, dihedrals0 = filetypes.get_angles_and_dihedrals(
            atoms0, bonds0)
        angles1, dihedrals1 = filetypes.get_angles_and_dihedrals(
            atoms1, bonds1)

        bond_error = 0.0
        for i in range(len(bonds0)):
            bond_error += abs(bonds0[i].d - bonds1[i].d)

        angles0.sort(key=lambda a: tuple([n.index for n in a.atoms]))
        angles1.sort(key=lambda a: tuple([n.index for n in a.atoms]))

        angle_error = 0.0
        for i in range(len(angles0)):
            angle_error += min(
                abs(angles0[i].theta - angles1[i].theta),
                abs(angles0[i].theta - angles1[i].theta + math.pi * 2),
                abs(angles0[i].theta - angles1[i].theta - math.pi * 2))

        dihedrals0.sort(key=lambda a: tuple([n.index for n in a.atoms]))
        dihedrals1.sort(key=lambda a: tuple([n.index for n in a.atoms]))

        angles_by_atoms = {}
        for angle in angles1:
            angles_by_atoms[tuple(angle.atoms)] = angle
            angles_by_atoms[tuple(reversed(angle.atoms))] = angle

        if dihedrals0:
            dihedral_error = 0.0
            for i in range(len(dihedrals0)):
                #if dihedral only controls a 180-degree angle, ignore comparison

                angle1 = angles_by_atoms[tuple(dihedrals1[i].atoms[1:])]
                angle2 = angles_by_atoms[tuple(dihedrals1[i].atoms[:-1])]

                #print angle1.theta, angle2.theta,

                if abs(angle1.theta -
                       180) < 2 or abs(angle1.theta + 180) < 2 or abs(
                           angle2.theta - 180) < 2 or abs(angle2.theta +
                                                          180) < 2:
                    #print angle1.theta, angle2.theta,
                    continue

                #if dihedral is single-bonded free rotor, ignore comparison
                if (dihedrals0[i].atoms[1].type.index,
                        dihedrals0[i].atoms[1].type.index) == (78, 78):
                    continue
                #else make comparison
                try:
                    a, b = utils.dihedral_angle(
                        *dihedrals0[i].atoms)[0], utils.dihedral_angle(
                            *dihedrals1[i].atoms)[0]
                    dihedral_error += min(abs(a - b), abs(a - b + math.pi * 2),
                                          abs(a - b - math.pi * 2))

                    #print [aa.element for aa in dihedrals0[i].atoms], min( abs(a-b), abs(a-b+math.pi*2), abs(a-b-math.pi*2) )
                except ZeroDivisionError:
                    pass

            print f, bond_error / len(bonds0), angle_error / len(
                angles0), 180 / math.pi * dihedral_error / len(dihedrals0)
        else:
            print f, bond_error / len(bonds0), angle_error / len(angles0), 0.0
Ejemplo n.º 11
0
def binding():
    #for n in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
    for n in ['aminobutane2']:

        contents = open('lammps/bind3_' + n + '.log').read()

        opls_binding_e = float(
            re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))

        atoms = filetypes.parse_xyz('bind3_' + n + '.xyz')

        #opt0: use B97D
        #gaussian.job(atoms, 'B97D/TZVP/Fit', 'batch', 'bind3_'+n+'_opt0', 'Opt=Cartesian', procs=1)

        #opt1: use M062X
        #os.system('cp gaussian/bind3_'+n+'_opt0.chk gaussian/bind3_'+n+'_opt1.chk')
        #gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1', 'Opt=Cartesian Geom=AllCheck Guess=Read', procs=1)
        #opt2: M062X with solvent
        #os.system('cp gaussian/bind3_'+n+'_opt0.chk gaussian/bind3_'+n+'_opt2.chk')
        #gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2', 'Opt=Cartesian Geom=AllCheck Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
        '''
		jlist = subprocess.Popen('jlist', shell=True, stdout=subprocess.PIPE).communicate()[0]
		if ' bind3_'+n+'_opt1 ' not in jlist and ' bind3_'+n+'_opt1.1 ' not in jlist and gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.log') is None and (not os.path.isfile('gaussian/bind3_'+n+'_opt1.1.log') or gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.1.log') is None):
			os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1.1.chk')
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1.1', 'Opt=Restart', procs=1)
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1.1', 'Opt=Cartesian Geom=AllCheck Guess=Read', procs=1)
			print 'bind3_'+n+'_opt1.1'
		if ' bind3_'+n+'_opt2 ' not in jlist and ' bind3_'+n+'_opt2.1 ' not in jlist and gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.log') is None and (not os.path.isfile('gaussian/bind3_'+n+'_opt2.1.log') or gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.1.log') is None):
			os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2.1.chk')
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2.1', 'Opt=Restart SCRF(Solvent=n-Hexane)', procs=1)
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2.1', 'Opt=Cartesian Geom=AllCheck Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
			print 'bind3_'+n+'_opt2.1'
		continue
		'''

        #Find BSSE without solvent (on opt1)
        #os.system('cp gaussian/'+n+'_0.chk gaussian/bind3_'+n+'_opt1a.chk')
        #os.system('cp gaussian/'+n+'_0.chk gaussian/bind3_'+n+'_opt1b.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1a_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1b_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt1.1.chk gaussian/bind3_'+n+'_opt1a_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt1.1.chk gaussian/bind3_'+n+'_opt1b_Bq.chk')
        try:
            atoms = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt1.1.log',
                                         check_convergence=False)[1]
        except:
            atoms = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt1.log',
                                         check_convergence=False)[1]
        #gaussian.job(atoms[ : len(atoms)/2 ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1a', 'Guess=Read', procs=1)
        #gaussian.job(atoms[ len(atoms)/2 : ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1b', 'Guess=Read', procs=1)
        atoms_a = copy.deepcopy(atoms)
        for a in atoms_a[:len(atoms) / 2]:
            a.element = a.element + '-Bq'
        #gaussian.job(atoms_a, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1a_Bq', 'Guess=Read', procs=1)
        for a in atoms[len(atoms) / 2:]:
            a.element = a.element + '-Bq'
        #gaussian.job(atoms, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1b_Bq', 'Guess=Read', procs=1)

        #Find BSSE with solvent (on opt2)
        #os.system('cp gaussian/'+n+'_1.chk gaussian/bind3_'+n+'_opt2a.chk')
        #os.system('cp gaussian/'+n+'_1.chk gaussian/bind3_'+n+'_opt2b.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2a_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2b_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt2.1.chk gaussian/bind3_'+n+'_opt2a_Bq.chk')
        #os.system('cp gaussian/bind3_'+n+'_opt2.1.chk gaussian/bind3_'+n+'_opt2b_Bq.chk')
        try:
            atoms = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt2.1.log',
                                         check_convergence=False)[1]
        except:
            atoms = gaussian.parse_atoms('gaussian/bind3_' + n + '_opt2.log',
                                         check_convergence=False)[1]
        #gaussian.job(atoms[ : len(atoms)/2 ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2a', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
        #gaussian.job(atoms[ len(atoms)/2 : ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2b', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
        atoms_a = copy.deepcopy(atoms)
        for a in atoms_a[:len(atoms) / 2]:
            a.element = a.element + '-Bq'
        gaussian.job(atoms_a,
                     'M062X/aug-cc-pVDZ',
                     'batch',
                     'bind3_' + n + '_opt2a_Bq',
                     'Guess=Read SCRF(Solvent=n-Hexane)',
                     procs=1)
        for a in atoms[len(atoms) / 2:]:
            a.element = a.element + '-Bq'
        #gaussian.job(atoms, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2b_Bq', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)

        continue

        #atoms = atoms[ : len(atoms)/2 ]
        #atoms = atoms[ len(atoms)/2 : ]

        #for a in atoms[ len(atoms)/2 : ]:
        #	a.element = a.element + '-Bq'

        #gaussian.job(atoms, 'M062X/cc-pVDZ', 'batch', n+'_sp4', 'SP', procs=1) #sp0 is pair, sp1,sp2 are single, sp3,sp4 with ghost atoms

        os.system('cp gaussian/' + n + '_sp0.chk gaussian/' + n + '_scrf0.chk')
        gaussian.job(atoms,
                     'M062X/aug-cc-pVDZ',
                     'batch',
                     n + '_scrf0',
                     'SP SCRF(Solvent=n-Hexane) Guess=Read',
                     procs=1)  #scrf0, scrf1, scrf2
        atoms1 = copy.deepcopy(atoms)
        for a in atoms1[:len(atoms) / 2]:
            a.element = a.element + '-Bq'
        os.system('cp gaussian/' + n + '_sp0.chk gaussian/' + n + '_scrf1.chk')
        gaussian.job(atoms1,
                     'M062X/aug-cc-pVDZ',
                     'batch',
                     n + '_scrf1',
                     'SP SCRF(Solvent=n-Hexane) Guess=Read',
                     procs=1)
        atoms2 = copy.deepcopy(atoms)
        for a in atoms2[len(atoms) / 2:]:
            a.element = a.element + '-Bq'
        os.system('cp gaussian/' + n + '_sp0.chk gaussian/' + n + '_scrf2.chk')
        gaussian.job(atoms2,
                     'M062X/aug-cc-pVDZ',
                     'batch',
                     n + '_scrf2',
                     'SP SCRF(Solvent=n-Hexane) Guess=Read',
                     procs=1)

        #pair = gaussian.parse_atoms('gaussian/'+n+'_sp0.log')[0]
        #single = gaussian.parse_atoms('gaussian/'+n+'_sp1.log')[0]

        #print n, opls_binding_e, 627.5*(pair - single*2)
        '''
Ejemplo n.º 12
0
	AB = gaussian.atoms(job_total)
	AB_A = copy.deepcopy(AB)
	for i,atom in enumerate(AB_A):
		if i not in zero_indexed_atom_indices_A: atom.element+='-Bq'
	AB_B = copy.deepcopy(AB)
	for i,atom in enumerate(AB_B):
		if i in zero_indexed_atom_indices_A: atom.element+='-Bq'
	#now AB_A is A from AB, AB_B is B from AB
	name1 = job(AB_A, job_total+'_A0', previous_job=job_total)
	name2 = job(AB_B, job_total+'_B0', previous_job=job_total)
	
	#non-rigid correction:
	AB_A = [atom for atom in AB_A if not atom.element.endswith('-Bq')]
	AB_B = [atom for atom in AB_B if not atom.element.endswith('-Bq')]
	name3 = job(AB_A, job_A+'_AB0', previous_job=job_A)
	name4 = job(AB_B, job_B+'_AB0'+('2' if job_A==job_B else ''), previous_job=job_B)
	
	print 'E_binding = %s - %s - %s + %s + %s - %s - %s' % (job_total, name1, name2, name3, name4, job_A, job_B)

#binding_energy_dz('4ACN_s_4_pbcl2', 'pbcl2_3acetoN_43', 'ACN_solv', range (21))

binding_energy_dz('5_acetone_5_PbCl2', 'pbcl2_4acetone_3', 'acetone_1', range (43))


for job in []:
	 print job,gaussian.parse_atoms(job)[0]
	



Ejemplo n.º 13
0
def binding():
	#for n in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
	for n in ['aminobutane2']:
		
		contents = open('lammps/bind3_'+n+'.log').read()
		
		opls_binding_e = float(re.search('\n1\s+(\S+)\s+Loop time of', contents).group(1))
		
		atoms = filetypes.parse_xyz('bind3_'+n+'.xyz')
		
		#opt0: use B97D
		#gaussian.job(atoms, 'B97D/TZVP/Fit', 'batch', 'bind3_'+n+'_opt0', 'Opt=Cartesian', procs=1)
		
		#opt1: use M062X
		#os.system('cp gaussian/bind3_'+n+'_opt0.chk gaussian/bind3_'+n+'_opt1.chk')
		#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1', 'Opt=Cartesian Geom=AllCheck Guess=Read', procs=1)
		#opt2: M062X with solvent
		#os.system('cp gaussian/bind3_'+n+'_opt0.chk gaussian/bind3_'+n+'_opt2.chk')
		#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2', 'Opt=Cartesian Geom=AllCheck Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
		
		'''
		jlist = subprocess.Popen('jlist', shell=True, stdout=subprocess.PIPE).communicate()[0]
		if ' bind3_'+n+'_opt1 ' not in jlist and ' bind3_'+n+'_opt1.1 ' not in jlist and gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.log') is None and (not os.path.isfile('gaussian/bind3_'+n+'_opt1.1.log') or gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.1.log') is None):
			os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1.1.chk')
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1.1', 'Opt=Restart', procs=1)
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1.1', 'Opt=Cartesian Geom=AllCheck Guess=Read', procs=1)
			print 'bind3_'+n+'_opt1.1'
		if ' bind3_'+n+'_opt2 ' not in jlist and ' bind3_'+n+'_opt2.1 ' not in jlist and gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.log') is None and (not os.path.isfile('gaussian/bind3_'+n+'_opt2.1.log') or gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.1.log') is None):
			os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2.1.chk')
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2.1', 'Opt=Restart SCRF(Solvent=n-Hexane)', procs=1)
			#gaussian.job([], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2.1', 'Opt=Cartesian Geom=AllCheck Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
			print 'bind3_'+n+'_opt2.1'
		continue
		'''
		
		#Find BSSE without solvent (on opt1)
		#os.system('cp gaussian/'+n+'_0.chk gaussian/bind3_'+n+'_opt1a.chk')
		#os.system('cp gaussian/'+n+'_0.chk gaussian/bind3_'+n+'_opt1b.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1a_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt1.chk gaussian/bind3_'+n+'_opt1b_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt1.1.chk gaussian/bind3_'+n+'_opt1a_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt1.1.chk gaussian/bind3_'+n+'_opt1b_Bq.chk')
		try:
			atoms = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.1.log', check_convergence=False)[1]
		except:
			atoms = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt1.log', check_convergence=False)[1]
		#gaussian.job(atoms[ : len(atoms)/2 ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1a', 'Guess=Read', procs=1)
		#gaussian.job(atoms[ len(atoms)/2 : ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1b', 'Guess=Read', procs=1)
		atoms_a = copy.deepcopy(atoms)
		for a in atoms_a[ : len(atoms)/2 ]:
			a.element = a.element + '-Bq'
		#gaussian.job(atoms_a, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1a_Bq', 'Guess=Read', procs=1)
		for a in atoms[ len(atoms)/2 : ]:
			a.element = a.element + '-Bq'
		#gaussian.job(atoms, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt1b_Bq', 'Guess=Read', procs=1)
		
		
		#Find BSSE with solvent (on opt2)
		#os.system('cp gaussian/'+n+'_1.chk gaussian/bind3_'+n+'_opt2a.chk')
		#os.system('cp gaussian/'+n+'_1.chk gaussian/bind3_'+n+'_opt2b.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2a_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt2.chk gaussian/bind3_'+n+'_opt2b_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt2.1.chk gaussian/bind3_'+n+'_opt2a_Bq.chk')
		#os.system('cp gaussian/bind3_'+n+'_opt2.1.chk gaussian/bind3_'+n+'_opt2b_Bq.chk')
		try:
			atoms = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.1.log', check_convergence=False)[1]
		except:
			atoms = gaussian.parse_atoms('gaussian/bind3_'+n+'_opt2.log', check_convergence=False)[1]
		#gaussian.job(atoms[ : len(atoms)/2 ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2a', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
		#gaussian.job(atoms[ len(atoms)/2 : ], 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2b', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
		atoms_a = copy.deepcopy(atoms)
		for a in atoms_a[ : len(atoms)/2 ]:
			a.element = a.element + '-Bq'
		gaussian.job(atoms_a, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2a_Bq', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
		for a in atoms[ len(atoms)/2 : ]:
			a.element = a.element + '-Bq'
		#gaussian.job(atoms, 'M062X/aug-cc-pVDZ', 'batch', 'bind3_'+n+'_opt2b_Bq', 'Guess=Read SCRF(Solvent=n-Hexane)', procs=1)
		
		continue
		
		#atoms = atoms[ : len(atoms)/2 ]
		#atoms = atoms[ len(atoms)/2 : ]
		
		#for a in atoms[ len(atoms)/2 : ]:
		#	a.element = a.element + '-Bq'
		
		#gaussian.job(atoms, 'M062X/cc-pVDZ', 'batch', n+'_sp4', 'SP', procs=1) #sp0 is pair, sp1,sp2 are single, sp3,sp4 with ghost atoms
		
		os.system('cp gaussian/'+n+'_sp0.chk gaussian/'+n+'_scrf0.chk')
		gaussian.job(atoms, 'M062X/aug-cc-pVDZ', 'batch', n+'_scrf0', 'SP SCRF(Solvent=n-Hexane) Guess=Read', procs=1) #scrf0, scrf1, scrf2
		atoms1 = copy.deepcopy(atoms)
		for a in atoms1[ : len(atoms)/2 ]:
			a.element = a.element + '-Bq'
		os.system('cp gaussian/'+n+'_sp0.chk gaussian/'+n+'_scrf1.chk')
		gaussian.job(atoms1, 'M062X/aug-cc-pVDZ', 'batch', n+'_scrf1', 'SP SCRF(Solvent=n-Hexane) Guess=Read', procs=1)
		atoms2 = copy.deepcopy(atoms)
		for a in atoms2[ len(atoms)/2 : ]:
			a.element = a.element + '-Bq'
		os.system('cp gaussian/'+n+'_sp0.chk gaussian/'+n+'_scrf2.chk')
		gaussian.job(atoms2, 'M062X/aug-cc-pVDZ', 'batch', n+'_scrf2', 'SP SCRF(Solvent=n-Hexane) Guess=Read', procs=1)
		
		#pair = gaussian.parse_atoms('gaussian/'+n+'_sp0.log')[0]
		#single = gaussian.parse_atoms('gaussian/'+n+'_sp1.log')[0]
		
		#print n, opls_binding_e, 627.5*(pair - single*2)
		
		'''
Ejemplo n.º 14
0
def compare():
	utils.Molecule.set_params('oplsaa4.prm')
	for f in ['propanenitrile', 'butanenitrile', 'pentanenitrile', 'hexanenitrile', 'aminopropane2', 'aminobutane2', 'aminopentane2', 'aminohexane2', 'hexane2', 'methane', 'hcn2', 'cyanoacetylene2', 'acrylonitrile2', 'cyanoallene2', 'acetonitrile2', 'hc5n2']:
		atoms0 = utils.Molecule(f+'.arc').atoms
		atoms1 = gaussian.parse_atoms('gaussian/'+f+'_0.log')[1]
		for i in range(len(atoms0)):
			atoms0[i].index = i+1
			atoms1[i].index = i+1
			
			#atoms0[i].x = atoms1[i].xp
			#atoms0[i].y = atoms1[i].y
			#atoms0[i].z = atoms1[i].z
	
		bonds0 = filetypes.get_bonds(atoms0)
		bonds1 = filetypes.get_bonds(atoms1)
		
		#filetypes.write_arc(f[:-1]+'3', atoms0)
		#continue
		
		angles0, dihedrals0 = filetypes.get_angles_and_dihedrals(atoms0, bonds0)
		angles1, dihedrals1 = filetypes.get_angles_and_dihedrals(atoms1, bonds1)
		
		bond_error = 0.0
		for i in range(len(bonds0)):
			bond_error += abs(bonds0[i].d - bonds1[i].d)
		
		angles0.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		angles1.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		
		angle_error = 0.0
		for i in range(len(angles0)):
			angle_error += min( abs(angles0[i].theta - angles1[i].theta), abs(angles0[i].theta - angles1[i].theta+math.pi*2), abs(angles0[i].theta - angles1[i].theta-math.pi*2) )
			
		dihedrals0.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		dihedrals1.sort(key=lambda a: tuple([n.index for n in a.atoms]) )
		
		angles_by_atoms = {}
		for angle in angles1:
			angles_by_atoms[ tuple(angle.atoms) ] = angle
			angles_by_atoms[ tuple(reversed(angle.atoms)) ] = angle
		
		if dihedrals0:
			dihedral_error = 0.0
			for i in range(len(dihedrals0)):
				#if dihedral only controls a 180-degree angle, ignore comparison
				
				angle1 = angles_by_atoms[ tuple(dihedrals1[i].atoms[1:]) ]
				angle2 = angles_by_atoms[ tuple(dihedrals1[i].atoms[:-1]) ]
				
				#print angle1.theta, angle2.theta,
				
				if abs(angle1.theta-180)<2 or abs(angle1.theta+180)<2 or abs(angle2.theta-180)<2 or abs(angle2.theta+180)<2:
					#print angle1.theta, angle2.theta, 
					continue
				
				#if dihedral is single-bonded free rotor, ignore comparison
				if (dihedrals0[i].atoms[1].type.index,dihedrals0[i].atoms[1].type.index) == (78,78):
					continue
				#else make comparison
				try:
					a,b = utils.dihedral_angle(*dihedrals0[i].atoms)[0], utils.dihedral_angle(*dihedrals1[i].atoms)[0]
					dihedral_error += min( abs(a-b), abs(a-b+math.pi*2), abs(a-b-math.pi*2) )
					
					#print [aa.element for aa in dihedrals0[i].atoms], min( abs(a-b), abs(a-b+math.pi*2), abs(a-b-math.pi*2) )
				except ZeroDivisionError: pass
		
			print f, bond_error/len(bonds0), angle_error/len(angles0), 180/math.pi*dihedral_error/len(dihedrals0)
		else:
			print f, bond_error/len(bonds0), angle_error/len(angles0), 0.0