From 845b26e280afdcb1565f7fb568262a2ae87db39d Mon Sep 17 00:00:00 2001 From: Louis Vanduyfhuys Date: Mon, 5 Feb 2018 13:37:19 +0100 Subject: [PATCH] Fixed some python 3 print bugs as well as include missing iter_equiv_keys_and_pars routines in Cross generators --- yaff/pes/generator.py | 30 +++++++++++++++++++++--------- yaff/pes/test/test_iclist.py | 8 ++++---- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/yaff/pes/generator.py b/yaff/pes/generator.py index 470dd6bf..9e654e82 100644 --- a/yaff/pes/generator.py +++ b/yaff/pes/generator.py @@ -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]) @@ -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() @@ -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 @@ -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() @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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() diff --git a/yaff/pes/test/test_iclist.py b/yaff/pes/test/test_iclist.py index 339c28f9..51603a9f 100644 --- a/yaff/pes/test/test_iclist.py +++ b/yaff/pes/test/test_iclist.py @@ -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(): @@ -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(): @@ -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(): @@ -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():