Issue warning when atom has tiny mass but is part of a COM group 57/4557/2
authorGiacomo Fiorin <giacomo.fiorin@gmail.com>
Fri, 7 Sep 2018 16:00:55 +0000 (12:00 -0400)
committerGiacomo Fiorin <giacomo.fiorin@gmail.com>
Fri, 7 Sep 2018 23:15:04 +0000 (19:15 -0400)
The current check is for masses <= 0.001, thus catching fixed-up zero
masses and unfixed lone pairs.

Making this into an error may break somebody's calculations, but the
warning should help troubleshooting future problems.

Change-Id: I219e9861c7da3925faa2fd63df52120ac18d730a

src/GlobalMasterServer.C

index ce92ab1..2db1770 100644 (file)
@@ -14,6 +14,7 @@
 #include "InfoStream.h"
 #include "Node.h"
 #include "SimParameters.h"
+#include "Molecule.h"
 //#define DEBUGM
 #define MIN_DEBUG_LEVEL 1
 #include "Debug.h"
@@ -264,8 +265,16 @@ int GlobalMasterServer::callClients() {
     numDataSenders = totalAtomsRequested;
     AtomIDList::iterator g_i = msg->newgdef.begin();
     AtomIDList::iterator g_e = msg->newgdef.end();
+    Molecule *mol = Node::Object()->molecule;
     for ( ; g_i != g_e; ++g_i ) {
-      if ( *g_i != -1 ) ++numDataSenders;
+      if ( *g_i != -1 ) {
+        if (mol->atommass(*g_i) <= 0.001) {
+          iout << iWARN << "Atom " << (*g_i+1) << " has a near-zero mass, "
+               << "but it was requested for center-of-mass calculation.\n"
+               << endi;
+        }
+        ++numDataSenders;
+      }
     }
 
     DebugM(3,"Sending configure ("<<totalAtomsRequested<<" atoms, "
@@ -423,8 +432,16 @@ int GlobalMasterServer::callClients() {
     numDataSenders = totalAtomsRequested;
     AtomIDList::iterator g_i = msg->newgdef.begin();
     AtomIDList::iterator g_e = msg->newgdef.end();
+    Molecule *mol = Node::Object()->molecule;
     for ( ; g_i != g_e; ++g_i ) {
-      if ( *g_i != -1 ) ++numDataSenders;
+      if ( *g_i != -1 ) {
+        if (mol->atommass(*g_i) <= 0.001) {
+          iout << iWARN << "Atom " << (*g_i+1) << " has a near-zero mass, "
+               << "but it was requested for center-of-mass calculation.\n"
+               << endi;
+        }
+        ++numDataSenders;
+      }
     }
   }
   msg->totalforces = forceSendActive;