This commit is contained in:
Anthony Scemama 2020-01-27 20:29:00 +01:00
parent b502a622cc
commit 53b075a839
16 changed files with 192 additions and 192 deletions

View File

@ -41,9 +41,9 @@ if "q5CostFile" in all:
for mod in all:
try:
exec 'from '+mod+' import *'
exec('from '+mod+' import *')
except:
print "Error importing module", mod
print("Error importing module", mod)
pass

View File

@ -26,7 +26,7 @@
import include
from . import include
eval(include.code)
import struct
@ -54,13 +54,13 @@ class gamessFile(resultsFile):
local_vars = list(local_vars)
defined_vars = list(gamessFile_defined_vars)
exec get_data('date',"EXECUTION OF GAMESS BEGUN",'4:') in locals()
exec get_data('machine',"Files used on the master node",'6:7') in locals()
exec get_data('version',"GAMESS VERSION",'4:8') in locals()
exec get_data('num_proc',"MEMDDI DISTRIBUTED OVER",'3:4',"int") in locals()
exec get_data('num_elec',"NUMBER OF ELECTRONS", '4:5',"int") in locals()
exec get_data('charge',"CHARGE OF MOLECULE", '4:5',"float") in locals()
exec get_data('nuclear_energy',"THE NUCLEAR REPULSION ENERGY", '5:6',"float") in locals()
exec(get_data('date',"EXECUTION OF GAMESS BEGUN",'4:'), locals())
exec(get_data('machine',"Files used on the master node",'6:7'), locals())
exec(get_data('version',"GAMESS VERSION",'4:8'), locals())
exec(get_data('num_proc',"MEMDDI DISTRIBUTED OVER",'3:4',"int"), locals())
exec(get_data('num_elec',"NUMBER OF ELECTRONS", '4:5',"int"), locals())
exec(get_data('charge',"CHARGE OF MOLECULE", '4:5',"float"), locals())
exec(get_data('nuclear_energy',"THE NUCLEAR REPULSION ENERGY", '5:6',"float"), locals())
def get_multiplicity(self):
if self._multiplicity is None:
@ -272,7 +272,7 @@ class gamessFile(resultsFile):
tokens = line.split()[0::2]
values = line.split()[1::2]
if len(tokens) != len(values):
print "error: ",line
print("error: ",line)
sys.exit(0)
except IndexError:
pass
@ -407,7 +407,7 @@ class gamessFile(resultsFile):
buffer = self.text[pos].split()
label = buffer[1]
assert label == i.name
f = map(float,buffer[2:])
f = list(map(float,buffer[2:]))
self._gradient_energy.append(f)
pos +=1
except IndexError:
@ -698,7 +698,7 @@ class gamessFile(resultsFile):
"xxxxyz", "xyyyyz", "xyzzzz", "xxxyyy", "xxxzzz", \
"yyyzzz", "xxxyyz", "xxxyzz", "xxyyyz", "xyyyzz", \
"xxyzzz", "xyyzzz" ]
map(normalize_basis_name,mylist)
list(map(normalize_basis_name,mylist))
for i in mylist[:-1]:
basis[k][0] = i
basis.insert(k,list(basis[k]))
@ -1451,17 +1451,17 @@ class gamessFile(resultsFile):
for i, j in local_vars:
if i not in defined_vars:
exec build_get_funcs(i) in locals()
exec build_property(i,j) in locals()
exec(build_get_funcs(i), locals())
exec(build_property(i,j), locals())
del to_remove, i, j
atom_to_ao_range = property(fget=get_atom_to_ao_range)
for i in "two_e_int_mo_filename two_e_int_ao_filename".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
class two_e_int_array(object):
@ -1499,7 +1499,7 @@ def set_%(i)s(self,value): self._%(i)s = value
Nint = rec.pop(0)
while (index >= Nint):
index -= Nint
rec = self._file.next()
rec = next(self._file)
Nint = rec.pop(0)
rec_i = rec[:4*Nint]
@ -1524,29 +1524,29 @@ def set_%(i)s(self,value): self._%(i)s = value
def gamess_write_contrl(res,file, runtyp="ENERGY",guess="HUCKEL",
exetyp="RUN",scftyp=None,moread=False,NoSym=False,units="BOHR"):
print >>file, " $CONTRL"
print >>file, " EXETYP=",exetyp
print >>file, " COORD= UNIQUE", " UNITS=",units
print >>file, " RUNTYP=", runtyp
print(" $CONTRL", file=file)
print(" EXETYP=",exetyp, file=file)
print(" COORD= UNIQUE", " UNITS=",units, file=file)
print(" RUNTYP=", runtyp, file=file)
if NoSym:
print >>file, " NOSYM=1"
print(" NOSYM=1", file=file)
if scftyp is None:
if res.num_alpha == res.num_beta:
scftyp="RHF"
else:
scftyp="ROHF"
print >>file, " SCFTYP=", scftyp
print >>file, " MULT=", res.multiplicity
print >>file, " ICHARG=",str(int(res.charge))
print >>file, " $END"
print >>file, ""
print >>file, " $GUESS"
print(" SCFTYP=", scftyp, file=file)
print(" MULT=", res.multiplicity, file=file)
print(" ICHARG=",str(int(res.charge)), file=file)
print(" $END", file=file)
print("", file=file)
print(" $GUESS", file=file)
if moread:
print >>file, " GUESS=MOREAD"
print >>file, " NORB=",len(res.mo_sets[res.mo_types[-1]])
print(" GUESS=MOREAD", file=file)
print(" NORB=",len(res.mo_sets[res.mo_types[-1]]), file=file)
else:
print >>file, " GUESS=HUCKEL"
print >>file, " $END"
print(" GUESS=HUCKEL", file=file)
print(" $END", file=file)
def gamess_write_vec(res, file):
@ -1556,8 +1556,8 @@ def gamess_write_vec(res, file):
# motypelist = [motype]
# for motype in motypelist:
motype = res.mo_types[-1]
print >>file, motype, "MOs"
print >>file, " $VEC"
print(motype, "MOs", file=file)
print(" $VEC", file=file)
moset = res.mo_sets[motype]
moindex = res.closed_mos + res.active_mos + \
res.virtual_mos
@ -1578,13 +1578,13 @@ def gamess_write_vec(res, file):
fields.append ( "%15.8E"%v.pop(0) )
except IndexError:
pass
print >>file, ''.join(fields)
print(''.join(fields), file=file)
line += 1
print >>file, " $END"
print(" $END", file=file)
def gamess_write_data(res, file):
print >>file, " $DATA"
print >>file, res.title
print(" $DATA", file=file)
print(res.title, file=file)
try:
point_group = res.point_group
N = point_group[1]
@ -1594,10 +1594,10 @@ def gamess_write_data(res, file):
except TypeError:
point_group = 'C1'
N = '1'
print >>file, point_group
print(point_group, file=file)
for at in res.geometry:
print >>file, "%10s %3.1f %15.8f %15.8f %15.8f" % tuple( \
[at.name.ljust(10), at.charge]+list(at.coord) )
print("%10s %3.1f %15.8f %15.8f %15.8f" % tuple( \
[at.name.ljust(10), at.charge]+list(at.coord) ), file=file)
for contr in at.basis:
sym = contr.sym
if sym == 's' :
@ -1632,13 +1632,13 @@ def gamess_write_data(res, file):
else:
doPrint = False
if doPrint:
print >>file, "%4s%8d"%(sym, len(contr.prim))
print("%4s%8d"%(sym, len(contr.prim)), file=file)
for i, p in enumerate(contr.prim):
if not isinstance(p,gaussian):
raise TypeError("Basis function is not a gaussian")
print >>file, "%6d%26.10f%12.8f"%(i+1,p.expo,contr.coef[i])
print >>file, ""
print >>file, " $END"
print("%6d%26.10f%12.8f"%(i+1,p.expo,contr.coef[i]), file=file)
print("", file=file)
print(" $END", file=file)
def gamess_write_integrals(res,file):
filename = file.name.replace('.inp','.moints')

View File

@ -26,7 +26,7 @@
import include
from . import include
eval(include.code)
import struct
@ -343,7 +343,7 @@ class gaussianFile(resultsFile):
if self._basis is None:
gfprint=False
gfinput=False
buffer = map(lambda x: x.lower(),self.options[1][0].split())
buffer = [x.lower() for x in self.options[1][0].split()]
if 'gfprint' in buffer: gfprint=True
elif 'gfinput' in buffer: gfinput=True
@ -409,7 +409,7 @@ class gaussianFile(resultsFile):
if line[0].startswith('==============='):
pos = end
else:
print "GFPRINT should be present in the gaussian keywords."
print("GFPRINT should be present in the gaussian keywords.")
return None
Nmax = basis_read[len(basis_read)-1][0]
basis = [None for i in range(Nmax)]
@ -473,7 +473,7 @@ class gaussianFile(resultsFile):
mylist = [ "G0", "G1+", "G1-", "G2+", "G2-", "G3+", "G3-",
"H4+", "H4-", "H5+", "H5-", "I6+", "I6-" ]
mylist = map(normalize_basis_name,mylist)
mylist = list(map(normalize_basis_name,mylist))
for i in mylist[:-1]:
basis[k][0] = i
basis.insert(k,list(basis[k]))
@ -904,8 +904,8 @@ class gaussianFile(resultsFile):
for i, j in local_vars:
if i not in defined_vars:
exec build_get_funcs(i) in locals()
exec build_property(i,j) in locals()
exec(build_get_funcs(i), locals())
exec(build_property(i,j), locals())
del to_remove, i, j
@ -944,7 +944,7 @@ class gaussianFile(resultsFile):
Nint = rec.pop(0)
while (index >= Nint):
index -= Nint
rec = self._file.next()
rec = next(self._file)
Nint = rec.pop(0)
rec_i = rec[:4*Nint]
@ -969,7 +969,7 @@ class gaussianFile(resultsFile):
def write_vec(res, file):
for motype in res.mo_types:
print >>file, " $VEC"
print(" $VEC", file=file)
moset = res.mo_sets[motype]
for idx,mo in enumerate(moset):
v = list(mo.vector)
@ -984,24 +984,24 @@ def write_vec(res, file):
fields.append ( linum )
for n in range(5):
fields.append ( "%15.8E"%v.pop(0) )
print >>file, ''.join(fields)
print(''.join(fields), file=file)
line += 1
print >>file, " $END"
print(" $END", file=file)
def write_data(res, file):
print >>file, " $DATA"
print >>file, res.title
print(" $DATA", file=file)
print(res.title, file=file)
point_group = res.point_group
N = point_group[1]
if N != '1':
point_group = point_group[0]+'N'+point_group[2:]
point_group += ' '+N
print >>file, point_group
print(point_group, file=file)
if N != '1':
print >>file, ""
print("", file=file)
for at in res.geometry:
print >>file, "%10s %3.1f %15.8f %15.8f %15.8f" % tuple( \
[at.name.ljust(10), at.charge]+list(at.coord) )
print("%10s %3.1f %15.8f %15.8f %15.8f" % tuple( \
[at.name.ljust(10), at.charge]+list(at.coord) ), file=file)
for contr in at.basis:
sym = contr.sym
if sym == 's' :
@ -1024,13 +1024,13 @@ def write_data(res, file):
else:
doPrint = False
if doPrint:
print >>file, "%4s%8d"%(sym, len(contr.prim))
print("%4s%8d"%(sym, len(contr.prim)), file=file)
for i, p in enumerate(contr.prim):
if not isinstance(p,gaussian):
raise TypeError("Basis function is not a gaussian")
print >>file, "%6d%26.10f%12.8f"%(i+1,p.expo,contr.coef[i])
print >>file, ""
print >>file, " $END"
print("%6d%26.10f%12.8f"%(i+1,p.expo,contr.coef[i]), file=file)
print("", file=file)
print(" $END", file=file)

View File

@ -26,7 +26,7 @@
import include
from . import include
eval(include.code)
import struct
@ -54,10 +54,10 @@ class molproFile(resultsFile):
local_vars = list(local_vars)
defined_vars = list(molproFile_defined_vars)
exec get_data('date',"DATE: ",'-3:-2') in locals()
exec get_data('point_group',"Point group",'2:') in locals()
exec get_data('version'," Version",'1:2') in locals()
exec get_data('nuclear_energy',"NUCLEAR REPULSION ENERGY", '3:4',"float") in locals()
exec(get_data('date',"DATE: ",'-3:-2'), locals())
exec(get_data('point_group',"Point group",'2:'), locals())
exec(get_data('version'," Version",'1:2'), locals())
exec(get_data('nuclear_energy',"NUCLEAR REPULSION ENERGY", '3:4',"float"), locals())
def get_num_elec(self):
if self._num_elec is None:
@ -181,7 +181,7 @@ class molproFile(resultsFile):
program = regexp.findall(line)
if program != []:
if program[0] in methods_with_orbitals:
while program[0] in occ.keys():
while program[0] in list(occ.keys()):
program[0] += 'x'
occ[program[0]] = []
progFound=True
@ -483,10 +483,10 @@ class molproFile(resultsFile):
file = open('basis.molpro','w')
molpro_write_input(self,file)
file.close()
print >>sys.stderr, """
print("""
Warning: there is a bug in the molpro output. Run the 'basis.molpro'
input file with molpro to generate a correct output for the basis set.
"""
""", file=sys.stderr)
return self._basis
def get_mo_types(self):
@ -584,7 +584,7 @@ input file with molpro to generate a correct output for the basis set.
v.sym = self.symmetries[ int(buffer[0].split('.')[1])-1 ][0]
v.eigenvalue = float(buffer[2])
if v.eigenvalue == 999999.9999:
print "Warning line", iline+1, ": '**********' in orbital eigenvalues"
print("Warning line", iline+1, ": '**********' in orbital eigenvalues")
for l,s in enumerate(self.num_orb_sym):
if l < symcount-1 :
bf += s[0]
@ -604,7 +604,7 @@ input file with molpro to generate a correct output for the basis set.
try:
x2 = k*float(x)
except ValueError:
print "Error line", iline+1, ": orbital coefficients"
print("Error line", iline+1, ": orbital coefficients")
sys.exit(1)
v.vector.append(x2)
bf+=1
@ -708,7 +708,7 @@ input file with molpro to generate a correct output for the basis set.
ncoreold=0
nactold=0
mo2=""
for ((ncore,nact),next) in zip(zip(ncore0,nact0),next0):
for ((ncore,nact),next) in zip(list(zip(ncore0,nact0)),next0):
for i in range(ncore):
tempcsf_a.append(ncoreold+i)
tempcsf_b.append(ncoreold+i)
@ -748,7 +748,7 @@ input file with molpro to generate a correct output for the basis set.
def get_closed_mos(self):
if self._closed_mos is None:
result = []
occ = filter(lambda x: x>0., self.occ_num[self.determinants_mo_type])
occ = [x for x in self.occ_num[self.determinants_mo_type] if x>0.]
maxmo = len(occ)
for orb in range(maxmo):
present = True
@ -765,7 +765,7 @@ input file with molpro to generate a correct output for the basis set.
def get_virtual_mos(self):
if self._virtual_mos is None:
result = []
occ = filter(lambda x: x>0., self.occ_num[self.determinants_mo_type])
occ = [x for x in self.occ_num[self.determinants_mo_type] if x>0.]
maxmo = len(self.mo_sets[self.determinants_mo_type])
for orb in range(maxmo):
present = False
@ -821,7 +821,7 @@ input file with molpro to generate a correct output for the basis set.
# Properties
# ----------
exec build_property("num_orb_sym","Number of SALCAO/sym") in locals()
exec(build_property("num_orb_sym","Number of SALCAO/sym"), locals())
to_remove = []
for i, j in local_vars:
if i in resultsFile_defined_vars:
@ -831,8 +831,8 @@ input file with molpro to generate a correct output for the basis set.
for i, j in local_vars:
if i not in defined_vars:
exec build_get_funcs(i) in locals()
exec build_property(i,j) in locals()
exec(build_get_funcs(i), locals())
exec(build_property(i,j), locals())
del to_remove, i, j
# Output Routines
@ -840,9 +840,9 @@ input file with molpro to generate a correct output for the basis set.
def molpro_write_input(res,file):
print >>file, " ***,", res.title
print(" ***,", res.title, file=file)
geom = res.geometry
print >>file, """
print("""
print,basis;
print,orbitals;
gprint,civector;
@ -850,17 +850,17 @@ def molpro_write_input(res,file):
geomtyp=xyz
geometry={
""", len(geom)
print >>file, res.title
""", len(geom), file=file)
print(res.title, file=file)
i=1
for at in geom:
coord = []
for x in at.coord: coord.append(x*a0)
print >>file, "%10s %15.8f %15.8f %15.8f" % tuple( \
[(at.name+str(i)).ljust(10) ]+coord )
print("%10s %15.8f %15.8f %15.8f" % tuple( \
[(at.name+str(i)).ljust(10) ]+coord ), file=file)
i+=1
print >>file, "}\n"
print >>file, "basis={"
print("}\n", file=file)
print("basis={", file=file)
lines = []
for idx,at in enumerate(geom):
# Find atom
@ -925,11 +925,11 @@ def molpro_write_input(res,file):
if line not in lines:
lines.append(line)
for line in lines:
print >>file, line
print >>file, "}\n",
print(line, file=file)
print("}\n", end=' ', file=file)
print >>file, "rhf;"
print >>file, "---"
print("rhf;", file=file)
print("---", file=file)
fileTypes.append(molproFile)

View File

@ -26,7 +26,7 @@
import include
from . import include
eval(include.code)
import struct
@ -336,8 +336,8 @@ class wfnFile(resultsFile):
for i, j in local_vars:
if i not in defined_vars:
exec build_get_funcs(i) in locals()
exec build_property(i,j) in locals()
exec(build_get_funcs(i), locals())
exec(build_property(i,j), locals())
del to_remove, i, j
@ -381,9 +381,9 @@ basis_correspond['f+2'] = 16
basis_correspond['f+3'] = 17
def wfn_write(res,file,MO_type=None):
print >>file, " "+res.title.strip()
print >>file, "GAUSSIAN %14d MOL ORBITALS %6d PRIMITIVES %8d NUCLEI" \
%(len(res.closed_mos+res.active_mos), len(res.uncontracted_basis), len(res.geometry)),
print(" "+res.title.strip(), file=file)
print("GAUSSIAN %14d MOL ORBITALS %6d PRIMITIVES %8d NUCLEI" \
%(len(res.closed_mos+res.active_mos), len(res.uncontracted_basis), len(res.geometry)), end=' ', file=file)
# write geom
geom = res.geometry
@ -394,8 +394,8 @@ def wfn_write(res,file,MO_type=None):
name = atom.name
for d in string.digits:
name = name.replace(d,'')
print >>file, "\n%3s %4d (CENTRE%3d) %12.8f%12.8f%12.8f CHARGE = %4.1f" \
%(name, i+1, i+1, atom.coord[0]*f, atom.coord[1]*f, atom.coord[2]*f, atom.charge),
print("\n%3s %4d (CENTRE%3d) %12.8f%12.8f%12.8f CHARGE = %4.1f" \
%(name, i+1, i+1, atom.coord[0]*f, atom.coord[1]*f, atom.coord[2]*f, atom.charge), end=' ', file=file)
# write basis
basis = res.uncontracted_basis
@ -415,23 +415,23 @@ def wfn_write(res,file,MO_type=None):
k=0
for c in center:
if k%20 == 0:
print "\nCENTRE ASSIGNMENTS ",
print "%2d"%(c),
print("\nCENTRE ASSIGNMENTS ", end=' ')
print("%2d"%(c), end=' ')
k+=1
k=0
for t in type:
if k%20 == 0:
print "\nTYPE ASSIGNMENTS ",
print "%2d"%(t),
print("\nTYPE ASSIGNMENTS ", end=' ')
print("%2d"%(t), end=' ')
k+=1
k=0
for e in expo:
if k%5 == 0:
print "\nEXPONENTS ",
print ("%13.7e"%(e)).replace('e','D'),
print("\nEXPONENTS ", end=' ')
print(("%13.7e"%(e)).replace('e','D'), end=' ')
k+=1
print '\n',
print('\n', end=' ')
# MOs
if MO_type is None:
@ -439,7 +439,7 @@ def wfn_write(res,file,MO_type=None):
try:
allMOs = res.uncontracted_mo_sets[MO_type]
except KeyError:
print "MO type not present in "+res.filename
print("MO type not present in "+res.filename)
return
mos = []
occ = res.occ_num[MO_type]
@ -449,22 +449,22 @@ def wfn_write(res,file,MO_type=None):
for i,orb2 in enumerate(mos):
if occ[orb2[2]] > 0.:
orb = orb2[1]
print "MO %4d MO 0.0 OCC NO = %9.7f ORB. ENERGY =%12.6f" \
%(i+1, occ[orb2[2]], orb.eigenvalue),
print("MO %4d MO 0.0 OCC NO = %9.7f ORB. ENERGY =%12.6f" \
%(i+1, occ[orb2[2]], orb.eigenvalue), end=' ')
k=0
for c in orb.vector:
if k%5 == 0:
print "\n",
print "%15.8e"%(c),
print("\n", end=' ')
print("%15.8e"%(c), end=' ')
k+=1
print "\n",
print "END DATA"
print("\n", end=' ')
print("END DATA")
idx = res.mo_types.index(MO_type)
try:
print " THE HF ENERGY =%20.12f THE VIRIAL(-V/T)="%(res.energies[idx]),
print "%12.8f"%(res.virials[idx])
print(" THE HF ENERGY =%20.12f THE VIRIAL(-V/T)="%(res.energies[idx]), end=' ')
print("%12.8f"%(res.virials[idx]))
except TypeError:
print " THE HF ENERGY =%20.12f THE VIRIAL(-V/T)=%12.8f"%(0.,0.)
print(" THE HF ENERGY =%20.12f THE VIRIAL(-V/T)=%12.8f"%(0.,0.))
@ -472,7 +472,7 @@ def wfn_write(res,file,MO_type=None):
def write_wfnFile(file,out=sys.stdout):
if "basis" in file.mo_sets.keys() :
if "basis" in list(file.mo_sets.keys()) :
MoType = "basis"
else:
MoType = None

View File

@ -26,7 +26,7 @@
import include
from . import include
eval(include.code)
import struct
@ -316,7 +316,7 @@ class xmvbFile(resultsFile):
if len(bf) > 0:
basis_read.append( [index,sym,bf,iatom] )
else:
print "GFPRINT should be present in the gaussian keywords."
print("GFPRINT should be present in the gaussian keywords.")
return None
Nmax = basis_read[len(basis_read)-1][0]
basis = [None for i in range(Nmax)]
@ -373,7 +373,7 @@ class xmvbFile(resultsFile):
# "XXXXYZ", "YYYYXZ", "ZZZZXY", "XXXYYY", "XXXZZZ", \
# "YYYZZZ", "XXXYYZ", "XXXZZY", "YYYXXZ", "YYYZZX", \
# "ZZZXXY", "ZZZYYX" ]
mylist = map(normalize_basis_name,mylist)
mylist = list(map(normalize_basis_name,mylist))
for i in mylist[:-1]:
basis[k][0] = i
basis.insert(k,list(basis[k]))
@ -718,8 +718,8 @@ class xmvbFile(resultsFile):
for i, j in local_vars:
if i not in defined_vars:
exec build_get_funcs(i) in locals()
exec build_property(i,j) in locals()
exec(build_get_funcs(i), locals())
exec(build_property(i,j), locals())
del to_remove, i, j

View File

@ -36,9 +36,9 @@ all = [ "resultsFile", "getFile", "lib", "Modules" ]
for mod in all:
try:
exec 'from '+mod+' import *'
exec('from '+mod+' import *')
except:
print "Error importing module", mod
print("Error importing module", mod)
pass

View File

@ -26,7 +26,7 @@
from resultsFile import *
from .resultsFile import *
import sys
# Find fileType
@ -44,7 +44,7 @@ def getFile(name):
pass
if fileType is None:
print "File type not recognized."
print("File type not recognized.")
sys.exit(1)
return file

View File

@ -38,9 +38,9 @@ all = [ i[:-3] for i in os.listdir(wd) if i.endswith(".py") ]
for mod in all:
try:
exec 'from '+mod+' import *'
exec('from '+mod+' import *')
except:
print "Error importing module", mod
print("Error importing module", mod)
pass

View File

@ -26,7 +26,7 @@
from library import *
from .library import *
from math import *
class atom(object):
@ -62,10 +62,10 @@ class atom(object):
return 0
for i in "name charge coord basis".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
class atomDataElement(object):
@ -213,5 +213,5 @@ for line in atomDataText.splitlines():
if __name__ == '__main__':
for s in atomData:
print s
print(s)

View File

@ -27,7 +27,7 @@
#import pdb
from library import *
from .library import *
from math import *
import sys
@ -97,10 +97,10 @@ class primitive(object):
norm = property (get_norm,None,doc="Sqrt( Integral f^2(R) dR ).")
for i in "center expo sym".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
#-----------------------
@ -132,7 +132,7 @@ def binom(n,m):
def rintgauss(n):
def ddfact2(n):
if n%2 == 0: print 'error in ddfact2'
if n%2 == 0: print('error in ddfact2')
res=1.
for i in range(1,n+1,2):
res*=float(i)
@ -228,7 +228,7 @@ def xyz_from_lm(l,m):
absm = abs(m)
nb2 = absm
nb1 = (l-absm)/2
clmt = [ (-0.25)**t * binom(l,t) * binom(l-t,absm+t) for t in xrange(nb1+1) ]
clmt = [ (-0.25)**t * binom(l,t) * binom(l-t,absm+t) for t in range(nb1+1) ]
mod_absm_2 = absm % 2
if m>=0:
nb2_start = mod_absm_2
@ -241,8 +241,8 @@ def xyz_from_lm(l,m):
for n1 in range(nb2_start,nb2+1,2):
k = (absm-n1)/2
factor = (-1.)**k * binom(absm,n1) * norm
for t in xrange(nb1+1):
for n2 in xrange(t+1):
for t in range(nb1+1):
for n2 in range(t+1):
coe = clmt[t] * factor * binom(t,n2)
ipw = ( n1+2*n2 , absm-n1+2*(t-n2), l-2*t-absm )
done = False
@ -402,10 +402,10 @@ class contraction(object):
for i in "center prim sym coef".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
norm = property (get_norm,None,doc="Sqrt( Integral f^2(R) dR ).")
@ -425,9 +425,9 @@ except ImportError:
if __name__ == '__main__':
for l in range(6):
print '---'
print('---')
for m in range(-l,l+1):
print "%3d %3d :"%(l,m), xyz_from_lm(l,m)
print("%3d %3d :"%(l,m), xyz_from_lm(l,m))
sys.exit(0)
if __name__ == '__main__':
@ -441,13 +441,13 @@ if __name__ == '__main__':
b.center = [0.,0.,0.]
x = spheToCart(a)
y = spheToCart(a)
print x
print(x)
sys.exit(0)
print GoverlapCart(a,b)
print GoverlapCartNorm2(a,b)
print ''
print(GoverlapCart(a,b))
print(GoverlapCartNorm2(a,b))
print('')
for i in range(0,10):
print rintgauss(i)
print(rintgauss(i))
sys.exit(0)
c = gaussian()
c.sym = 's'
@ -458,7 +458,7 @@ if __name__ == '__main__':
d.append(0.190362765893, b)
d.append(0.852162022245, c)
d.normalize()
print d
print(d)
sys.exit(0)
a = gaussian()
a.sym = 'x'
@ -471,14 +471,14 @@ if __name__ == '__main__':
c = contraction()
c.append(1.,a)
c.append(2.,b)
print c.value( (1.,1.,0.) )
print b.overlap(a)
print a.overlap(b)
print a.norm
print c.norm, c.coef
print(c.value( (1.,1.,0.) ))
print(b.overlap(a))
print(a.overlap(b))
print(a.norm)
print(c.norm, c.coef)
c.normalize()
print c.norm, c.coef
print(c.norm, c.coef)
c.normalize()
print c.norm, c.coef
print Goverlap(a,b)
print(c.norm, c.coef)
print(Goverlap(a,b))

View File

@ -26,7 +26,7 @@
from library import *
from .library import *
class CSF(object):
"""Class for an configuration state function."""
@ -69,8 +69,8 @@ class CSF(object):
self._coefficients.append( c )
for i in "determinants coefficients".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())

View File

@ -27,7 +27,7 @@
import struct
from library import *
from .library import *
import sys
class fortranBinary(object):
@ -51,7 +51,7 @@ Behaves like an array of records.
def seek(self,index):
self.file.seek(index)
def next(self):
def __next__(self):
if self.form is None:
raise TypeError
data = self.file.read(4) # Rec length at the beginning of record
@ -102,18 +102,18 @@ Behaves like an array of records.
# file = property ( get_file, doc="Binary file")
# form = xproperty ( '_form', doc="Format to read the binary record")
for i in "recl mode name file form".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
if __name__ == '__main__':
f = fortranBinary(sys.argv[1],"rb")
f.form = 'l'+4*15000*'h'+15000*'d'
print f.name
print f.mode
print f[0]
print f[10]
print f[0]
print(f.name)
print(f.mode)
print(f[0])
print(f[10])
print(f[0])

View File

@ -26,7 +26,7 @@
from library import *
from .library import *
from math import *
class integral(object):
@ -56,19 +56,19 @@ class integral(object):
return 0
for i in "indices value".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
if __name__ == '__main__':
i = integral()
i.indices = [1,4]
i.value = 1.5
print i
print(i)
j = integral()
j.indices = [4,3,2,1]
j.value = 2.5
print j
print i<j
print(j)
print(i<j)

View File

@ -35,10 +35,10 @@ def prettyPrint(obj,shift=" "):
prettyPrint(k)
elif isinstance(obj,dict):
for k in obj:
print k
print(k)
prettyPrint(obj[k])
else:
print str(obj)
print(str(obj))
def xproperty(fget, fset=None, fdel=None, doc=None):
"""Automatically defines the properties if the functions don't exist."""

View File

@ -26,7 +26,7 @@
from library import *
from .library import *
from math import *
class orbital(object):
@ -96,10 +96,10 @@ class orbital(object):
return result
for i in "eigenvalue vector basis set sym".split():
exec """
exec("""
def get_%(i)s(self): return self._%(i)s
def set_%(i)s(self,value): self._%(i)s = value
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals()
%(i)s = property(fget=get_%(i)s,fset=set_%(i)s) """%locals())
@ -114,20 +114,20 @@ if __name__ == '__main__':
l[1].eigenvalue = 1.
l[2].eigenvalue = 3.
for i in l:
print i.eigenvalue
print(i.eigenvalue)
l.sort()
print ""
print("")
for i in l:
print i.eigenvalue
print(i.eigenvalue)
l[0].vector = [1., 0., 0.]
l[1].vector = [0., 1., 0.]
l[2].vector = [0., 1., 1.]
print l[0].is_ortho(l[1])
print l[1].is_ortho(l[2])
print l[1].dot(l[2])
print l[1].dot(l[0])
print l[1].norm()
print l[2].norm()
print(l[0].is_ortho(l[1]))
print(l[1].is_ortho(l[2]))
print(l[1].dot(l[2]))
print(l[1].dot(l[0]))
print(l[1].norm())
print(l[2].norm())