10
0
mirror of https://gitlab.com/scemama/resultsFile.git synced 2024-12-22 04:13:41 +01:00

Merge branch 'master' into 'master'

correcting the phase in the CSF information in the gamessfile module

See merge request scemama/resultsFile!2
This commit is contained in:
Anthony Scemama 2022-02-07 08:25:30 +00:00
commit 6ddb0d49ea

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/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. # 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 # 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 # 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. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Anthony Scemama # Anthony Scemama
# LCPQ - IRSAMC # LCPQ - IRSAMC
# Universite Paul Sabatier # Universite Paul Sabatier
# 118, route de Narbonne # 118, route de Narbonne
# 31062 Toulouse Cedex 4 # 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr # scemama@irsamc.ups-tlse.fr
@ -297,7 +297,7 @@ class gamessFile(resultsFile.resultsFileX):
occ[motype][i] = mo.eigenvalue occ[motype][i] = mo.eigenvalue
if occ != {}: if occ != {}:
self._occ_num = occ self._occ_num = occ
return self._occ_num return self._occ_num
def get_options(self): def get_options(self):
if self._options is None: if self._options is None:
@ -457,7 +457,7 @@ class gamessFile(resultsFile.resultsFileX):
assert label == i.name assert label == i.name
f = list(map(float,buffer[2:])) f = list(map(float,buffer[2:]))
self._gradient_energy.append(f) self._gradient_energy.append(f)
pos +=1 pos +=1
except IndexError: except IndexError:
self._gradient_energy = [] self._gradient_energy = []
return self._gradient_energy return self._gradient_energy
@ -590,7 +590,7 @@ class gamessFile(resultsFile.resultsFileX):
self._point_group = group.replace('N',line[6]) self._point_group = group.replace('N',line[6])
except IndexError: except IndexError:
pass pass
return self._point_group return self._point_group
def get_geometry(self): def get_geometry(self):
if self._geometry is None: if self._geometry is None:
@ -634,7 +634,7 @@ class gamessFile(resultsFile.resultsFileX):
except IndexError: except IndexError:
pass pass
return self._dipole return self._dipole
def get_basis(self): def get_basis(self):
if self._basis is None: if self._basis is None:
try: try:
@ -691,7 +691,7 @@ class gamessFile(resultsFile.resultsFileX):
# for (i, s, b) in atom: # for (i, s, b) in atom:
# new_basis_read += [ [ib, s, b] ] # new_basis_read += [ [ib, s, b] ]
# ib += 1 # ib += 1
# #
# basis_read = new_basis_read # basis_read = new_basis_read
new_basis_read = [] new_basis_read = []
@ -784,7 +784,7 @@ class gamessFile(resultsFile.resultsFileX):
def get_mo_types(self): def get_mo_types(self):
if self._mo_types is None: if self._mo_types is None:
self.get_mo_sets() self.get_mo_sets()
return self._mo_types return self._mo_types
def get_atom_to_ao_range(self): def get_atom_to_ao_range(self):
try: try:
@ -1219,12 +1219,12 @@ class gamessFile(resultsFile.resultsFileX):
def get_num_alpha(self): def get_num_alpha(self):
if self._num_alpha is None: if self._num_alpha is None:
self._num_alpha = (self.num_elec + self.multiplicity-1)//2 self._num_alpha = (self.num_elec + self.multiplicity-1)//2
return self._num_alpha return self._num_alpha
def get_num_beta(self): def get_num_beta(self):
if self._num_beta is None: if self._num_beta is None:
self._num_beta = (self.num_elec - self.multiplicity+1)//2 self._num_beta = (self.num_elec - self.multiplicity+1)//2
return self._num_beta return self._num_beta
def get_determinants_mo_type(self): def get_determinants_mo_type(self):
if self._determinants_mo_type is None: if self._determinants_mo_type is None:
@ -1301,12 +1301,25 @@ class gamessFile(resultsFile.resultsFileX):
mo = [] mo = []
for i in mostr: for i in mostr:
mo.append (int(i)) mo.append (int(i))
p_count=0 # Calculate the phase based on the the number of swaps in the determinant
for j in range ( len(mo) ): p_count=0; done = False
if mo[j] < 0: while (not done):
for l in range ( j+1, len(mo) ): swaps = 0
if mo[l] > 0: for j in range ( len(mo) -1 ):
p_count+=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 coef = float (buffer[0])*(-1.0)**p_count
tempcsf_a = [] tempcsf_a = []
tempcsf_b = [] tempcsf_b = []
@ -1396,7 +1409,7 @@ class gamessFile(resultsFile.resultsFileX):
self.options['SCFTYP'] == 'UHF' or\ self.options['SCFTYP'] == 'UHF' or\
self.options['SCFTYP'] == 'ROHF': self.options['SCFTYP'] == 'ROHF':
self._csf_coefficients = [ [1.] ] self._csf_coefficients = [ [1.] ]
# Multi-determinant case # Multi-determinant case
elif self.options['CITYP'] == 'GUGA' or self.options['SCFTYP'] == 'MCSCF': elif self.options['CITYP'] == 'GUGA' or self.options['SCFTYP'] == 'MCSCF':
self._csf_coefficients = [ [] for i in range(self.num_states) ] self._csf_coefficients = [ [] for i in range(self.num_states) ]
self._pos = 0 self._pos = 0
@ -1518,7 +1531,7 @@ def set_%(i)s(self,value): self._%(i)s = value
self._file = fortranBinary(filename,"rb") self._file = fortranBinary(filename,"rb")
def get_form(self): def get_form(self):
return self._file.form return self._file.form
def set_form(self,form): def set_form(self,form):
self._file.form = form self._file.form = form
@ -1619,7 +1632,7 @@ def gamess_write_vec(res, file):
monum = monum[-2:] monum = monum[-2:]
fields.append ( monum ) fields.append ( monum )
linum = "%4d"%(line) linum = "%4d"%(line)
linum = linum[-3:] linum = linum[-3:]
fields.append ( linum ) fields.append ( linum )
for n in range(5): for n in range(5):
try: try:
@ -1690,7 +1703,7 @@ def gamess_write_data(res, file):
def gamess_write_integrals(res,file): def gamess_write_integrals(res,file):
filename = file.name.replace('.inp','.moints') filename = file.name.replace('.inp','.moints')
def write_gamess(file,stdout): def write_gamess(file,stdout):
gamess_write_contrl(file,stdout) gamess_write_contrl(file,stdout)
x = file.basis x = file.basis
@ -1698,7 +1711,7 @@ def write_gamess(file,stdout):
gamess_write_data(file,stdout) gamess_write_data(file,stdout)
gamess_write_vec(file,stdout) gamess_write_vec(file,stdout)
resultsFile.fileTypes.append(gamessFile) resultsFile.fileTypes.append(gamessFile)
if __name__ == '__main__': if __name__ == '__main__':