From: Mark M. <mo...@oc...> - 2009-10-21 13:50:09
|
Hi Karol, Your fix for exam17 works great! I went ahead and wrote a parsing routine to parse the Force Constant Matrix of a GAMESS output file. Not sure if your interested in adding it to your code. It is pasted at the end of the message. Mark Code to put in gamessparser.py: The below parsing routine creates a numpy matrix and fills it with the force constant values in the GAMESS output file. Numpy matrices don't like to be sparse, so I padded the matrix with blank entries to make it square. When those blanks are set to a float in arrayify in data.py an error occurs. The hessian _attrtypes needs to be changed to list to fix the error. # MJM----------- if line.find("CARTESIAN FORCE CONSTANT MATRIX") >= 0: self.logger.info("Creating attribute hessian") for i in range(1,7): line = inputfile.next() hessx = [] hessy =[] hessz = [] while line.find("--") < 0: index=int(line[0:3])-1 if len(hessx) <= index: hessx.insert(index,[]) hessy.insert(index,[]) hessz.insert(index,[]) hessx[index].extend([line[20:29].strip(), line[29:38].strip(), line[38:47].strip(), line[47:56].strip(), line[56:65].strip(),line[65:74].strip()]) line = inputfile.next() hessy[index].extend([line[20:29].strip(), line[29:38].strip(), line[38:47].strip(), line[47:56].strip(), line[56:65].strip(),line[65:74].strip()]) line = inputfile.next() hessz[index].extend([line[20:29].strip(), line[29:38].strip(), line[38:47].strip(), line[47:56].strip(), line[56:65].strip(),line[65:74].strip()]) line = inputfile.next() if line.isspace(): for i in range(1,5): line = inputfile.next() if line.find("--") >= 0: break longest=0 for x in hessx[:]: if len(x) > longest: longest=len(x) for i in range(0,len(hessx)): for j in range(0,longest-len(hessx[i])): hessx[i].append('') hessy[i].append('') hessz[i].append('') self.hessian=numpy.vstack((hessx[0],hessy[0],hessz[0])) for i in range(1,len(hessx)): self.hessian=numpy.vstack([self.hessian,hessx[i], hessy[i],hessz[i]]) #------------------------ |