Skip to content

Commit 2ed3d4c

Browse files
committed
Fix python 3 print bug, fix duplicate/symmetry bug in cross terms
1 parent 0fc8ec6 commit 2ed3d4c

File tree

2 files changed

+63
-71
lines changed

2 files changed

+63
-71
lines changed

quickff/io.py

Lines changed: 62 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
#--
2525

26-
from __future__ import print_function, absolute_import
26+
from __future__ import print_function, absolute_import, unicode_literals
2727

2828
'''Readers ab initio vibrational calculations.
2929
'''
@@ -718,22 +718,22 @@ def _cross_to_yaff(valence):
718718
if b0a is not None: Kbs0, r0, theta0 = b0a
719719
if b1a is not None: Kbs1, r1, theta0 = b1a
720720
ffatypes = ffatypes.split('.')
721-
pars.lines.append(
722-
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
723-
ffatypes[0], ffatypes[1], ffatypes[2],
724-
Kss/(kjmol/angstrom**2), Kbs0/(kjmol/angstrom),
725-
Kbs1/(kjmol/angstrom), r0/angstrom, r1/angstrom, theta0/deg,
726-
))
727-
#add identical line with inversed order of atom types to ensure all
728-
#angle patterns have corresponding ff parameters. Only do this if
729-
#inversed angle pattern is different from original
730721
if ffatypes[::-1]!=ffatypes:
722+
pars.lines.append(
723+
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
724+
ffatypes[0], ffatypes[1], ffatypes[2],
725+
Kss/(kjmol/angstrom**2), Kbs0/(kjmol/angstrom),
726+
Kbs1/(kjmol/angstrom), r0/angstrom, r1/angstrom, theta0/deg,
727+
))
728+
#average parameters for symmetric terms
729+
else:
731730
pars.lines.append(
732731
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
733732
ffatypes[2], ffatypes[1], ffatypes[0],
734-
Kss/(kjmol/angstrom**2), Kbs1/(kjmol/angstrom),
735-
Kbs0/(kjmol/angstrom), r1/angstrom, r0/angstrom, theta0/deg,
736-
))
733+
Kss/(kjmol/angstrom**2), 0.5*(Kbs0+Kbs1)/(kjmol/angstrom),
734+
0.5*(Kbs0+Kbs1)/(kjmol/angstrom), r1/angstrom, r0/angstrom,
735+
theta0/deg,
736+
))
737737
done.append(label)
738738
return ParameterSection(prefix, definitions={'UNIT': units, 'PARS': pars})
739739

@@ -771,22 +771,20 @@ def _crosscbend_to_yaff(valence):
771771
if b0a is not None: Kbs0, r0, cos0 = b0a
772772
if b1a is not None: Kbs1, r1, cos0 = b1a
773773
ffatypes = ffatypes.split('.')
774-
pars.lines.append(
775-
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
776-
ffatypes[0], ffatypes[1], ffatypes[2],
777-
Kss/(kjmol/angstrom**2), Kbs0/(kjmol/angstrom),
778-
Kbs1/(kjmol/angstrom), r0/angstrom, r1/angstrom, cos0,
779-
))
780-
#add identical line with inversed order of atom types to ensure all
781-
#angle patterns have corresponding ff parameters. Only do this if
782-
#inversed angle pattern is different from original
783774
if ffatypes[::-1]!=ffatypes:
784775
pars.lines.append(
785-
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
786-
ffatypes[2], ffatypes[1], ffatypes[0],
787-
Kss/(kjmol/angstrom**2), Kbs1/(kjmol/angstrom),
788-
Kbs0/(kjmol/angstrom), r1/angstrom, r0/angstrom, cos0,
789-
))
776+
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
777+
ffatypes[0], ffatypes[1], ffatypes[2],
778+
Kss/(kjmol/angstrom**2), Kbs0/(kjmol/angstrom),
779+
Kbs1/(kjmol/angstrom), r0/angstrom, r1/angstrom, cos0,
780+
))
781+
else:
782+
pars.lines.append(
783+
'%8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
784+
ffatypes[0], ffatypes[1], ffatypes[2],
785+
Kss/(kjmol/angstrom**2), 0.5*(Kbs0+Kbs1)/(kjmol/angstrom),
786+
0.5*(Kbs0+Kbs1)/(kjmol/angstrom), r0/angstrom, r1/angstrom, cos0,
787+
))
790788
done.append(label)
791789
return ParameterSection(prefix, definitions={'UNIT': units, 'PARS': pars})
792790

@@ -828,24 +826,22 @@ def _crossbonddihed_to_yaff(valence, m):
828826
if b1d is not None: Ksd1, r1, cpsi0 = b1d
829827
if b2d is not None: Ksd2, r2, cpsi0 = b2d
830828
ffatypes = ffatypes.split('.')
831-
pars.lines.append(
832-
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e %.10e %.10e' %(
833-
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
834-
Kss/(kjmol/angstrom**2), Ksd0/(kjmol/angstrom),
835-
Ksd1/(kjmol/angstrom), Ksd2/(kjmol/angstrom),
836-
r0/angstrom, r1/angstrom, r2/angstrom, cpsi0,
837-
))
838-
#add identical line with inversed order of atom types to ensure all
839-
#angle patterns have corresponding ff parameters. Only do this if
840-
#inversed angle pattern is different from original
841829
if ffatypes[::-1]!=ffatypes:
830+
pars.lines.append(
831+
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e %.10e %.10e' %(
832+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
833+
Kss/(kjmol/angstrom**2), Ksd0/(kjmol/angstrom),
834+
Ksd1/(kjmol/angstrom), Ksd2/(kjmol/angstrom),
835+
r0/angstrom, r1/angstrom, r2/angstrom, cpsi0,
836+
))
837+
else:
842838
pars.lines.append(
843839
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e %.10e %.10e' %(
844-
ffatypes[3], ffatypes[2], ffatypes[1], ffatypes[0],
845-
Kss/(kjmol/angstrom**2), Ksd2/(kjmol/angstrom),
846-
Ksd1/(kjmol/angstrom), Ksd0/(kjmol/angstrom),
847-
r2/angstrom, r1/angstrom, r0/angstrom, cpsi0,
848-
))
840+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
841+
Kss/(kjmol/angstrom**2), 0.5*(Ksd0+Ksd2)/(kjmol/angstrom),
842+
Ksd1/(kjmol/angstrom), 0.5*(Ksd0+Ksd2)/(kjmol/angstrom),
843+
r0/angstrom, r1/angstrom, r2/angstrom, cpsi0,
844+
))
849845
done.append(label)
850846
return ParameterSection(prefix, definitions={'UNIT': units, 'PARS': pars})
851847

@@ -883,22 +879,20 @@ def _crossbenddihed_to_yaff(valence, m):
883879
if a0d is not None: Kad0, theta0, cpsi0 = a0d
884880
if a1d is not None: Kad1, theta1, cpsi0 = a1d
885881
ffatypes = ffatypes.split('.')
886-
pars.lines.append(
887-
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
888-
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
889-
Kaa/kjmol, Kad0/kjmol, Kad1/kjmol,
890-
theta0/deg, theta1/deg, cpsi0,
891-
))
892-
#add identical line with inversed order of atom types to ensure all
893-
#angle patterns have corresponding ff parameters. Only do this if
894-
#inversed angle pattern is different from original
895882
if ffatypes[::-1]!=ffatypes:
896883
pars.lines.append(
897-
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
898-
ffatypes[3], ffatypes[2], ffatypes[1], ffatypes[0],
899-
Kaa/kjmol, Kad1/kjmol, Kad0/kjmol,
900-
theta1/deg, theta0/deg, cpsi0,
901-
))
884+
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
885+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
886+
Kaa/kjmol, Kad0/kjmol, Kad1/kjmol,
887+
theta0/deg, theta1/deg, cpsi0,
888+
))
889+
else:
890+
pars.lines.append(
891+
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
892+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
893+
Kaa/kjmol, 0.5*(Kad0+Kad1)/kjmol, 0.5*(Kad0+Kad1)/kjmol,
894+
theta0/deg, theta1/deg, cpsi0,
895+
))
902896
done.append(label)
903897
return ParameterSection(prefix, definitions={'UNIT': units, 'PARS': pars})
904898

@@ -935,22 +929,20 @@ def _crosscbenddihed_to_yaff(valence):
935929
if a0d is not None: Kad0, ctheta0, cpsi0 = a0d
936930
if a1d is not None: Kad1, ctheta1, cpsi0 = a1d
937931
ffatypes = ffatypes.split('.')
938-
pars.lines.append(
939-
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
940-
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
941-
Kaa/kjmol, Kad0/kjmol, Kad1/kjmol,
942-
ctheta0, ctheta1, cpsi0,
943-
))
944-
#add identical line with inversed order of atom types to ensure all
945-
#angle patterns have corresponding ff parameters. Only do this if
946-
#inversed angle pattern is different from original
947932
if ffatypes[::-1]!=ffatypes:
948933
pars.lines.append(
949-
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
950-
ffatypes[3], ffatypes[2], ffatypes[1], ffatypes[0],
951-
Kaa/kjmol, Kad1/kjmol, Kad0/kjmol,
952-
ctheta1, ctheta0, cpsi0,
953-
))
934+
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
935+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
936+
Kaa/kjmol, Kad0/kjmol, Kad1/kjmol,
937+
ctheta0, ctheta1, cpsi0,
938+
))
939+
else:
940+
pars.lines.append(
941+
'%8s %8s %8s %8s % .10e % .10e % .10e %.10e %.10e %.10e' %(
942+
ffatypes[0], ffatypes[1], ffatypes[2], ffatypes[3],
943+
Kaa/kjmol, 0.5*(Kad0+Kad1)/kjmol, 0.5*(Kad0+Kad1)/kjmol,
944+
ctheta0, ctheta1, cpsi0,
945+
))
954946
done.append(label)
955947
return ParameterSection(prefix, definitions={'UNIT': units, 'PARS': pars})
956948

quickff/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def warning(self, message, new_line=True):
181181
for piece in splitstring('WARNING: '+message, self.ll-self.mll):
182182
line += ' ' + self.label[:self.mll-2] + ' '
183183
line += ' '*(self.mll-2 - len(self.label[:self.mll-2]))
184-
line += piece.encode('utf-8')
184+
line += piece #.encode('utf-8')
185185
line += '\n'
186186
line = line.rstrip('\n')
187187
print(line, file=self._f)

0 commit comments

Comments
 (0)