From 54a30962780f9f69e4ac7b03389b0b60a0ce779c Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Wed, 31 Jan 2018 05:59:19 -0500
Subject: [PATCH] do not allow single bond/angle/dihedral definitions with
 illegal atom ID combinations

---
 src/create_bonds.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/create_bonds.cpp b/src/create_bonds.cpp
index 2e59b11aea..4752002ac9 100644
--- a/src/create_bonds.cpp
+++ b/src/create_bonds.cpp
@@ -75,6 +75,8 @@ void CreateBonds::command(int narg, char **arg)
     btype = force->inumeric(FLERR,arg[1]);
     batom1 = force->tnumeric(FLERR,arg[2]);
     batom2 = force->tnumeric(FLERR,arg[3]);
+    if (batom1 == batom2)
+      error->all(FLERR,"Illegal create_bonds command");
     iarg = 4;
   } else if (strcmp(arg[0],"single/angle") == 0) {
     style = SANGLE;
@@ -83,6 +85,8 @@ void CreateBonds::command(int narg, char **arg)
     aatom1 = force->tnumeric(FLERR,arg[2]);
     aatom2 = force->tnumeric(FLERR,arg[3]);
     aatom3 = force->tnumeric(FLERR,arg[4]);
+    if ((aatom1 == aatom2) || (aatom1 == aatom3) || (aatom2 == aatom3))
+      error->all(FLERR,"Illegal create_bonds command");
     iarg = 5;
   } else if (strcmp(arg[0],"single/dihedral") == 0) {
     style = SDIHEDRAL;
@@ -92,6 +96,9 @@ void CreateBonds::command(int narg, char **arg)
     datom2 = force->tnumeric(FLERR,arg[3]);
     datom3 = force->tnumeric(FLERR,arg[4]);
     datom4 = force->tnumeric(FLERR,arg[5]);
+    if ((datom1 == datom2) || (datom1 == datom3) || (datom1 == datom4) ||
+        (datom2 == datom3) || (datom2 == datom4) || (datom3 == datom4))
+      error->all(FLERR,"Illegal create_bonds command");
     iarg = 6;
   } else error->all(FLERR,"Illegal create_bonds command");
 
-- 
GitLab