diff --git a/src/core/collision_detection/GlueToSurface.cpp b/src/core/collision_detection/GlueToSurface.cpp index 8390d2f5d2..a9a3b6f309 100644 --- a/src/core/collision_detection/GlueToSurface.cpp +++ b/src/core/collision_detection/GlueToSurface.cpp @@ -58,6 +58,20 @@ void GlueToSurface::initialize(System::System &system) { // Cache square of cutoff distance_sq = Utils::sqr(distance); + // Check that the bonds have the right number of partners. Both bonds are + // stored with a single-partner list in handle_collisions(), so they must + // be strict pair bonds (existence is already guaranteed at the seam). + assert(system.bonded_ias->contains(bond_centers)); + if (number_of_partners(*system.bonded_ias->at(bond_centers)) != 1) { + throw std::runtime_error("The bond type to be used for binding particle " + "centers needs to be a pair bond"); + } + assert(system.bonded_ias->contains(bond_vs)); + if (number_of_partners(*system.bonded_ias->at(bond_vs)) != 1) { + throw std::runtime_error("The bond type to be used for binding virtual " + "sites needs to be a pair bond"); + } + if (part_type_vs < 0) { throw std::domain_error("Collision detection particle type for virtual " "sites needs to be >=0"); diff --git a/testsuite/python/collision_detection_interface.py b/testsuite/python/collision_detection_interface.py index bd629c8d1a..a5988d49f1 100644 --- a/testsuite/python/collision_detection_interface.py +++ b/testsuite/python/collision_detection_interface.py @@ -153,6 +153,10 @@ def test_glue_to_surface(self): self.set_coldet("glue_to_surface", part_type_to_attach_vs_to=-1) with self.assertRaisesRegex(ValueError, "type after gluing needs to be >=0"): self.set_coldet("glue_to_surface", part_type_after_glueing=-1) + with self.assertRaisesRegex(RuntimeError, "The bond type to be used for binding particle centers needs to be a pair bond"): + self.set_coldet("glue_to_surface", bond_centers=self.bond_angle) + with self.assertRaisesRegex(RuntimeError, "The bond type to be used for binding virtual sites needs to be a pair bond"): + self.set_coldet("glue_to_surface", bond_vs=self.bond_angle) # check if original parameters have been preserved self.check_stored_parameters("glue_to_surface", distance=0.5)