29 #ifndef CDPL_FORCEFIELD_MMFF94GRADIENTCALCULATOR_HPP
30 #define CDPL_FORCEFIELD_MMFF94GRADIENTCALCULATOR_HPP
60 template <
typename ValueType>
105 template <
typename CoordsArray>
119 template <
typename CoordsArray,
typename GradVector>
120 const ValueType&
operator()(
const CoordsArray& coords, GradVector& grad);
189 std::size_t numAtoms;
190 ValueType totalEnergy;
191 ValueType bondStretchingEnergy;
192 ValueType angleBendingEnergy;
193 ValueType stretchBendEnergy;
194 ValueType outOfPlaneEnergy;
195 ValueType torsionEnergy;
196 ValueType electrostaticEnergy;
197 ValueType vanDerWaalsEnergy;
198 unsigned int interactionTypes;
208 template <
typename ValueType>
210 interactionData(0), numAtoms(0), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
211 stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
212 vanDerWaalsEnergy(), interactionTypes(InteractionType::
ALL)
215 template <
typename ValueType>
217 interactionData(&ia_data), numAtoms(num_atoms), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
218 stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
219 vanDerWaalsEnergy(), interactionTypes(InteractionType::
ALL)
222 template <
typename ValueType>
225 interactionTypes = types;
228 template <
typename ValueType>
231 return interactionTypes;
234 template <
typename ValueType>
237 interactionData = &ia_data;
238 numAtoms = num_atoms;
241 template <
typename ValueType>
242 template <
typename CoordsArray>
245 if (!interactionData) {
246 totalEnergy = ValueType();
247 bondStretchingEnergy = ValueType();
248 angleBendingEnergy = ValueType();
249 stretchBendEnergy = ValueType();
250 outOfPlaneEnergy = ValueType();
251 torsionEnergy = ValueType();
252 electrostaticEnergy = ValueType();
253 vanDerWaalsEnergy = ValueType();
258 totalEnergy = ValueType();
261 bondStretchingEnergy = calcMMFF94BondStretchingEnergy<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
262 interactionData->getBondStretchingInteractions().getElementsEnd(),
264 totalEnergy += bondStretchingEnergy;
267 bondStretchingEnergy = ValueType();
271 angleBendingEnergy = calcMMFF94AngleBendingEnergy<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
272 interactionData->getAngleBendingInteractions().getElementsEnd(),
274 totalEnergy += angleBendingEnergy;
277 angleBendingEnergy = ValueType();
280 stretchBendEnergy = calcMMFF94StretchBendEnergy<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
281 interactionData->getStretchBendInteractions().getElementsEnd(),
283 totalEnergy += stretchBendEnergy;
286 stretchBendEnergy = ValueType();
289 outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingEnergy<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
290 interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
292 totalEnergy += outOfPlaneEnergy;
295 outOfPlaneEnergy = ValueType();
298 torsionEnergy = calcMMFF94TorsionEnergy<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
299 interactionData->getTorsionInteractions().getElementsEnd(),
301 totalEnergy += torsionEnergy;
304 torsionEnergy = ValueType();
307 electrostaticEnergy = calcMMFF94ElectrostaticEnergy<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
308 interactionData->getElectrostaticInteractions().getElementsEnd(),
310 totalEnergy += electrostaticEnergy;
313 electrostaticEnergy = ValueType();
316 vanDerWaalsEnergy = calcMMFF94VanDerWaalsEnergy<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
317 interactionData->getVanDerWaalsInteractions().getElementsEnd(),
319 totalEnergy += vanDerWaalsEnergy;
322 vanDerWaalsEnergy = ValueType();
327 template <
typename ValueType>
328 template <
typename CoordsArray,
typename GradVector>
333 if (!interactionData) {
334 totalEnergy = ValueType();
335 bondStretchingEnergy = ValueType();
336 angleBendingEnergy = ValueType();
337 stretchBendEnergy = ValueType();
338 outOfPlaneEnergy = ValueType();
339 torsionEnergy = ValueType();
340 electrostaticEnergy = ValueType();
341 vanDerWaalsEnergy = ValueType();
346 totalEnergy = ValueType();
349 bondStretchingEnergy = calcMMFF94BondStretchingGradient<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
350 interactionData->getBondStretchingInteractions().getElementsEnd(),
352 totalEnergy += bondStretchingEnergy;
355 bondStretchingEnergy = ValueType();
358 angleBendingEnergy = calcMMFF94AngleBendingGradient<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
359 interactionData->getAngleBendingInteractions().getElementsEnd(),
361 totalEnergy += angleBendingEnergy;
364 angleBendingEnergy = ValueType();
367 stretchBendEnergy = calcMMFF94StretchBendGradient<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
368 interactionData->getStretchBendInteractions().getElementsEnd(),
370 totalEnergy += stretchBendEnergy;
373 stretchBendEnergy = ValueType();
376 outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingGradient<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
377 interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
379 totalEnergy += outOfPlaneEnergy;
382 outOfPlaneEnergy = ValueType();
385 torsionEnergy = calcMMFF94TorsionGradient<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
386 interactionData->getTorsionInteractions().getElementsEnd(),
388 totalEnergy += torsionEnergy;
391 torsionEnergy = ValueType();
394 electrostaticEnergy = calcMMFF94ElectrostaticGradient<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
395 interactionData->getElectrostaticInteractions().getElementsEnd(),
397 totalEnergy += electrostaticEnergy;
400 electrostaticEnergy = ValueType();
403 vanDerWaalsEnergy = calcMMFF94VanDerWaalsGradient<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
404 interactionData->getVanDerWaalsInteractions().getElementsEnd(),
406 totalEnergy += vanDerWaalsEnergy;
409 vanDerWaalsEnergy = ValueType();
411 if (!fixedAtomMask.empty())
412 for (Util::BitSet::size_type i = fixedAtomMask.find_first(); i != Util::BitSet::npos; i = fixedAtomMask.find_next(i))
413 grad[i].clear(ValueType());
418 template <
typename ValueType>
424 template <
typename ValueType>
427 return bondStretchingEnergy;
430 template <
typename ValueType>
433 return angleBendingEnergy;
436 template <
typename ValueType>
439 return stretchBendEnergy;
442 template <
typename ValueType>
445 return outOfPlaneEnergy;
448 template <
typename ValueType>
451 return torsionEnergy;
454 template <
typename ValueType>
457 return electrostaticEnergy;
460 template <
typename ValueType>
463 return vanDerWaalsEnergy;
466 template <
typename ValueType>
469 return fixedAtomMask;
472 template <
typename ValueType>
475 fixedAtomMask = mask;
478 template <
typename ValueType>
481 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:62
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 parameter records for a molecular graph.
Definition: MMFF94InteractionData.hpp:62
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:71