29 #ifndef CDPL_FORCEFIELD_MMFF94GRADIENTCALCULATOR_HPP
30 #define CDPL_FORCEFIELD_MMFF94GRADIENTCALCULATOR_HPP
59 template <
typename ValueType>
104 template <
typename CoordsArray>
118 template <
typename CoordsArray,
typename GradVector>
119 const ValueType&
operator()(
const CoordsArray& coords, GradVector& grad);
188 std::size_t numAtoms;
189 ValueType totalEnergy;
190 ValueType bondStretchingEnergy;
191 ValueType angleBendingEnergy;
192 ValueType stretchBendEnergy;
193 ValueType outOfPlaneEnergy;
194 ValueType torsionEnergy;
195 ValueType electrostaticEnergy;
196 ValueType vanDerWaalsEnergy;
197 unsigned int interactionTypes;
207 template <
typename ValueType>
209 interactionData(0), numAtoms(0), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
210 stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
211 vanDerWaalsEnergy(), interactionTypes(InteractionType::
ALL)
214 template <
typename ValueType>
216 interactionData(&ia_data), numAtoms(num_atoms), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
217 stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
218 vanDerWaalsEnergy(), interactionTypes(InteractionType::
ALL)
221 template <
typename ValueType>
224 interactionTypes = types;
227 template <
typename ValueType>
230 return interactionTypes;
233 template <
typename ValueType>
236 interactionData = &ia_data;
237 numAtoms = num_atoms;
240 template <
typename ValueType>
241 template <
typename CoordsArray>
244 if (!interactionData) {
245 totalEnergy = ValueType();
246 bondStretchingEnergy = ValueType();
247 angleBendingEnergy = ValueType();
248 stretchBendEnergy = ValueType();
249 outOfPlaneEnergy = ValueType();
250 torsionEnergy = ValueType();
251 electrostaticEnergy = ValueType();
252 vanDerWaalsEnergy = ValueType();
257 totalEnergy = ValueType();
260 bondStretchingEnergy = calcMMFF94BondStretchingEnergy<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
261 interactionData->getBondStretchingInteractions().getElementsEnd(),
263 totalEnergy += bondStretchingEnergy;
266 bondStretchingEnergy = ValueType();
270 angleBendingEnergy = calcMMFF94AngleBendingEnergy<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
271 interactionData->getAngleBendingInteractions().getElementsEnd(),
273 totalEnergy += angleBendingEnergy;
276 angleBendingEnergy = ValueType();
279 stretchBendEnergy = calcMMFF94StretchBendEnergy<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
280 interactionData->getStretchBendInteractions().getElementsEnd(),
282 totalEnergy += stretchBendEnergy;
285 stretchBendEnergy = ValueType();
288 outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingEnergy<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
289 interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
291 totalEnergy += outOfPlaneEnergy;
294 outOfPlaneEnergy = ValueType();
297 torsionEnergy = calcMMFF94TorsionEnergy<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
298 interactionData->getTorsionInteractions().getElementsEnd(),
300 totalEnergy += torsionEnergy;
303 torsionEnergy = ValueType();
306 electrostaticEnergy = calcMMFF94ElectrostaticEnergy<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
307 interactionData->getElectrostaticInteractions().getElementsEnd(),
309 totalEnergy += electrostaticEnergy;
312 electrostaticEnergy = ValueType();
315 vanDerWaalsEnergy = calcMMFF94VanDerWaalsEnergy<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
316 interactionData->getVanDerWaalsInteractions().getElementsEnd(),
318 totalEnergy += vanDerWaalsEnergy;
321 vanDerWaalsEnergy = ValueType();
326 template <
typename ValueType>
327 template <
typename CoordsArray,
typename GradVector>
332 if (!interactionData) {
333 totalEnergy = ValueType();
334 bondStretchingEnergy = ValueType();
335 angleBendingEnergy = ValueType();
336 stretchBendEnergy = ValueType();
337 outOfPlaneEnergy = ValueType();
338 torsionEnergy = ValueType();
339 electrostaticEnergy = ValueType();
340 vanDerWaalsEnergy = ValueType();
345 totalEnergy = ValueType();
348 bondStretchingEnergy = calcMMFF94BondStretchingGradient<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
349 interactionData->getBondStretchingInteractions().getElementsEnd(),
351 totalEnergy += bondStretchingEnergy;
354 bondStretchingEnergy = ValueType();
357 angleBendingEnergy = calcMMFF94AngleBendingGradient<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
358 interactionData->getAngleBendingInteractions().getElementsEnd(),
360 totalEnergy += angleBendingEnergy;
363 angleBendingEnergy = ValueType();
366 stretchBendEnergy = calcMMFF94StretchBendGradient<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
367 interactionData->getStretchBendInteractions().getElementsEnd(),
369 totalEnergy += stretchBendEnergy;
372 stretchBendEnergy = ValueType();
375 outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingGradient<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
376 interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
378 totalEnergy += outOfPlaneEnergy;
381 outOfPlaneEnergy = ValueType();
384 torsionEnergy = calcMMFF94TorsionGradient<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
385 interactionData->getTorsionInteractions().getElementsEnd(),
387 totalEnergy += torsionEnergy;
390 torsionEnergy = ValueType();
393 electrostaticEnergy = calcMMFF94ElectrostaticGradient<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
394 interactionData->getElectrostaticInteractions().getElementsEnd(),
396 totalEnergy += electrostaticEnergy;
399 electrostaticEnergy = ValueType();
402 vanDerWaalsEnergy = calcMMFF94VanDerWaalsGradient<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
403 interactionData->getVanDerWaalsInteractions().getElementsEnd(),
405 totalEnergy += vanDerWaalsEnergy;
408 vanDerWaalsEnergy = ValueType();
410 if (!fixedAtomMask.empty())
411 for (Util::BitSet::size_type i = fixedAtomMask.find_first(); i != Util::BitSet::npos; i = fixedAtomMask.find_next(i))
412 grad[i].clear(ValueType());
417 template <
typename ValueType>
423 template <
typename ValueType>
426 return bondStretchingEnergy;
429 template <
typename ValueType>
432 return angleBendingEnergy;
435 template <
typename ValueType>
438 return stretchBendEnergy;
441 template <
typename ValueType>
444 return outOfPlaneEnergy;
447 template <
typename ValueType>
450 return torsionEnergy;
453 template <
typename ValueType>
456 return electrostaticEnergy;
459 template <
typename ValueType>
462 return vanDerWaalsEnergy;
465 template <
typename ValueType>
468 return fixedAtomMask;
471 template <
typename ValueType>
474 fixedAtomMask = mask;
477 template <
typename ValueType>
480 fixedAtomMask.clear();
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::ForceField::GradientVectorTraits.
Definition of constants in namespace CDPL::ForceField::InteractionType.
Functions for the calculation of MMFF94 interaction energies.
Functions for the calculation of MMFF94 interaction energy gradients.
Definition of class CDPL::ForceField::MMFF94InteractionData.
Calculates the total MMFF94 force field energy and its gradient for a set of atom 3D coordinates.
Definition: MMFF94GradientCalculator.hpp:61
const ValueType & operator()(const CoordsArray &coords, GradVector &grad)
Computes the total MMFF94 energy and the per-atom gradient of the conformation specified by coords.
const ValueType & operator()(const CoordsArray &coords)
Computes the total MMFF94 energy of the conformation specified by coords without calculating the grad...
void setup(const MMFF94InteractionData &ia_data, std::size_t num_atoms)
Associates the calculator with the supplied ForceField::MMFF94InteractionData instance and atom count...
void setFixedAtomMask(const Util::BitSet &mask)
Sets the bit mask flagging atoms whose gradient components shall be zeroed after calculation.
unsigned int getEnabledInteractionTypes() const
Returns the currently enabled interaction-type contributions.
void setEnabledInteractionTypes(unsigned int types)
Enables/disables specific MMFF94 interaction-type contributions.
const ValueType & getElectrostaticEnergy() const
Returns the electrostatic energy contribution computed by the most recent operator()() call.
void resetFixedAtomMask()
Clears the fixed-atom mask so that all atoms contribute to the gradient.
MMFF94GradientCalculator(const MMFF94InteractionData &ia_data, std::size_t num_atoms)
Constructs the calculator and associates it with the supplied ForceField::MMFF94InteractionData insta...
const ValueType & getStretchBendEnergy() const
Returns the stretch-bend coupling energy contribution computed by the most recent operator()() call.
const ValueType & getVanDerWaalsEnergy() const
Returns the Van der Waals energy contribution computed by the most recent operator()() call.
const ValueType & getAngleBendingEnergy() const
Returns the angle-bending energy contribution computed by the most recent operator()() call.
MMFF94GradientCalculator()
Constructs the calculator without an associated ForceField::MMFF94InteractionData instance.
const ValueType & getOutOfPlaneBendingEnergy() const
Returns the out-of-plane bending energy contribution computed by the most recent operator()() call.
const ValueType & getTotalEnergy() const
Returns the total MMFF94 energy computed by the most recent operator()() call.
const ValueType & getTorsionEnergy() const
Returns the torsion energy contribution computed by the most recent operator()() call.
const Util::BitSet & getFixedAtomMask() const
Returns the bit mask flagging atoms whose gradient components are zeroed after evaluation.
const ValueType & getBondStretchingEnergy() const
Returns the bond-stretching energy contribution computed by the most recent operator()() call.
Container holding the full set of MMFF94 interaction parameters for a molecular graph.
Definition: MMFF94InteractionData.hpp:60
constexpr unsigned int ALL
Specifies reactants, agents and products of a reaction.
Definition: ReactionRole.hpp:74
constexpr unsigned int STRETCH_BEND
Specifies a stretch-bend coupling interaction.
Definition: InteractionType.hpp:63
constexpr unsigned int TORSION
Specifies a torsion interaction.
Definition: InteractionType.hpp:73
constexpr unsigned int VAN_DER_WAALS
Specifies a Van der Waals interaction.
Definition: InteractionType.hpp:78
constexpr unsigned int BOND_STRETCHING
Specifies a bond stretching interaction.
Definition: InteractionType.hpp:53
constexpr unsigned int ELECTROSTATIC
Specifies an electrostatic interaction.
Definition: InteractionType.hpp:83
constexpr unsigned int OUT_OF_PLANE_BENDING
Specifies an out-of-plane bending interaction.
Definition: InteractionType.hpp:68
constexpr unsigned int ANGLE_BENDING
Specifies an angle bending interaction.
Definition: InteractionType.hpp:58
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:66