Skip to content

Commit

Permalink
Add check for non-bonded parameters for GIST (#997)
Browse files Browse the repository at this point in the history
* Add check for NB params in gist

* Improve error message about no nonbonds. Add warning if no charge info.

* Revision bump for warning users when no nonbonds present for GIST
  • Loading branch information
drroe authored Nov 4, 2022
1 parent 3192d05 commit 81048b9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Action_GIST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@ Action::RetType Action_GIST::Setup(ActionSetup& setup) {
#endif

if (!skipE_) {
// Warn if no charge info
if (!setup.Top().HasChargeInfo())
mprintf("Warning: No charges in topology '%s'.\n", setup.Top().c_str());
// Ensure we have nonbonded parameters
if (!setup.Top().Nonbond().HasNonbond()) {
mprinterr("Error: Topology '%s' does not have nonbonded parameters\n"
"Error: required for GIST energy calc. Use a topology file with non-bonded\n"
"Error: parameters.\n", setup.Top().c_str());
return Action::ERR;
}
E_UV_.resize( numthreads_ );
E_VV_.resize( numthreads_ );
neighborPerThread_.resize( numthreads_ );
Expand Down
9 changes: 9 additions & 0 deletions src/Topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,15 @@ void Topology::AssignNonbondParams(ParmHolder<AtomType> const& newTypes, ParmHol
}
}

/** \return True if any atom has a non-zero charge. */
bool Topology::HasChargeInfo() const {
for (std::vector<Atom>::const_iterator at = atoms_.begin();
at != atoms_.end(); ++at)
if (at->Charge() > 0.0 || at->Charge() < 0.0)
return true;
return false;
}

// -----------------------------------------------------------------------------

/** Update/add to parameters in this topology with those from given set. */
Expand Down
2 changes: 2 additions & 0 deletions src/Topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class Topology {
/// \return Lennard-Jones 6-12 parameters for given pair of atoms
inline NonbondType const& GetLJparam(int, int) const;
void AssignNonbondParams(ParmHolder<AtomType> const&, ParmHolder<NonbondType> const&);
/// \return True if any charge is non-zero
bool HasChargeInfo() const;
// ----- Water Cap Info ----------------------
CapParmType const& Cap() const { return cap_; }
CapParmType& SetCap() { return cap_; }
Expand Down
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Whenever a number that precedes <revision> is incremented, all subsequent
* numbers should be reset to 0.
*/
#define CPPTRAJ_INTERNAL_VERSION "V6.15.1"
#define CPPTRAJ_INTERNAL_VERSION "V6.15.2"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif

0 comments on commit 81048b9

Please sign in to comment.