Skip to content
Merged
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
15 changes: 13 additions & 2 deletions src/Energy/VDW_LongRange_Correction.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "VDW_LongRange_Correction.h"
#include "../CpptrajStdio.h"
#include "../Topology.h"
#include <limits>

using namespace Cpptraj::Energy;

Expand Down Expand Up @@ -48,9 +49,19 @@ int VDW_LongRange_Correction::Setup_VDW_Correction(Topology const& topIn,
unsigned int idx = offset + jtype;
int nbidx = NB_->NBindex()[ idx ];
if (nbidx > -1) {
atype_vdw_term += N_vdw_type_[itype] * N_vdw_type_[jtype] * NB_->NBarray()[ nbidx ].B();
// Avoid integer overflow by converting to double.
double Ni = (double)N_vdw_type_[itype];
double Nj = (double)N_vdw_type_[jtype];
double NiNj = Ni * Nj;
// Sanity check
if (std::isinf(NiNj)) {
mprinterr("Internal Error: overflow detected calculating LJ VDW LR correction (%i types=%i, %i types=%i)\n",
itype, N_vdw_type_[itype], jtype, N_vdw_type_[jtype]);
return 1;
}
atype_vdw_term += NiNj * NB_->NBarray()[ nbidx ].B();

Vdw_Recip_term_ += N_vdw_type_[itype] * N_vdw_type_[jtype] * NB_->NBarray()[ nbidx ].B();
Vdw_Recip_term_ += NiNj * NB_->NBarray()[ nbidx ].B();
}
}
atype_vdw_recip_terms_.push_back(atype_vdw_term);
Expand Down
2 changes: 1 addition & 1 deletion src/Energy/VDW_LongRange_Correction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class VDW_LongRange_Correction {
double Vdw_Recip_term_;
int debug_;
// Below variables are needed for per-atom decomp
Iarray vdw_type_; ///< VDW type for each seleccted atom (#atoms)
Iarray vdw_type_; ///< VDW type for each selected atom (#atoms)
Iarray N_vdw_type_; ///< Count of atoms that have each VDW type index (#types)
Darray atype_vdw_recip_terms_; ///< the nonbond interaction for each atom type (#types)
};
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 "V7.11.2"
#define CPPTRAJ_INTERNAL_VERSION "V7.12.0"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
Loading