def main(): logFile = open(sys.argv[1], 'r') file = logFile inertiaFile = open('inertia.dat', 'r') (geom, Mass) = readGeomFc.readGeom(logFile) (rotors) = readGeomFc.readGeneralInertia(inertiaFile) D = calculateD(geom, Mass, rotors) (l, v) = linalg.eigh(D) print(l, linalg.det(D))
def main(): logFile = open(sys.argv[1],'r') file = logFile inertiaFile = open('inertia.dat','r') (geom,Mass)=readGeomFc.readGeom(logFile) (rotors)= readGeomFc.readGeneralInertia(inertiaFile) #D=calculateI23(geom,Mass,rotors) D=calculateD(geom,Mass,rotors) (l,v)= linalg.eigh(D) print l, linalg.det(D)
numIter = 20000 theory = ' b3lyp/6-31G(d) ' numprocessors = 8 memory = ' 1000MB ' multi = ' 2' #file = open(sys.argv[1],'r') inertia = open('inertia.dat', 'r') result = open('dihed_energy.out', 'w') outputName = '0.log' energy = readGeomFc.readHFEnergy(outputName) outFile = open('0.log', 'r') (geom, Mass) = readGeomFc.readGeom(outFile) (rotors) = readGeomFc.readGeneralInertia(inertia, Mass) numRotors = len(rotors) - 1 atoms = readGeomFc.getAtoms(Mass) diheds = numRotors * [0] for i in range(numRotors): result.write('%10.3f' % diheds[i]) result.write('%14.7f' % energy + '\n') for i in range(12**(numRotors)): # diheds = random.rand(len(rotors)-1)*360 irem = i for j in range(len(rotors) - 1): diheds[j] = (irem - irem / 12 * 12) * 30.0 irem = irem / 12
def __init__(self,file, isTS): self.Freq = [] self.Harmonics = [] self.hindFreq = [] self.bonds = [] self.Etype = '' self.TS = isTS self.E0 = [] #read dummy line "MOL #" line = readGeomFc.readMeaningfulLine(file) #self.linearity = line.split()[0].upper #read linearity line = readGeomFc.readMeaningfulLine(file) if line.split()[0].upper() == 'NONLINEAR' : self.linearity = 'Nonlinear' elif line.split()[0].upper() == 'LINEAR' : self.linearity = 'Linear' elif line.split()[0].upper() == 'ATOM' : self.linearity = 'Atom' else : print 'Linearity keyword not recognized ' + line exit() #linearity = line.split()[0].upper # read geometry line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() != 'GEOM' : print 'Geom keyword not found in the input file' + line exit() if len(tokens) == 1: #geometry is given following the GEOM keyword line = readGeomFc.readMeaningfulLine(file) numAtoms = int(line.split()[0]) self.geom = matrix(array(zeros((numAtoms,3),dtype=float))) self.Mass = matrix(array(zeros((numAtoms,1),dtype=float))) for i in range(numAtoms): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() self.geom[i,0]=double(tokens[3]) self.geom[i,1]=double(tokens[4]) self.geom[i,2]=double(tokens[5]) atomicNum = int(tokens[1]) if (atomicNum == 6): self.Mass[i]=12.0 if (atomicNum == 8): self.Mass[i]=15.99491 if (atomicNum == 1): self.Mass[i]=1.00783 if (atomicNum == 7): self.Mass[i]=14.0031 if (atomicNum == 17): self.Mass[i]=34.96885 if (atomicNum == 16): self.Mass[i]=31.97207 if (atomicNum == 9): self.Mass[i]=18.99840 #read geometry from the file elif tokens[1].upper() == 'FILE' : print "reading Geometry from the file: ",tokens[2] geomFile = open(tokens[2],'r') (self.geom,self.Mass) = readGeomFc.readGeom(geomFile); #print self.geom else: print 'Either give geometry or give keyword File followed by the file containing geometry data' exit() self.calculateMomInertia() # read force constant or frequency data line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() == 'FORCEC' and tokens[1].upper() == 'FILE': #MRH added following line on 2/Dec/2009 if self.linearity != 'Atom': fcfile = open(tokens[2],'r') self.Fc = readGeomFc.readFc(fcfile) for i in range(0,3*self.Mass.size): for j in range(i,3*self.Mass.size): self.Fc[i,j] = self.Fc[j,i] elif tokens[0].upper() == "FREQ" : line = readGeomFc.readMeaningfulLine(file) numFreq = int(line.split()[0]) i = 0 while (i < numFreq): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() i = i+ len(tokens) for j in tokens: self.Freq.append(float(j)) if len(self.Freq) > numFreq: print 'More frequencies than ', numFreq, ' are specified' else: print 'Frequency information cannot be read, check input file again' exit() #read energy line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if (tokens[0].upper() != 'ENERGY'): print 'Energy information not given' exit() if tokens[1].upper() == 'FILE' : print 'Reading energy from file: ', tokens[2] energyFile = open(tokens[2],'r') if (tokens[3].upper() == 'CBS-QB3'): self.Etype = 'cbsqb3' elif (tokens[3].upper() == 'G3'): self.Etype = 'g3' self.Energy = readGeomFc.readEnergy(energyFile, self.Etype) print self.Energy, self.Etype elif (len(tokens) == 3): self.Energy = float(tokens[1]) if (tokens[2].upper() == 'CBS-QB3'): self.Etype = 'cbsqb3' elif (tokens[2].upper() == 'G3'): self.Etype = 'g3' print self.Etype.upper(),' Energy: ',self.Energy else : print 'Cannot read the Energy' exit() #read external symmetry line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'EXTSYM'): print 'Extsym keyword required' exit() self.extSymm = int(line.split()[1]) #read electronic degeneracy line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'NELEC'): print 'Nelec keyword required' exit() self.nelec = int(line.split()[1]) #read rotor information line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'ROTORS'): print 'Rotors keyword required' exit() self.numRotors = int(line.split()[1]) if self.numRotors == 0: #Line added by MRH o 2/Dec/2009 #If no rotors exist and molecule is not a single atom, still need to: # (1) Check if frequencies are already computed # (2) Read in the BAC information if self.linearity != 'Atom': self.rotors = [] if (len(self.Freq) == 0): #calculate frequencies from force constant self.getFreqFromFc() line = readGeomFc.readMeaningfulLine(file) tokens = line.split() for bond in tokens: self.bonds.append(float(bond)) return # If the molecule is a single atom, no rotors exist, no frequencies need # calculating, and no BAC information needs to be read else: return rotorFile = line.split()[2] inertiaFile = open(rotorFile,'r') #print self.Mass (self.rotors)= readGeomFc.readGeneralInertia(inertiaFile,self.Mass) if len(self.rotors)-1 != self.numRotors : print "The number of rotors specified in file, ",rotorFile,' is different than, ',self.numRotors if (len(self.Freq) == 0): #calculate frequencies from force constant #Added by MRH on 2/Dec/2009 if self.linearity != 'Atom': self.getFreqFromFc() #read potential information for rotors line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() != 'POTENTIAL': print 'No information for potential given' exit() if tokens[1].upper() == 'SEPARABLE': if tokens[2].upper() == 'FILES': line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if len(tokens) != self.numRotors : print 'give a separate potential file for each rotor' for files in tokens: Kcos=[] Ksin =[] harmonic = Harmonics(5,Kcos,Ksin) harmonic.fitPotential(files) self.Harmonics.append(harmonic) elif tokens[2].upper() == 'HARMONIC': for i in range(self.numRotors): line = readGeomFc.readMeaningfulLine(file) numFit = int(line.split()[0]) Ksin = [] Kcos = [] for i in range(numFit): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() Kcos.append(tokens[0]) Ksin.append(tokens[0]) harmonic = Harmonics(numFit,Kcos,Ksin) self.Harmonics.append(harmonic) elif tokens[1].upper() == 'NONSEPARABLE': line = readGeomFc.readMeaningfulLine(file) self.potentialFile = line.split()[0] # read the energy base #line = readGeomFc.readMeaningfulLine(file) #tokens = line.split() #if (tokens[0].upper() != 'ENERGYBASE'): # print 'Keyword EnergyBase required' # exit() #self.ebase=float(tokens[1]) # read the bonds line = readGeomFc.readMeaningfulLine(file) tokens = line.split() for bond in tokens: self.bonds.append(float(bond)) #read the random seed number '''line = readGeomFc.readMeaningfulLine(file)
inputFiles = ['022.log','112.log','012.log','120.log'] #inputFiles = ['12211.log','02211.log','22211.log','11011.log','11022.log'] #inputFiles = ['111122.log','212211.log', '102022.log', '002022.log', '212122.log', '022022.log'] harmonics = file('harmonics.dat_ring','w') energy_base = readGeomFc.readHFEnergy(inputFiles[0][:-4]+'_rot0_6.log') numRotors = 4 harmonics.write(str(len(inputFiles))+'\n') for files in inputFiles: y = matrix(zeros((13,1),dtype=float)) x = matrix(zeros((13,11),dtype=float)) energy = readGeomFc.readHFEnergy(files[:-4]+'_rot0_6.log') # harmonics.write(files+'\n') (geom,Mass) = readGeomFc.readGeom(open(files,'r')) inertia = open('inertia.dat','r') (rotors) = readGeomFc.readGeneralInertia(inertia,Mass) if (files == inputFiles[0]): K = geomUtility.calculateD32(geom,Mass,rotors) detD = 1.0 for i in range(numRotors): print K[i], detD = detD*K[i] harmonics.write(str(float(detD))+'\n') harmonics.write(str((energy-energy_base)*627.5095)+'\n') if (energy < energy_base): print files, " has lower energy" exit() for i in range(numRotors): potgiven = [] for j in range(13): angle = (-60.0 + j*120.0/12.0)*2*math.pi/360.0
def __init__(self, file, isTS): self.Freq = [] self.Harmonics = [] self.hindFreq = [] self.bonds = [] self.Etype = '' self.TS = isTS self.E0 = [] self.variableInertia = False #read dummy line "MOL #" line = readGeomFc.readMeaningfulLine(file) #self.linearity = line.split()[0].upper #read linearity line = readGeomFc.readMeaningfulLine(file) if line.split()[0].upper() == 'NONLINEAR': self.linearity = 'Nonlinear' elif line.split()[0].upper() == 'LINEAR': self.linearity = 'Linear' elif line.split()[0].upper() == 'ATOM': self.linearity = 'Atom' else: print 'Linearity keyword not recognized ' + line exit() #linearity = line.split()[0].upper # read geometry line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() != 'GEOM': print 'Geom keyword not found in the input file' + line exit() if len(tokens) == 1: #geometry is given following the GEOM keyword line = readGeomFc.readMeaningfulLine(file) numAtoms = int(line.split()[0]) self.geom = matrix(array(zeros((numAtoms, 3), dtype=float))) self.Mass = matrix(array(zeros((numAtoms, 1), dtype=float))) for i in range(numAtoms): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() self.geom[i, 0] = double(tokens[3]) self.geom[i, 1] = double(tokens[4]) self.geom[i, 2] = double(tokens[5]) atomicNum = int(tokens[1]) if (atomicNum == 6): self.Mass[i] = 12.0 if (atomicNum == 8): self.Mass[i] = 15.99491 if (atomicNum == 1): self.Mass[i] = 1.00783 if (atomicNum == 7): self.Mass[i] = 14.0031 if (atomicNum == 17): self.Mass[i] = 34.96885 if (atomicNum == 16): self.Mass[i] = 31.97207 if (atomicNum == 9): self.Mass[i] = 18.99840 #read geometry from the file elif tokens[1].upper() == 'FILE': print "reading Geometry from the file: ", tokens[2] geomFile = open(tokens[2], 'r') (self.geom, self.Mass) = readGeomFc.readGeom(geomFile) #print self.geom elif tokens[1].upper() == 'MM4FILE': #mm4 option added by gmagoon print "reading MM4 Geometry from the file: ", tokens[2] geomFile = open(tokens[2], 'r') (self.geom, self.Mass) = readGeomFc.readMM4Geom(geomFile) #print self.geom else: print 'Either give geometry or give keyword File followed by the file containing geometry data' exit() self.calculateMomInertia() # read force constant or frequency data line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() == 'FORCEC' and tokens[1].upper() == 'FILE': #MRH added following line on 2/Dec/2009 if self.linearity != 'Atom': fcfile = open(tokens[2], 'r') self.Fc = readGeomFc.readFc(fcfile) for i in range(0, 3 * self.Mass.size): for j in range(i, 3 * self.Mass.size): self.Fc[i, j] = self.Fc[j, i] elif tokens[0].upper() == 'FORCEC' and tokens[1].upper( ) == 'MM4FILE': #MM4 case if self.linearity != 'Atom': fcfile = open(tokens[2], 'r') self.Fc = readGeomFc.readMM4Fc(fcfile) for i in range(0, 3 * self.Mass.size): for j in range(i, 3 * self.Mass.size): self.Fc[i, j] = self.Fc[j, i] elif tokens[0].upper() == "FREQ": line = readGeomFc.readMeaningfulLine(file) numFreq = int(line.split()[0]) i = 0 while (i < numFreq): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() i = i + len(tokens) for j in tokens: self.Freq.append(float(j)) if self.TS: self.imagFreq = self.Freq.pop(0) if len(self.Freq) > numFreq: print 'More frequencies than ', numFreq, ' are specified' else: print 'Frequency information cannot be read, check input file again' exit() #read energy line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if (tokens[0].upper() != 'ENERGY'): print 'Energy information not given' exit() if tokens[1].upper() == 'FILE': print 'Reading energy from file: ', tokens[2] energyFile = open(tokens[2], 'r') if (tokens[3].upper() == 'CBS-QB3'): self.Etype = 'cbsqb3' elif (tokens[3].upper() == 'CBS-QB3_ULTRAFINE'): self.Etype = 'cbsqb3uf' print 'Warning: "Regular" (non-ultrafine) CBS-QB3 values will be used for P, N as a first approximation' elif (tokens[3].upper() == 'G3'): self.Etype = 'g3' elif (tokens[3].upper() == 'KLIP_1'): self.Etype = 'klip_1' elif (tokens[3].upper() == 'KLIP_2'): self.Etype = 'klip_2' elif (tokens[3].upper() == 'KLIP_2_CC'): self.Etype = 'klip_2_cc' self.Energy = readGeomFc.readEnergy(energyFile, self.Etype) print self.Energy, self.Etype elif (len(tokens) == 3): self.Energy = float(tokens[1]) if (tokens[2].upper() == 'CBS-QB3'): self.Etype = 'cbsqb3' elif (tokens[2].upper() == 'CBS-QB3_ULTRAFINE'): self.Etype = 'cbsqb3uf' print 'Warning: "Regular" (non-ultrafine) CBS-QB3 values will be used for P, N as a first approximation' elif (tokens[2].upper() == 'G3'): self.Etype = 'g3' elif (tokens[2].upper() == 'Klip_1'): self.Etype = 'klip_1' elif (tokens[2].upper() == 'Klip_2'): self.Etype = 'klip_2' elif (tokens[2].upper() == 'KLIP_2_CC'): self.Etype = 'klip_2_cc' elif (tokens[2].upper() == 'MM4'): self.Etype = 'mm4' print self.Etype.upper(), ' Energy: ', self.Energy else: print 'Cannot read the Energy' exit() #read external symmetry line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'EXTSYM'): print 'Extsym keyword required' exit() self.extSymm = float(line.split()[1]) #read electronic degeneracy line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'NELEC'): print 'Nelec keyword required' exit() self.nelec = int(line.split()[1]) #read rotor information line = readGeomFc.readMeaningfulLine(file) if (line.split()[0].upper() != 'ROTORS'): print 'Rotors keyword required' exit() self.numRotors = int(line.split()[1]) if self.numRotors == 0: #Line added by MRH o 2/Dec/2009 #If no rotors exist and molecule is not a single atom, still need to: # (1) Check if frequencies are already computed # (2) Read in the BAC information if self.linearity != 'Atom': self.rotors = [] if (len(self.Freq) == 0): #calculate frequencies from force constant self.getFreqFromFc() line = readGeomFc.readMeaningfulLine(file) tokens = line.split() for bond in tokens: self.bonds.append(float(bond)) return # If the molecule is a single atom, no rotors exist, no frequencies need # calculating, and no BAC information needs to be read else: return rotorFile = line.split()[2] inertiaFile = open(rotorFile, 'r') #print self.Mass (self.rotors) = readGeomFc.readGeneralInertia(inertiaFile, self.Mass) if len(self.rotors) - 1 != self.numRotors: print "The number of rotors specified in file, ", rotorFile, ' is different than, ', self.numRotors if (len(self.Freq) == 0): #calculate frequencies from force constant #Added by MRH on 2/Dec/2009 if self.linearity != 'Atom': self.getFreqFromFc() else: if self.linearity != 'Atom': self.getFreqFromFreq() #read potential information for rotors line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if tokens[0].upper() != 'POTENTIAL': print 'No information for potential given' exit() if tokens[1].upper() == 'SEPARABLE': if tokens[2].upper() == 'FILES': line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if len(tokens) != self.numRotors: print 'give a separate potential file for each rotor' for files in tokens: Kcos = [] Ksin = [] harmonic = Harmonics(5, Kcos, Ksin) harmonic.fitPotential(files) self.Harmonics.append(harmonic) elif tokens[2].upper().startswith('MM4FILES'): if tokens[2].upper( ) == 'MM4FILES_INERTIA': #whether to consider variable inertia or not self.variableInertia = True line = readGeomFc.readMeaningfulLine(file) tokens = line.split() if len(tokens) != self.numRotors: print 'give a separate potential file for each rotor' line = readGeomFc.readMeaningfulLine( file ) #the next line contains V0 (kcal/mol) followed by the rotor dihedrals (degrees) for the minimum energy conformation rotinfo = line.split() V0 = float(rotinfo[0]) K = geomUtility.calculateD32( self.geom, self.Mass, self.rotors ) #get the rotor moments of inertia for the minimum energy conformation, which will be used during the Fourier fit i = 0 for files in tokens: i = i + 1 dihedralMinimum = float(rotinfo[i]) Kcos = [] Ksin = [] harmonic = Harmonics(5, Kcos, Ksin) harmonic.fitMM4Potential(files, V0, dihedralMinimum, self.variableInertia, self.rotors[i], float(K[i - 1])) self.Harmonics.append(harmonic) elif tokens[2].upper() == 'HARMONIC': for i in range(self.numRotors): line = readGeomFc.readMeaningfulLine(file) numFit = int(line.split()[0]) Ksin = [] Kcos = [] for i in range(numFit): line = readGeomFc.readMeaningfulLine(file) tokens = line.split() Kcos.append(tokens[0]) Ksin.append(tokens[0]) harmonic = Harmonics(numFit, Kcos, Ksin) self.Harmonics.append(harmonic) elif tokens[1].upper() == 'NONSEPARABLE': line = readGeomFc.readMeaningfulLine(file) self.potentialFile = line.split()[0] # read the energy base #line = readGeomFc.readMeaningfulLine(file) #tokens = line.split() #if (tokens[0].upper() != 'ENERGYBASE'): # print 'Keyword EnergyBase required' # exit() #self.ebase=float(tokens[1]) # read the bonds line = readGeomFc.readMeaningfulLine(file) tokens = line.split() for bond in tokens: self.bonds.append(float(bond)) #read the random seed number '''line = readGeomFc.readMeaningfulLine(file)