def harvest_zmat(zmat): """Parses the contents of the Cfour ZMAT file into array and coordinate information. The coordinate info is converted into a rather dinky Molecule (no fragment, but does read charge, mult, unit). Return qcdb.Molecule. Written for findif zmat* where geometry always Cartesian and Bohr. """ zmat = zmat.splitlines()[1:] # skip comment line Nat = 0 readCoord = True isBohr = '' charge = 0 mult = 1 molxyz = '' cgeom = [] for line in zmat: if line.strip() == '': readCoord = False elif readCoord: lline = line.split() molxyz += line + '\n' Nat += 1 else: if line.find('CHARGE') > -1: idx = line.find('CHARGE') charge = line[idx + 7:] idxc = charge.find(',') if idxc > -1: charge = charge[:idxc] charge = int(charge) if line.find('MULTIPLICITY') > -1: idx = line.find('MULTIPLICITY') mult = line[idx + 13:] idxc = mult.find(',') if idxc > -1: mult = mult[:idxc] mult = int(mult) if line.find('UNITS=BOHR') > -1: isBohr = ' bohr' molxyz = '%d%s\n%d %d\n' % (Nat, isBohr, charge, mult) + molxyz mol = Molecule.init_with_xyz(molxyz, no_com=True, no_reorient=True, contentsNotFilename=True) return mol
def jajo2mol(jajodic): """Returns a Molecule from entries in dictionary *jajodic* extracted from JAINDX and JOBARC. """ map = jajodic['MAP2ZMAT'] elem = jajodic['ATOMCHRG'] coord = jajodic['COORD '] Nat = len(elem) molxyz = '%d bohr\n\n' % (Nat) # TODO chgmult, though not really necessary for reorientation for at in range(Nat): posn = map[at] - 1 el = 'GH' if elem[posn] == 0 else z2el[elem[posn]] posn *= 3 molxyz += '%s %21.15f %21.15f %21.15f\n' % (el, coord[posn], coord[posn + 1], coord[posn + 2]) mol = Molecule.init_with_xyz(molxyz, no_com=True, no_reorient=True, contentsNotFilename=True) return mol
def harvest_GRD(grd): """Parses the contents *grd* of the Cfour GRD file into the gradient array and coordinate information. The coordinate info is converted into a rather dinky Molecule (no charge, multiplicity, or fragment), but this is these coordinates that govern the reading of molecule orientation by Cfour. Return qcdb.Molecule and gradient array. """ grd = grd.splitlines() Nat = int(grd[0].split()[0]) molxyz = '%d bohr\n\n' % (Nat) grad = [] for at in range(Nat): mline = grd[at + 1].split() el = 'GH' if int(float(mline[0])) == 0 else z2el[int(float(mline[0]))] molxyz += '%s %16s %16s %16s\n' % (el, mline[-3], mline[-2], mline[-1]) lline = grd[at + 1 + Nat].split() grad.append([float(lline[-3]), float(lline[-2]), float(lline[-1])]) mol = Molecule.init_with_xyz(molxyz, no_com=True, no_reorient=True, contentsNotFilename=True) return mol, grad
def harvest_outfile_pass(outtext): """Function to read CFOUR output file *outtext* and parse important quantum chemical information from it in """ psivar = PreservingDict() psivar_coord = None psivar_grad = None # TODO: BCC # CI # QCISD(T) # other ROHF tests # vcc/ecc NUMBER = "((?:[-+]?\\d*\\.\\d+(?:[DdEe][-+]?\\d+)?)|(?:[-+]?\\d+\\.\\d*(?:[DdEe][-+]?\\d+)?))" # Process NRE mobj = re.search(r'^\s+' + r'(?:Nuclear repulsion energy :)' + r'\s+' + NUMBER + r'\s+a\.u\.\s*$', outtext, re.MULTILINE) if mobj: print('matched nre') psivar['NUCLEAR REPULSION ENERGY'] = mobj.group(1) # Process SCF mobj = re.search( r'^\s+' + r'(?:E\(SCF\))' + r'\s+=\s+' + NUMBER + r'\s+a\.u\.\s*$', outtext, re.MULTILINE) if mobj: print('matched scf1') psivar['SCF TOTAL ENERGY'] = mobj.group(1) mobj = re.search( r'^\s+' + r'(?:E\(SCF\)=)' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE) if mobj: print('matched scf2') psivar['SCF TOTAL ENERGY'] = mobj.group(1) mobj = re.search( r'^\s+' + r'(?:SCF has converged.)' + r'\s*$' + r'(?:.*?)' + r'^\s+' + r'(?:\d+)' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched scf3') psivar['SCF TOTAL ENERGY'] = mobj.group(1) # Process MP2 mobj = re.search( r'^\s+' + r'(?:E2\(AA\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(AB\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(TOT\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:Total MP2 energy)' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*$', outtext, re.MULTILINE) if mobj: print('matched mp2r') psivar['MP2 SAME-SPIN CORRELATION ENERGY'] = 2 * Decimal(mobj.group(1)) psivar['MP2 OPPOSITE-SPIN CORRELATION ENERGY'] = mobj.group(2) psivar['MP2 CORRELATION ENERGY'] = 2 * Decimal(mobj.group(1)) + Decimal(mobj.group(2)) psivar['MP2 TOTAL ENERGY'] = mobj.group(4) mobj = re.search( r'^\s+' + r'(?:E2\(AA\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(BB\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(AB\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(TOT\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:Total MP2 energy)' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*$', outtext, re.MULTILINE) if mobj: print('matched mp2u') psivar['MP2 SAME-SPIN CORRELATION ENERGY'] = Decimal(mobj.group(1)) + Decimal(mobj.group(2)) psivar['MP2 OPPOSITE-SPIN CORRELATION ENERGY'] = mobj.group(3) psivar['MP2 CORRELATION ENERGY'] = Decimal(mobj.group(1)) + \ Decimal(mobj.group(2)) + Decimal(mobj.group(3)) psivar['MP2 TOTAL ENERGY'] = mobj.group(5) mobj = re.search( r'^\s+' + r'(?:E2\(AA\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(BB\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(AB\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(SINGLE\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:E2\(TOT\))' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'(?:Total MP2 energy)' + r'\s+=\s+' + NUMBER + r'\s+a.u.\s*$', outtext, re.MULTILINE) if mobj: print('matched mp2ro') psivar['MP2 SAME-SPIN CORRELATION ENERGY'] = Decimal(mobj.group(1)) + Decimal(mobj.group(2)) psivar['MP2 OPPOSITE-SPIN CORRELATION ENERGY'] = mobj.group(3) psivar['MP2 SINGLES ENERGY'] = mobj.group(4) psivar['MP2 CORRELATION ENERGY'] = Decimal(mobj.group(1)) + \ Decimal(mobj.group(2)) + Decimal(mobj.group(3)) + Decimal(mobj.group(4)) psivar['MP2 TOTAL ENERGY'] = mobj.group(6) # Process MP3 mobj = re.search( r'^\s+' + r'(?:D-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp3r') dmp2 = Decimal(mobj.group(1)) dmp3 = Decimal(mobj.group(3)) psivar['MP2 CORRELATION ENERGY'] = dmp2 psivar['MP2 TOTAL ENERGY'] = mobj.group(2) psivar['MP3 CORRELATION ENERGY'] = dmp2 + dmp3 psivar['MP3 TOTAL ENERGY'] = mobj.group(4) psivar['MP2.5 CORRELATION ENERGY'] = dmp2 + Decimal('0.500000000000') * dmp3 psivar['MP2.5 TOTAL ENERGY'] = psivar['MP2.5 CORRELATION ENERGY'] + psivar['SCF TOTAL ENERGY'] mobj = re.search( r'^\s+' + r'(?:S-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:S-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp3ro') dmp2 = Decimal(mobj.group(1)) + Decimal(mobj.group(3)) dmp3 = Decimal(mobj.group(5)) + Decimal(mobj.group(7)) psivar['MP3 CORRELATION ENERGY'] = dmp2 + dmp3 psivar['MP3 TOTAL ENERGY'] = mobj.group(8) psivar['MP2.5 CORRELATION ENERGY'] = dmp2 + Decimal('0.500000000000') * dmp3 psivar['MP2.5 TOTAL ENERGY'] = psivar['MP2.5 CORRELATION ENERGY'] + psivar['SCF TOTAL ENERGY'] # Process MP4 mobj = re.search( r'^\s+' + r'(?:D-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:Q-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:S-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp4r') dmp2 = Decimal(mobj.group(1)) dmp3 = Decimal(mobj.group(3)) dmp4sdq = Decimal(mobj.group(5)) + Decimal(mobj.group(7)) + Decimal(mobj.group(9)) psivar['MP2 CORRELATION ENERGY'] = dmp2 psivar['MP2 TOTAL ENERGY'] = mobj.group(2) psivar['MP3 CORRELATION ENERGY'] = dmp2 + dmp3 psivar['MP3 TOTAL ENERGY'] = mobj.group(4) psivar['MP2.5 CORRELATION ENERGY'] = dmp2 + Decimal('0.500000000000') * dmp3 psivar['MP2.5 TOTAL ENERGY'] = psivar['MP2.5 CORRELATION ENERGY'] + psivar['SCF TOTAL ENERGY'] psivar['MP4(SDQ) CORRELATION ENERGY'] = dmp2 + dmp3 + dmp4sdq psivar['MP4(SDQ) TOTAL ENERGY'] = mobj.group(10) mobj = re.search( r'^\s+' + r'(?:S-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(2\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:S-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:D-MBPT\(3\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:L-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:NL-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp4ro') dmp2 = Decimal(mobj.group(1)) + Decimal(mobj.group(3)) dmp3 = Decimal(mobj.group(5)) + Decimal(mobj.group(7)) dmp4sdq = Decimal(mobj.group(9)) + Decimal(mobj.group(11)) psivar['MP2 CORRELATION ENERGY'] = dmp2 psivar['MP2 TOTAL ENERGY'] = mobj.group(4) psivar['MP3 CORRELATION ENERGY'] = dmp2 + dmp3 psivar['MP3 TOTAL ENERGY'] = mobj.group(8) psivar['MP2.5 CORRELATION ENERGY'] = dmp2 + Decimal('0.500000000000') * dmp3 psivar['MP2.5 TOTAL ENERGY'] = psivar['MP2.5 CORRELATION ENERGY'] + psivar['SCF TOTAL ENERGY'] psivar['MP4(SDQ) CORRELATION ENERGY'] = dmp2 + dmp3 + dmp4sdq psivar['MP4(SDQ) TOTAL ENERGY'] = mobj.group(12) mobj = re.search( r'^\s+' + r'(?:D-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:Q-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:S-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:T-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp4tr') dmp4sdq = Decimal(mobj.group(1)) + Decimal(mobj.group(3)) + Decimal(mobj.group(5)) dmp4t = Decimal(mobj.group(7)) psivar['MP4(SDQ) CORRELATION ENERGY'] = psivar['MP3 CORRELATION ENERGY'] + dmp4sdq psivar['MP4(SDQ) TOTAL ENERGY'] = mobj.group(6) psivar['MP4(T) CORRECTION ENERGY'] = dmp4t psivar['MP4(SDTQ) CORRELATION ENERGY'] = psivar['MP3 CORRELATION ENERGY'] + dmp4sdq + dmp4t psivar['MP4(SDTQ) TOTAL ENERGY'] = mobj.group(8) psivar['MP4 CORRELATION ENERGY'] = psivar['MP4(SDTQ) CORRELATION ENERGY'] psivar['MP4 TOTAL ENERGY'] = psivar['MP4(SDTQ) TOTAL ENERGY'] mobj = re.search( r'^\s+' + r'(?:L-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:NL-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:WT12-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*' + r'^\s+' + r'(?:T-MBPT\(4\))' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched mp4tro') dmp4sdq = Decimal(mobj.group(1)) + Decimal(mobj.group(3)) dmp4t = Decimal(mobj.group(5)) + Decimal(mobj.group(7)) # TODO: WT12 with T, not SDQ? psivar['MP4(SDQ) CORRELATION ENERGY'] = psivar['MP3 CORRELATION ENERGY'] + dmp4sdq psivar['MP4(SDQ) TOTAL ENERGY'] = mobj.group(4) psivar['MP4(T) CORRECTION ENERGY'] = dmp4t psivar['MP4(SDTQ) CORRELATION ENERGY'] = psivar['MP3 CORRELATION ENERGY'] + dmp4sdq + dmp4t psivar['MP4(SDTQ) TOTAL ENERGY'] = mobj.group(8) psivar['MP4 CORRELATION ENERGY'] = psivar['MP4(SDTQ) CORRELATION ENERGY'] psivar['MP4 TOTAL ENERGY'] = psivar['MP4(SDTQ) TOTAL ENERGY'] # Process CC Iterations mobj = re.search( r'^\s+' + r'(?P<fullCC>(?P<iterCC>CC(?:\w+))(?:\(T\))?)' + r'\s+(?:energy will be calculated.)\s*' + r'(?:.*?)' + r'^\s+' + r'(?:\d+)' + r'\s+' + NUMBER + r'\s+' + NUMBER + r'\s+DIIS\s*' + r'^\s*(?:-+)\s*' + r'^\s*(?:A miracle (?:has come|come) to pass. The CC iterations have converged.)\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched cc with full %s iterating %s' % (mobj.group('fullCC'), mobj.group('iterCC'))) psivar['%s CORRELATION ENERGY' % (mobj.group('iterCC'))] = mobj.group(3) psivar['%s TOTAL ENERGY' % (mobj.group('iterCC'))] = mobj.group(4) # Process CC(T) mobj = re.search( r'^\s+' + r'(?:E\(SCF\))' + r'\s+=\s+' + NUMBER + r'\s+a\.u\.\s*' + r'(?:.*?)' + r'^\s+' + r'(?:E\(CCSD\))' + r'\s+=\s+' + NUMBER + r'\s*' + r'(?:.*?)' + r'^\s+' + r'(?:E\(CCSD\(T\)\))' + r'\s+=\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched ccsd(t) vcc') psivar['SCF TOTAL ENERGY'] = mobj.group(1) psivar['CCSD TOTAL ENERGY'] = mobj.group(2) psivar['(T) CORRECTION ENERGY'] = Decimal(mobj.group(3)) - Decimal(mobj.group(2)) psivar['CCSD(T) CORRELATION ENERGY'] = Decimal(mobj.group(3)) - Decimal(mobj.group(1)) psivar['CCSD(T) TOTAL ENERGY'] = mobj.group(3) mobj = re.search( r'^\s+' + r'(?:E\(SCF\))' + r'\s+=\s+' + NUMBER + r'\s+a\.u\.\s*' + r'(?:.*?)' + r'^\s+' + r'(?:CCSD energy)' + r'\s+' + NUMBER + r'\s*' + r'(?:.*?)' + r'^\s+' + r'(?:Total perturbative triples energy:)' + r'\s+' + NUMBER + r'\s*' + r'^\s*(?:-+)\s*' + r'^\s+' + r'(?:CCSD\(T\) energy)' + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched ccsd(t) ecc') psivar['SCF TOTAL ENERGY'] = mobj.group(1) psivar['CCSD TOTAL ENERGY'] = mobj.group(2) psivar['(T) CORRECTION ENERGY'] = mobj.group(3) psivar['CCSD(T) CORRELATION ENERGY'] = Decimal(mobj.group(4)) - Decimal(mobj.group(2)) psivar['CCSD(T) TOTAL ENERGY'] = mobj.group(4) mobj = re.search( r'^\s+' + r'(?:CCSD energy)' + r'\s+' + NUMBER + r'\s*' + r'^\s*(?:-+)\s*' + r'^\s+' + r'(?:CCSD\(T\) energy)' + r'\s+' + NUMBER + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: print('matched ccsd(t) lamb') psivar['CCSD TOTAL ENERGY'] = mobj.group(1) psivar['(T) CORRECTION ENERGY'] = Decimal(mobj.group(2)) - Decimal(mobj.group(1)) psivar['CCSD(T) CORRELATION ENERGY'] = Decimal(mobj.group(2)) - psivar['SCF TOTAL ENERGY'] psivar['CCSD(T) TOTAL ENERGY'] = mobj.group(2) # Process SCS-CC mobj = re.search( r'^\s+' + r'(?P<fullCC>(?P<iterCC>CC(?:\w+))(?:\(T\))?)' + r'\s+(?:energy will be calculated.)\s*' + r'(?:.*?)' + r'^\s*' + r'(?:@CCENRG-I, Correlation energies.)' + r'\s+(?:ECCAA)\s+' + NUMBER + r'\s*' + r'^\s+(?:ECCBB)\s+' + NUMBER + '\s*' + r'^\s+(?:ECCAB)\s+' + NUMBER + '\s*' + r'^\s+(?:Total)\s+' + NUMBER + '\s*', outtext, re.MULTILINE | re.DOTALL) if mobj: # PRINT=2 to get SCS-CC components print('matched scscc') psivar['%s SAME-SPIN CORRELATION ENERGY' % (mobj.group('iterCC'))] = Decimal(mobj.group(3)) + Decimal(mobj.group(4)) psivar['%s OPPOSITE-SPIN CORRELATION ENERGY' % (mobj.group('iterCC'))] = mobj.group(5) psivar['%s CORRELATION ENERGY' % (mobj.group('iterCC'))] = mobj.group(6) mobj = re.search( r'^\s+' + r'(?P<fullCC>(?P<iterCC>CC(?:\w+))(?:\(T\))?)' + r'\s+(?:energy will be calculated.)\s*' + r'(?:.*?)' + r'^\s+' + r'Amplitude equations converged in' + r'\s*\d+\s*' + r'iterations.\s*' + r'^\s+' + r'The AA contribution to the correlation energy is:\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'The BB contribution to the correlation energy is:\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'The AB contribution to the correlation energy is:\s+' + NUMBER + r'\s+a.u.\s*' + r'^\s+' + r'The total correlation energy is\s+' + NUMBER + r'\s+a.u.\s*' + r'(?:.*?)' + #r'^\s+' + r'The CC iterations have converged.' + r'\s*$', r'^\s+' + r'(?:A miracle come to pass. )?' + r'The CC iterations have converged.' + r'\s*$', outtext, re.MULTILINE | re.DOTALL) if mobj: # PRINT=2 to get SCS components print('matched scscc2') psivar['%s SAME-SPIN CORRELATION ENERGY' % (mobj.group('iterCC'))] = Decimal(mobj.group(3)) + Decimal(mobj.group(4)) psivar['%s OPPOSITE-SPIN CORRELATION ENERGY' % (mobj.group('iterCC'))] = mobj.group(5) psivar['%s CORRELATION ENERGY' % (mobj.group('iterCC'))] = mobj.group(6) # Process gradient mobj = re.search( r'\s+' + r'Molecular gradient' + r'\s*' + r'\s+' + r'------------------' + r'\s*' + r'\s+' + r'\n' + r'(?:(?:\s+[A-Z]+\s*#\d+\s+[xyz]\s+[-+]?\d+\.\d+\s*\n)+)' + # optional, it seems r'\n\n' + # optional, it seems r'((?:\s+[A-Z]+\s*#\d+\s+\d?\s+[-+]?\d+\.\d+\s+[-+]?\d+\.\d+\s+[-+]?\d+\.\d+\s*\n)+)' + r'\n\n' + r'\s+' + 'Molecular gradient norm', outtext, re.MULTILINE) if mobj: print('matched molgrad') atoms = [] psivar_grad = [] for line in mobj.group(1).splitlines(): lline = line.split() atoms.append(lline[0]) #psivar_gradient.append([Decimal(lline[-3]), Decimal(lline[-2]), Decimal(lline[-1])]) psivar_grad.append([float(lline[-3]), float(lline[-2]), float(lline[-1])]) # Process geometry mobj = re.search( # r'\s+(?:-+)\s*' + # r'^\s+' + r'Z-matrix Atomic Coordinates (in bohr)' + r'\s*' + r'^\s+' + r'Symbol Number X Y Z' + r'\s*' + r'^\s+(?:-+)\s*' + r'((?:\s+[A-Z]+\s+[0-9]+\s+[-+]?\d+\.\d+\s+[-+]?\d+\.\d+\s+[-+]?\d+\.\d+\s*\n)+)' + r'^\s+(?:-+)\s*', outtext, re.MULTILINE) if mobj: print('matched geom') molxyz = '%d bohr\n\n' % len(mobj.group(1).splitlines()) for line in mobj.group(1).splitlines(): lline = line.split() molxyz += '%s %16s %16s %16s\n' % (lline[0], lline[-3], lline[-2], lline[-1]) # Rather a dinky Molecule as no ghost, charge, or multiplicity psivar_coord = Molecule.init_with_xyz(molxyz, no_com=True, no_reorient=True, contentsNotFilename=True) # Process atom geometry mobj = re.search( r'^\s+' + r'@GETXYZ-I, 1 atoms read from ZMAT.' + r'\s*' + r'^\s+' + r'[0-9]+\s+([A-Z]+)\s+[0-9]+\s+' + NUMBER + r'\s*', outtext, re.MULTILINE) if mobj: print('matched atom') # Dinky Molecule molxyz = '1 bohr\n\n%s 0.0 0.0 0.0\n' % (mobj.group(1)) psivar_coord = Molecule.init_with_xyz(molxyz, no_com=True, no_reorient=True, contentsNotFilename=True) # Process error codes mobj = re.search( r'^\s*' + r'--executable ' + r'(\w+)' + r' finished with status' + r'\s+' + r'([1-9][0-9]*)', outtext, re.MULTILINE) if mobj: print('matched error') psivar['CFOUR ERROR CODE'] = mobj.group(2) # Process CURRENT energies (TODO: needs better way) if 'SCF TOTAL ENERGY' in psivar: psivar['CURRENT REFERENCE ENERGY'] = psivar['SCF TOTAL ENERGY'] psivar['CURRENT ENERGY'] = psivar['SCF TOTAL ENERGY'] if 'MP2 TOTAL ENERGY' in psivar and 'MP2 CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['MP2 CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['MP2 TOTAL ENERGY'] if 'MP3 TOTAL ENERGY' in psivar and 'MP3 CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['MP3 CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['MP3 TOTAL ENERGY'] if 'MP4 TOTAL ENERGY' in psivar and 'MP4 CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['MP4 CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['MP4 TOTAL ENERGY'] # if ('%s TOTAL ENERGY' % (mobj.group('fullCC')) in psivar) and \ # ('%s CORRELATION ENERGY' % (mobj.group('fullCC')) in psivar): # psivar['CURRENT CORRELATION ENERGY'] = psivar['%s CORRELATION ENERGY' % (mobj.group('fullCC')] # psivar['CURRENT ENERGY'] = psivar['%s TOTAL ENERGY' % (mobj.group('fullCC')] if 'CC2 TOTAL ENERGY' in psivar and 'CC2 CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['CC2 CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['CC2 TOTAL ENERGY'] if 'CCSD TOTAL ENERGY' in psivar and 'CCSD CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['CCSD CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['CCSD TOTAL ENERGY'] if 'CCSD(T) TOTAL ENERGY' in psivar and 'CCSD(T) CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['CCSD(T) CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['CCSD(T) TOTAL ENERGY'] if 'CC3 TOTAL ENERGY' in psivar and 'CC3 CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['CC3 CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['CC3 TOTAL ENERGY'] if 'CCSDT TOTAL ENERGY' in psivar and 'CCSDT CORRELATION ENERGY' in psivar: psivar['CURRENT CORRELATION ENERGY'] = psivar['CCSDT CORRELATION ENERGY'] psivar['CURRENT ENERGY'] = psivar['CCSDT TOTAL ENERGY'] return psivar, psivar_coord, psivar_grad