diff --git a/testsuite/python/bond_breakage.py b/testsuite/python/bond_breakage.py index fc89d2c57e3..ba538cb81c9 100644 --- a/testsuite/python/bond_breakage.py +++ b/testsuite/python/bond_breakage.py @@ -64,8 +64,10 @@ def tearDown(self): def test_00_interface(self): self.assertEqual(len(self.system.bond_breakage), 0) - spec2 = BreakageSpec(breakage_length=1.2, action_type=1) - spec4 = BreakageSpec(breakage_length=0.2, action_type=2) + spec2 = BreakageSpec( + breakage_length=1.2, + action_type="revert_center_bond") + spec4 = BreakageSpec(breakage_length=0.2, action_type="revert_vs_bond") self.system.bond_breakage[2] = spec2 self.system.bond_breakage[4] = spec4 self.assertEqual(self.system.bond_breakage[2], spec2) @@ -91,7 +93,7 @@ def test_ignore(self): # Particles closer than cutoff system.bond_breakage[self.h1._bond_id] = BreakageSpec( - breakage_length=2, action_type=1) + breakage_length=2, action_type="revert_center_bond") self.p1.bonds = ((self.h1, self.p2)) system.integrator.run(1) @@ -103,7 +105,7 @@ def test_ignore(self): # Different bond type system.bond_breakage[self.h1._bond_id] = BreakageSpec( - breakage_length=0.2, action_type=1) + breakage_length=0.2, action_type="revert_center_bond") self.p1.bonds = [(self.h2, self.p2)] self.p2.bonds = [(self.h2, self.p1)] system.integrator.run(1) @@ -115,7 +117,7 @@ def test_delete_bond(self): # Particles closer than cutoff system.bond_breakage[self.h1._bond_id] = BreakageSpec( - breakage_length=0, action_type=1) + breakage_length=0, action_type="revert_center_bond") self.p1.bonds = [(self.h1, self.p2)] system.integrator.run(1) @@ -130,7 +132,7 @@ def test_revert_bind_at_point_of_collision(self): # Particles closer than cutoff system.bond_breakage[self.h1._bond_id] = BreakageSpec( - breakage_length=0.5, action_type=2) + breakage_length=0.5, action_type="revert_vs_bond") self.p1.bonds = [(self.h2, self.p2)] self.p1v.bonds = [(self.h1, self.p2v)] @@ -167,6 +169,17 @@ def setUpClass(cls): cls.system.time_step = 0.01 cls.system.cell_system.skin = 0.4 + def count_bonds(self, pairs): + bonds_count = 0 + for pair in pairs: + for bond in self.system.part.by_id(pair[0]).bonds: + if bond[1] == pair[1]: + bonds_count += 1 + for bond in self.system.part.by_id(pair[1]).bonds: + if bond[1] == pair[0]: + bonds_count += 1 + return bonds_count + def setUp(self): box_vol = self.system.box_l[0]**3. @@ -213,7 +226,7 @@ def test_center_bonds(self): self.system.collision_detection.set_params(mode="off") self.system.bond_breakage[harm._bond_id] = BreakageSpec( - breakage_length=crit, action_type=1) + breakage_length=crit, action_type="revert_center_bond") self.system.integrator.run(1) bonds_dist = 0 @@ -225,17 +238,7 @@ def test_center_bonds(self): if dist <= crit: bonds_dist += 1 - bonds_count = 0 - for pair in pairs: - num_bonds = len(self.system.part.by_id(pair[0]).bonds) - for i in range(num_bonds): - if self.system.part.by_id(pair[0]).bonds[i][1] == pair[1]: - bonds_count += 1 - num_bonds = len(self.system.part.by_id(pair[1]).bonds) - for i in range(num_bonds): - if self.system.part.by_id(pair[1]).bonds[i][1] == pair[0]: - bonds_count += 1 - + bonds_count = self.count_bonds(pairs) np.testing.assert_equal(bonds_dist, bonds_count) @utx.skipIfMissingFeatures("VIRTUAL_SITES_RELATIVE") @@ -256,7 +259,7 @@ def test_vs_bonds(self): self.system.collision_detection.set_params(mode="off") self.system.bond_breakage[harm._bond_id] = BreakageSpec( - breakage_length=crit_vs, action_type=2) + breakage_length=crit_vs, action_type="revert_vs_bond") self.system.integrator.run(1) bonds_dist = 0 @@ -277,16 +280,7 @@ def test_vs_bonds(self): if dist > 0.0: bonds_dist += 1 - bonds_count = 0 - for pair in pairs: - num_bonds = len(self.system.part.by_id(pair[0]).bonds) - for i in range(num_bonds): - if self.system.part.by_id(pair[0]).bonds[i][1] == pair[1]: - bonds_count += 1 - num_bonds = len(self.system.part.by_id(pair[1]).bonds) - for i in range(num_bonds): - if self.system.part.by_id(pair[1]).bonds[i][1] == pair[0]: - bonds_count += 1 + bonds_count = self.count_bonds(pairs) np.testing.assert_equal(bonds_dist, bonds_count)