diff --git a/resultsFile/Modules/gamessFile.py b/resultsFile/Modules/gamessFile.py index f7ce2d0..4b4376f 100755 --- a/resultsFile/Modules/gamessFile.py +++ b/resultsFile/Modules/gamessFile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -# resultsFile is a library which allows to read output files of quantum +# resultsFile is a library which allows to read output files of quantum # chemistry codes and write input files. -# Copyright (C) 2007 Anthony SCEMAMA +# Copyright (C) 2007 Anthony SCEMAMA # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Anthony Scemama -# LCPQ - IRSAMC +# LCPQ - IRSAMC # Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 -# scemama@irsamc.ups-tlse.fr +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 +# scemama@irsamc.ups-tlse.fr @@ -297,7 +297,7 @@ class gamessFile(resultsFile.resultsFileX): occ[motype][i] = mo.eigenvalue if occ != {}: self._occ_num = occ - return self._occ_num + return self._occ_num def get_options(self): if self._options is None: @@ -457,7 +457,7 @@ class gamessFile(resultsFile.resultsFileX): assert label == i.name f = list(map(float,buffer[2:])) self._gradient_energy.append(f) - pos +=1 + pos +=1 except IndexError: self._gradient_energy = [] return self._gradient_energy @@ -590,7 +590,7 @@ class gamessFile(resultsFile.resultsFileX): self._point_group = group.replace('N',line[6]) except IndexError: pass - return self._point_group + return self._point_group def get_geometry(self): if self._geometry is None: @@ -634,7 +634,7 @@ class gamessFile(resultsFile.resultsFileX): except IndexError: pass return self._dipole - + def get_basis(self): if self._basis is None: try: @@ -691,7 +691,7 @@ class gamessFile(resultsFile.resultsFileX): # for (i, s, b) in atom: # new_basis_read += [ [ib, s, b] ] # ib += 1 -# +# # basis_read = new_basis_read new_basis_read = [] @@ -784,7 +784,7 @@ class gamessFile(resultsFile.resultsFileX): def get_mo_types(self): if self._mo_types is None: self.get_mo_sets() - return self._mo_types + return self._mo_types def get_atom_to_ao_range(self): try: @@ -1219,12 +1219,12 @@ class gamessFile(resultsFile.resultsFileX): def get_num_alpha(self): if self._num_alpha is None: self._num_alpha = (self.num_elec + self.multiplicity-1)//2 - return self._num_alpha + return self._num_alpha def get_num_beta(self): if self._num_beta is None: self._num_beta = (self.num_elec - self.multiplicity+1)//2 - return self._num_beta + return self._num_beta def get_determinants_mo_type(self): if self._determinants_mo_type is None: @@ -1301,12 +1301,25 @@ class gamessFile(resultsFile.resultsFileX): mo = [] for i in mostr: mo.append (int(i)) - p_count=0 - for j in range ( len(mo) ): - if mo[j] < 0: - for l in range ( j+1, len(mo) ): - if mo[l] > 0: - p_count+=1 + # Calculate the phase based on the the number of swaps in the determinant + p_count=0; done = False + while (not done): + swaps = 0 + for j in range ( len(mo) -1 ): + if (abs(mo[j]) > abs(mo[j+1])): + tmp = mo[j] + mo[j] = mo[j+1] + mo[j+1] = tmp + swaps += 1 + elif (abs(mo[j]) == abs(mo[j+1])): + if (mo[j] < 0): + mo[j] = -mo[j] + mo[j+1] = -mo[j+1] + swaps += 1 + if (swaps == 0): + done = True + else: + p_count += swaps coef = float (buffer[0])*(-1.0)**p_count tempcsf_a = [] tempcsf_b = [] @@ -1396,7 +1409,7 @@ class gamessFile(resultsFile.resultsFileX): self.options['SCFTYP'] == 'UHF' or\ self.options['SCFTYP'] == 'ROHF': self._csf_coefficients = [ [1.] ] - # Multi-determinant case + # Multi-determinant case elif self.options['CITYP'] == 'GUGA' or self.options['SCFTYP'] == 'MCSCF': self._csf_coefficients = [ [] for i in range(self.num_states) ] self._pos = 0 @@ -1518,7 +1531,7 @@ def set_%(i)s(self,value): self._%(i)s = value self._file = fortranBinary(filename,"rb") def get_form(self): - return self._file.form + return self._file.form def set_form(self,form): self._file.form = form @@ -1619,7 +1632,7 @@ def gamess_write_vec(res, file): monum = monum[-2:] fields.append ( monum ) linum = "%4d"%(line) - linum = linum[-3:] + linum = linum[-3:] fields.append ( linum ) for n in range(5): try: @@ -1690,7 +1703,7 @@ def gamess_write_data(res, file): def gamess_write_integrals(res,file): filename = file.name.replace('.inp','.moints') - + def write_gamess(file,stdout): gamess_write_contrl(file,stdout) x = file.basis @@ -1698,7 +1711,7 @@ def write_gamess(file,stdout): gamess_write_data(file,stdout) gamess_write_vec(file,stdout) - + resultsFile.fileTypes.append(gamessFile) if __name__ == '__main__':