/** Set up the exclusion list based on the given mask and parm. * \return the total number of interactions, -1 on error. */ int Action_Pairwise::SetupNonbondParm(AtomMask const& maskIn, Topology const& ParmIn) { // Check if LJ parameters present - need at least 2 atoms for it to matter. if (ParmIn.Natom() > 1 && !ParmIn.Nonbond().HasNonbond()) { mprinterr("Error: Topology does not have LJ information.\n"); return -1; } // Determine the actual number of pairwise interactions that will be calcd. // This is ((N^2 - N) / 2) - SUM[ #excluded atoms] int N_interactions = ((maskIn.Nselected() * maskIn.Nselected()) - maskIn.Nselected()) / 2; for (AtomMask::const_iterator at = maskIn.begin(); at != maskIn.end(); ++at) N_interactions -= ParmIn[ *at ].Nexcluded(); // DEBUG - Print total number of interactions for this parm mprintf("\t%i interactions for this parm.\n",N_interactions); // DEBUG - Print exclusion list for each atom /*for (unsigned int atom = 0; atom < exclusionList.size(); atom++) { mprintf("\t%8u:",atom + 1); for (std::vector<int>::iterator eat = exclusionList[atom].begin(); eat != exclusionList[atom].end(); eat++) { mprintf(" %i",*eat + 1); } mprintf("\n"); }*/ return N_interactions; }
/** Determine VDW long range correction prefactor. */ void Ewald::Setup_VDW_Correction(Topology const& topIn, AtomMask const& maskIn) { Vdw_Recip_term_ = 0.0; NB_ = static_cast<NonbondParmType const*>( &(topIn.Nonbond()) ); if (!NB_->HasNonbond()) { mprintf("Warning: '%s' has no nonbonded parameters. Cannot calculate VDW correction.\n", topIn.c_str()); return; } // Count the number of each unique nonbonded type. Iarray N_vdw_type( NB_->Ntypes(), 0 ); for (AtomMask::const_iterator atm = maskIn.begin(); atm != maskIn.end(); ++atm) N_vdw_type[ topIn[*atm].TypeIndex() ]++; if (debug_ > 0) { mprintf("DEBUG: %zu VDW types.\n", N_vdw_type.size()); for (Iarray::const_iterator it = N_vdw_type.begin(); it != N_vdw_type.end(); ++it) mprintf("\tType %li = %i\n", it-N_vdw_type.begin(), *it); } // Determine correction term from types and LJ B parameters for (unsigned int itype = 0; itype != N_vdw_type.size(); itype++) { unsigned int offset = N_vdw_type.size() * itype; for (unsigned int jtype = 0; jtype != N_vdw_type.size(); jtype++) { unsigned int idx = offset + jtype; int nbidx = NB_->NBindex()[ idx ]; if (nbidx > -1) Vdw_Recip_term_ += N_vdw_type[itype] * N_vdw_type[jtype] * NB_->NBarray()[ nbidx ].B(); } } }
/** Sets the temporary charge array and makes sure that we have the necessary * parameters in our topology to calculate nonbonded energy terms */ int Action_LIE::SetupParms(Topology const& ParmIn) { if (!ParmIn.Nonbond().HasNonbond()) { mprinterr("Error: Topology does not have LJ information.\n"); return 1; } // Store the charges atom_charge_.clear(); atom_charge_.reserve( ParmIn.Natom() ); for (Topology::atom_iterator atom = ParmIn.begin(); atom != ParmIn.end(); ++atom) atom_charge_.push_back( atom->Charge() * Constants::ELECTOAMBER / sqrt(dielc_) ); return 0; }