Skip to content

Commit

Permalink
Fixed some python 3 print bugs as well as include missing iter_equiv_…
Browse files Browse the repository at this point in the history
…keys_and_pars routines in Cross generators
  • Loading branch information
lvduyfhu committed Feb 5, 2018
1 parent 9196186 commit 845b26e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
30 changes: 21 additions & 9 deletions yaff/pes/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,8 @@ def apply(self, par_table, system, ff_args):
part_valence = ff_args.get_part_valence(system)
vterms = []
ics = []
for i in xrange(6):
for j in xrange(i+1,6):
for i in range(6):
for j in range(i+1,6):
VClass = self.__class__.__dict__['VClass%i%i' %(i,j)]
if VClass is not None:
vterms.append([i,j,VClass])
Expand Down Expand Up @@ -1161,6 +1161,10 @@ class CrossBondDihedralGenerator(ValenceCrossGenerator):

def iter_alt_keys(self, key):
yield key

def iter_equiv_keys_and_pars(self, key, pars):
yield key, pars
yield key[::-1], (pars[0], pars[3], pars[2], pars[1], pars[6], pars[5], pars[4], pars[7])

def iter_indexes(self, system):
return system.iter_dihedrals()
Expand Down Expand Up @@ -1301,7 +1305,7 @@ class CrossBendDihedralGenerator(ValenceCrossGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1313,7 +1317,11 @@ class CrossBendDihedralGenerator(ValenceCrossGenerator):
VClass45 = None

def iter_alt_keys(self, key):
yield key
yield key

def iter_equiv_keys_and_pars(self, key, pars):
yield key, pars
yield key[::-1], (pars[0], pars[2], pars[1], pars[4], pars[3], pars[5])

def iter_indexes(self, system):
return system.iter_dihedrals()
Expand Down Expand Up @@ -1343,7 +1351,7 @@ class CrossBendDihedral2Generator(CrossBendDihedralGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1370,7 +1378,7 @@ class CrossBendDihedral3Generator(CrossBendDihedralGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1397,7 +1405,7 @@ class CrossBendDihedral4Generator(CrossBendDihedralGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1424,7 +1432,7 @@ class CrossBendDihedral6Generator(CrossBendDihedralGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1451,7 +1459,7 @@ class CrossBendCosDihedralGenerator(ValenceCrossGenerator):
VClass03 = None
VClass04 = None
VClass05 = None
VClass12 = None #bend123,dihed0123
VClass12 = Cross #bend123,dihed0123
VClass13 = None
VClass14 = None
VClass15 = None
Expand All @@ -1465,6 +1473,10 @@ class CrossBendCosDihedralGenerator(ValenceCrossGenerator):
def iter_alt_keys(self, key):
yield key

def iter_equiv_keys_and_pars(self, key, pars):
yield key, pars
yield key[::-1], (pars[0], pars[2], pars[1], pars[4], pars[3], pars[5])

def iter_indexes(self, system):
return system.iter_dihedrals()

Expand Down
8 changes: 4 additions & 4 deletions yaff/pes/test/test_iclist.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_iclist_peroxide_dihedral_cos2():
dlist.forward()
iclist.forward()
angle = dihed_angle(system.pos)[0]
print 'psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(2*angle), iclist.ictab[3]['value'])
print('psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(2*angle), iclist.ictab[3]['value']))
assert abs(iclist.ictab[3]['value'] - np.cos(2*angle)) < 1e-5

def test_iclist_peroxide_dihedral_cos3():
Expand All @@ -192,7 +192,7 @@ def test_iclist_peroxide_dihedral_cos3():
dlist.forward()
iclist.forward()
angle = dihed_angle(system.pos)[0]
print 'psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(3*angle), iclist.ictab[3]['value'])
print('psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(3*angle), iclist.ictab[3]['value']))
assert abs(iclist.ictab[3]['value'] - np.cos(3*angle)) < 1e-5

def test_iclist_peroxide_dihedral_cos4():
Expand All @@ -214,7 +214,7 @@ def test_iclist_peroxide_dihedral_cos4():
dlist.forward()
iclist.forward()
angle = dihed_angle(system.pos)[0]
print 'psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(4*angle), iclist.ictab[3]['value'])
print('psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(4*angle), iclist.ictab[3]['value']))
assert abs(iclist.ictab[3]['value'] - np.cos(4*angle)) < 1e-5

def test_iclist_peroxide_dihedral_cos6():
Expand All @@ -236,7 +236,7 @@ def test_iclist_peroxide_dihedral_cos6():
dlist.forward()
iclist.forward()
angle = dihed_angle(system.pos)[0]
print 'psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(6*angle), iclist.ictab[3]['value'])
print('psi=%.3f deg: target=%.6f value=%.6f' %(angle/deg, np.cos(6*angle), iclist.ictab[3]['value']))
assert abs(iclist.ictab[3]['value'] - np.cos(6*angle)) < 1e-5

def test_iclist_grad_dihedral_cos_mil53():
Expand Down

0 comments on commit 845b26e

Please sign in to comment.