Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/core/collision_detection/GlueToSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions testsuite/python/collision_detection_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading