def grep_aimd(inputfile): # Routine for the extraction of AIMD geometries, MOs and energies. # The geometries are converted to the zmat format using babel. a = qc.read(inputfile) # Get geometries in zmat format geo_list = [] for geo in a.aimd.geometries: geo.write('dummy.xyz') os.system('babel dummy.xyz dummy.gzmat') infile = open('dummy.gzmat', 'r') content = infile.readlines() infile.close() os.system('rm dummy.xyz; rm dummy.gzmat') geometry = [] for line in content: if '=' in line: dummy = line.split('=') geometry.append(float(dummy[1])) geometry = np.asarray(geometry) geo_list.append(geometry) # Get Overlap Matrices #overlap_list=grep_overlap(inputfile) # Get Core Hamiltonians core_list = grep_core(inputfile) # Get Fock Matrices fock_list = grep_fock(inputfile) # Get MO-Energies e_mos = grep_e_mo(inputfile) # Get MOs mos_list = grep_MOs(inputfile) # Get energies energies = a.aimd.energies # Get nuclear repulsion energies e_rep = grep_nuc_rep(inputfile) # Get basis set information (atom_indices, basis_types) = grep_basis_info(inputfile) # Q-Chem does extra SCF before AIMD starts, # so first entries of 'e_mos', 'mos', 'core', 'fock', 'overlap' and 'e_rep' have to be cut del e_rep[0] del e_mos[0] del mos_list[0] del fock_list[0] del core_list[0] #del overlap_list[0] return (geo_list, e_rep, core_list, fock_list, e_mos, mos_list, energies, atom_indices, basis_types)
def grep_sp(inputfile): # Routine for the extraction of AIMD geometries, MOs and energies. # The geometries are converted to the zmat format using babel. a = qc.read(inputfile, silent=True) # Get Overlap Matrices overlap = grep_overlap(inputfile) # Get Core Hamiltonians core = grep_core(inputfile) # Get Fock Matrices fock = grep_fock(inputfile) # Get MO-Energies e_mos = grep_e_mo(inputfile) # Get MOs #mos = grep_MOs_sp(inputfile) # Get Density Matrix density = grep_density(inputfile) # Get energies energy = a.general.energy # Get nuclear repulsion energies e_rep = grep_nuc_rep(inputfile) # Get basis set information #(atom_indices,basis_types) = grep_basis_info(inputfile) # Get Mulliken charges mull = grep_mull(inputfile) return (e_rep, overlap, core, fock, e_mos, density, energy, mull)
# pyQChem script for a AIMD follow-up with reduced basis set size # # AWH/RM 2015 import pyQChem as qc # First, read all N geometries from aimd outputfile a = qc.read('aimd_small.out') aa = a.list_of_jobs[1] # Second, create the template myrem = qc.rem_array() myrem.jobtype('sp') myrem.exchange('hf') myrem.basis('sto-3g') myrem.scf_algorithm('rca_diis') #myrem.max_rca_cycles('10') #myrem.thresh_rca_switch('7') myrem.scf_guess('sad') myrem.scf_convergence('9') myrem.thresh('14') myrem.incfock('0') myrem.incdft('0') #myrem.max_scf_cycles('500') #myrem.symmetry('false') #myrem.sym_ignore('true') myrem.mem_total('16000') myrem.mem_static('4000') # Add rem_array myfile = qc.inputfile()
def __init__(self, infile,charge=0,mult=1,jobtype='opt',basis='6-31+g*',method='tpssh', \ geom_read=False, nametrunc=True, bond_cons = None, infodump=False): self.jobdict = {'sp':self.jobSp, 'opt':self.jobOpt, 'fq':self.jobFreq, 'sopt':self.jobSopt, \ 'cube':self.jobCube, 'constr':self.jobConstrainedOpt, 'fixbonds':self.jobFixedBondOpt, \ 'cdft':self.jobCdft, \ } # self.bond_cons = [[2,5,con_N_x],[3,4,con_N_x],[2,3,con_N_y],[4,5,con_N_y]] self.bond_cons = bond_cons self.info_dump = infodump # self.free_atom = ['Fe','O'] self.free_atom = ['O'] self.job_arr_list = [] self.charge = charge self.mult = mult self.jobtype = jobtype self.pcm_arr = None self.sol_arr = None self.plot_arr = None #if nametrunc == True: self.name = (infile.split('.')[0]).split('_')[0] #else: self.name = infile.split('.')[0] splinfile = infile.split('/') if len(splinfile) == 1: self.path = '' else: self.path = '/'.join(splinfile[:-1]) + '/' if nametrunc == True: self.name = (splinfile[-1].split('.')[0]).split('_')[0] else: self.name = (splinfile[-1].split('.'))[0] print(splinfile) print(splinfile[-1]) print(self.name) print(self.charge) print(self.mult) self.out = qc.read(infile) self.rem = qc.rem_array() self.rem.basis(basis) self.rem.method(method) self.rem.thresh("14") self.rem.add('mem_total', '4096') self.rem.add('mem_static', '256') self.rem.add('max_scf_cycles', '500') # self.rem.add('scf_convergence','7') # self.rem.add('scf_algorithm','diis_gdm') ##For these metal-centered systems self.rem.add('unrestricted', 'true') # if self.mult == '1': ## I didn't find that this worked at all for any of the metal-macrocycle systems # self.rem.add("scf_guess_mix", "1") # self.rem.add("scf_guess", "gwh") if geom_read: self.mol = qc.mol_array() self.mol.geometry("read") self.rem.add('scf_guess', 'read') else: if infile.split('.')[-1] == 'out': # self.mol=qc.mol_array(self.out.opt.geometries[-1]) self.mol = qc.mol_array(self.out.general.final_geometry) # self.mol = qc.mol_array(self.out.general.initial_geometry) else: xyz = qc.cartesian(atom_list=self.out.list_of_atoms) self.mol = qc.mol_array(xyz) self.mol.charge(charge) self.mol.multiplicity(mult)
rem = qc.rem_array() rem.basis("sto-3g") rem.jobtype("opt") xyz = qc.cartesian() xyz.add_atom() xyz.add_atom("H", "0", "0", ".74") molec = qc.mol_array(xyz) job = qc.inputfile() job.add(rem) job.add(molec) #run job with name "h2" making h2.in h2.sh, and h2.out job.run(name="h2") #read in output out = qc.read("h2.out") out.opt.info() #let's approximate how much this has changed #grab first geometry start = out.opt.geometries[0] #grab last geometry end = out.opt.geometries[-1] #Print statistics for geometric distortions print "\n\nApproximate change between starting and ending geometries by two metrics:\n" print qc.utilities.rmsd(start.xyzs, end.xyzs), " or ", qc.utilities.kabsch( start.xyzs, end.xyzs), "\n"
# # This sample file generates center-of-mass displaced water molecules from the standard water dimer # and loops through different multiplicative displacements # # MBG (02/2014) # import pyQChem as qc import os from pylab import * #load some sample inputs - here the first and second monomers of the water dimer a = qc.read("../../databases/s22/Water-dimer_mono1.xyz") a.name = "water-dimer_mono1" b = qc.read("../../databases/s22/Water-dimer_mono2.xyz") b.name = "water-dimer_mono2" #Save direction and magnitude d = b.com - a.com #Translate both to origin a.move(-a.com) b.move(-b.com) #loop over a multiplicative factor for center of mass distance and generate jobs for i in arange(.9, 2.01, .1): #translate to new coordinates a.move(-i * d / 2) b.move(i * d / 2) #form new dimer
import pyQChem as qc import os #make a generic rem array rem = qc.rem_array() rem.basis("sto-3g") rem.exchange("hf") #make a list of jobs job_list = [] #for all xyzs in a database, create and append the job to the list for i in os.popen("ls ../../databases/a24/*.xyz").read().splitlines(): #make the jobs job = qc.inputfile() #give job a name job.runinfo.name = i.split('/')[-1].replace(".xyz", "") #read the xyz xyz = qc.read(i) #append the molecule and rem array job.add(qc.mol_array(xyz)) job.add(rem) job_list.append(job) # run all jobs in list using 12 workers qc.queue(job_list, num_workers=12)
import pyQChem as qc import os #make a generic rem array rem=qc.rem_array() rem.basis("sto-3g") rem.exchange("hf") #make a list of jobs job_list=[] #for all xyzs in a database, create and append the job to the list for i in os.popen("ls ../../databases/a24/*.xyz").read().splitlines(): #make the jobs job=qc.inputfile() #give job a name job.runinfo.name=i.split('/')[-1].replace(".xyz","") #read the xyz xyz=qc.read(i) #append the molecule and rem array job.add(qc.mol_array(xyz)) job.add(rem) job_list.append(job) # run all jobs in list using 12 workers qc.queue(job_list,num_workers=12)
rem1=pq.rem_array() rem1.basis("6-31++G**") rem1.exchange("hf") rem1.thresh("14") rem1.scf_convergence("10") from copy import deepcopy rem2=deepcopy(rem1) rem2.scf_guess("fragmo") #make a rem_frgm array rem_frgm=pq.rem_frgm_array() rem_frgm.thresh("7") rem_frgm.scf_convergence("3") #make objects for holding the molecular geometries xyz=pq.read("4water.xyz") frag=pq.fragment(atom_list=xyz.list_of_atoms) #make molecule array from cartesian object mol1=pq.mol_array(xyz) mol2=pq.mol_array(frag) #make input object and write to disk job1=pq.inputfile() job1.add(rem1) job1.add(mol1) job2=pq.inputfile() job2.add(rem2) job2.rem.scf_guess("fragmo") job2.add(rem_frgm)
#generate rem array, cartesian object, mol array, and job via standard procedure (see input demos) rem=qc.rem_array() rem.basis("6-31g") rem.jobtype("sp") rem.method("adc(2)") rem.ee_singlets("[2,0,0,0,0,2,0,0]") xyz=qc.cartesian() xyz.add_atom() xyz.add_atom("H","0","0",".74") molec=qc.mol_array(xyz) job=qc.inputfile() job.add(rem) job.add(molec) #run job with name "h2" making h2.in h2.sh, and h2.out job.run(name="h2") #read in output out=qc.read("h2.out") out.adc.info() #let's compute the excitation energies between the excited states print "\nExcitation energies between excited states:" for i in range(0,len(out.adc.list_of_excited_states)-1): es1 = out.adc.list_of_excited_states[i] for j in range(i + 1,len(out.adc.list_of_excited_states)): es2 = out.adc.list_of_excited_states[j] print("{0:10s} -> {1:10s}: {2:12.6f}".format(es1.term_symbol, es2.term_symbol,es2.energy - es1.energy))
# # This sample file generates center-of-mass displaced water molecules from the standard water dimer # and loops through different multiplicative displacements # # MBG (02/2014) # import pyQChem as qc import os from pylab import * #load some sample inputs - here the first and second monomers of the water dimer a=qc.read("../../databases/s22/Water-dimer_mono1.xyz") a.name="water-dimer_mono1" b=qc.read("../../databases/s22/Water-dimer_mono2.xyz") b.name="water-dimer_mono2" #Save direction and magnitude d=b.com-a.com #Translate both to origin a.move(-a.com) b.move(-b.com) #loop over a multiplicative factor for center of mass distance and generate jobs for i in arange(.9,2.01,.1): #translate to new coordinates a.move(-i*d/2) b.move(i*d/2) #form new dimer