def o_orbital_symmetries(file='output.dat'): #gives occupied orbital symmetries from a specified output file with open(file, 'r') as f: output = f.read() f = open(file) lines = f.readlines() section = lines[sedre.Parser(program='qchem', filename=file). data['sections']['TDDFT']['occ_orbitals']['hits'][0][0]: sedre.Parser(program='qchem', filename=file). data['sections']['TDDFT']['occ_orbitals']['hits'][0][1]] cleaner_section = ''.join(section) return clean_orbital_list(cleaner_section, file)
def clean_orbital_list(section, file='output.dat'): #takes a section found by sedre and returns a list of orbital symmetries if sedre.Parser(program='qchem', filename=file ).data['properties']['TDDFT']['pg']['vals'][0][0] == 'C1': return None else: lst1 = section.split('\n') lst2 = [] for item in lst1: for i in range(len(item.split())): lst2.append(item.split()[i]) lst3 = [] lst4 = [] lst5 = [] for item in lst2: if item.strip(' -') == '': continue else: lst3.append(item) for item in lst3: if item == '': continue else: lst5.append(item) for item in lst5: for i in range(len(item)): if item[0] in [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'V', '-' ]: continue else: lst4.append(item) break return lst4
def test1(self): test_parser = sedre.Parser() test_parser.content['str'] =\ """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.""" o = test_parser.look_for('Lorem') self.assertEqual(o, ['Lorem'])
def func(): myp = sedre.Parser(program='psi4', filename='./data/test_psi4_opt.dat') return myp.data['properties']['opt']['iteration']['vals'][0]
def func(): myp = sedre.Parser(program='psi4', filename='./data/test_load.dat') return myp.data['energy']['HF']['raw']['vals'][0][0]
def orbTest(): myp = sedre.Parser(program='qchem', filename='data/qchem_orbital_eigenvalue.dat') eigs = myp.data['properties']['orbitals']['alpha']['occ']['e']['vals'][0] return eigs
def func(): myp = sedre.Parser(program='molpro', filename='data/test_molpro_rhf.dat') return myp.data['energy']['RHF']['raw']['vals'][0]
def return_trans_sym(file='output.dat'): # returns a list of transition symmetries from a qchem TDDFT output.dat file in order of increasing excitation energies # if the molecule is C1, all transitions are of A symmetry... # this will return a list of As of the appropriate length # if the point group is detected to be C1 if sedre.Parser(program='qchem', filename=file ).data['properties']['TDDFT']['pg']['vals'][0][0] == 'C1': return ['A'] * len( sedre.Parser( program='qchem', filename=file).data['energy']['TDDFT']['exc']['vals'][0]) else: lst_1 = [] lst_2 = [] lst_3 = [] lst4 = [] property_list = [] # read the file and temporarily save the lines with open(file, 'r') as f: output = f.read() f = open(file) lines = f.readlines() # iterate through each line in lines # remove extraneous spaces # append cleaned line to lst_1 for line in list(lines): new_line = line.strip(' ') lst_1.append(new_line) # iterate through each cleaned line in lst_1 # append the line 5 lines after any line that contains the word 'Excited' to lst_2 # (this is the line that contains the D() --> V() information) for i in range(len(lst_1)): if 'Excited' in lst_1[i].split(' '): lst_2.append(lst_1[i + 5]) # finds the point group of the molecule with sedre in the output.dat file # uses sedre functions to get the symmetries of the occupied, virtual, and all orbitals pg = sedre.Parser( program='qchem', filename=file).data['properties']['TDDFT']['pg']['vals'][0][0] occ_orb_sym = sedre.o_orbital_symmetries(file) vir_orb_sym = sedre.v_orbital_symmetries(file) all_orb_sym = sedre.orbital_symmetries(file) # grabs the orbital numbers from D(m) --> V(n) line # remove extraneous spaces # append orbital numbers m, n to lst_3 for item in lst_2: orbitals = [ int((item[2] + item[3] + item[4]).strip(' ')), int((item[13] + item[14] + item[15]).strip(' ')) ] lst_3.append(orbitals) # re-indexes the orbital numbers so that each orbital has a unique number # virtual orbitals start at ('number of occupied orbitals' + 1) for i in range(len(lst_3)): num_occ_orb = len(occ_orb_sym) new_item = [int(lst_3[i][0]), int(lst_3[i][1]) + num_occ_orb] lst4.append(new_item) # appends the symmetries of the origin orbital, destination orbital, # and transition (product of the previous two symmetries) for i in range(len(lst4)): lst4[i].append(all_orb_sym[int(lst4[i][0]) - 1]) lst4[i].append(all_orb_sym[int(lst4[i][1]) - 1]) lst4[i].append(sedre.reduction_formula(pg, lst4[i][2], lst4[i][3])) property_list.append(lst4[i][4]) return property_list
def ParserLoad(): myp = sedre.Parser(filename='./data/test_load.dat') myp.program = 'psi4' myp.psi4() myp.load() return len(myp.content['list'])
def func(): myp = sedre.Parser(program='psi4',filename='./data/psi4_freq.dat') return myp.data['properties']['freq']['entry']['vals'][0]
"o": 8, "f": 9, "ne": 10 } freq_rstr = "Freq \[cm\^-1\]" + space + canynum + space + canynum + space + canynum rmass_rstr = "Reduced mass \[u\]" + space + canynum + space + canynum + space + canynum frc_rstr = "Force const \[mDyne/A\]" + space + canynum + space + canynum + space + canynum int_rstr = "IR activ \[km/mol\]" + space + canynum + space + canynum + space + canynum disp_rstr = "\s+[0-9] " + "([A-Za-z]+)" + (space + canynum + space + canynum + space + canynum) * 3 geom_rstr = "([A-Z]|[A-Z][A-Z])" + (space + canynum) * 3 with open('output.dat', 'r') as f: cont = f.read() myp = sedre.Parser(program="psi4") geom = myp.data['properties']['GEOM']['cart']['vals'][-1] freq = re.findall(freq_rstr, cont) rmass = re.findall(rmass_rstr, cont) frc = re.findall(frc_rstr, cont) intens = re.findall(int_rstr, cont) disps = re.findall(disp_rstr, cont) natom = len(geom) ostr = "" ostr += header ostr += compline ostr += input_orientation for idx, atom in enumerate(geom): num = atlookup[atom[0].strip().lower()] ostr += gline.format(idx + 1, num, 0, *atom[1:]) ostr += sep