Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94EnergyCalculator.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94EnergyCalculator.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_FORCEFIELD_MMFF94ENERGYCALCULATOR_HPP
30 #define CDPL_FORCEFIELD_MMFF94ENERGYCALCULATOR_HPP
31 
36 
37 
38 namespace CDPL
39 {
40 
41  namespace ForceField
42  {
43 
55  template <typename ValueType>
57  {
58 
59  public:
66 
72 
78  void setEnabledInteractionTypes(unsigned int types);
79 
84  unsigned int getEnabledInteractionTypes() const;
85 
90  void setup(const MMFF94InteractionData& ia_data);
91 
101  template <typename CoordsArray>
102  const ValueType& operator()(const CoordsArray& coords);
103 
108  const ValueType& getTotalEnergy() const;
109 
114  const ValueType& getBondStretchingEnergy() const;
115 
120  const ValueType& getAngleBendingEnergy() const;
121 
126  const ValueType& getStretchBendEnergy() const;
127 
132  const ValueType& getOutOfPlaneBendingEnergy() const;
133 
138  const ValueType& getTorsionEnergy() const;
139 
144  const ValueType& getElectrostaticEnergy() const;
145 
150  const ValueType& getVanDerWaalsEnergy() const;
151 
152  private:
153  const MMFF94InteractionData* interactionData;
154  ValueType totalEnergy;
155  ValueType bondStretchingEnergy;
156  ValueType angleBendingEnergy;
157  ValueType stretchBendEnergy;
158  ValueType outOfPlaneEnergy;
159  ValueType torsionEnergy;
160  ValueType electrostaticEnergy;
161  ValueType vanDerWaalsEnergy;
162  unsigned int interactionTypes;
163  };
164  } // namespace ForceField
165 } // namespace CDPL
166 
167 
168 // Implementation
169 // \cond DOC_IMPL_DETAILS
170 
171 template <typename ValueType>
173  interactionData(0), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
174  stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
175  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
176 {}
177 
178 template <typename ValueType>
180  interactionData(&ia_data), totalEnergy(), bondStretchingEnergy(),
181  angleBendingEnergy(), stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
182  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
183 {}
184 
185 template <typename ValueType>
187 {
188  interactionTypes = types;
189 }
190 
191 template <typename ValueType>
193 {
194  return interactionTypes;
195 }
196 
197 template <typename ValueType>
198 void CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::setup(const MMFF94InteractionData& ia_data)
199 {
200  interactionData = &ia_data;
201 }
202 
203 template <typename ValueType>
204 template <typename CoordsArray>
205 const ValueType& CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::operator()(const CoordsArray& coords)
206 {
207  if (!interactionData) {
208  totalEnergy = ValueType();
209  bondStretchingEnergy = ValueType();
210  angleBendingEnergy = ValueType();
211  stretchBendEnergy = ValueType();
212  outOfPlaneEnergy = ValueType();
213  torsionEnergy = ValueType();
214  electrostaticEnergy = ValueType();
215  vanDerWaalsEnergy = ValueType();
216 
217  return totalEnergy;
218  }
219 
220  totalEnergy = ValueType();
221 
222  if (interactionTypes & InteractionType::BOND_STRETCHING) {
223  bondStretchingEnergy = calcMMFF94BondStretchingEnergy<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
224  interactionData->getBondStretchingInteractions().getElementsEnd(),
225  coords);
226  totalEnergy += bondStretchingEnergy;
227 
228  } else
229  bondStretchingEnergy = ValueType();
230 
231 
232  if (interactionTypes & InteractionType::ANGLE_BENDING) {
233  angleBendingEnergy = calcMMFF94AngleBendingEnergy<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
234  interactionData->getAngleBendingInteractions().getElementsEnd(),
235  coords);
236  totalEnergy += angleBendingEnergy;
237 
238  } else
239  angleBendingEnergy = ValueType();
240 
241  if (interactionTypes & InteractionType::STRETCH_BEND) {
242  stretchBendEnergy = calcMMFF94StretchBendEnergy<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
243  interactionData->getStretchBendInteractions().getElementsEnd(),
244  coords);
245  totalEnergy += stretchBendEnergy;
246 
247  } else
248  stretchBendEnergy = ValueType();
249 
250  if (interactionTypes & InteractionType::OUT_OF_PLANE_BENDING) {
251  outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingEnergy<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
252  interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
253  coords);
254  totalEnergy += outOfPlaneEnergy;
255 
256  } else
257  outOfPlaneEnergy = ValueType();
258 
259  if (interactionTypes & InteractionType::TORSION) {
260  torsionEnergy = calcMMFF94TorsionEnergy<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
261  interactionData->getTorsionInteractions().getElementsEnd(),
262  coords);
263  totalEnergy += torsionEnergy;
264 
265  } else
266  torsionEnergy = ValueType();
267 
268  if (interactionTypes & InteractionType::ELECTROSTATIC) {
269  electrostaticEnergy = calcMMFF94ElectrostaticEnergy<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
270  interactionData->getElectrostaticInteractions().getElementsEnd(),
271  coords);
272  totalEnergy += electrostaticEnergy;
273 
274  } else
275  electrostaticEnergy = ValueType();
276 
277  if (interactionTypes & InteractionType::VAN_DER_WAALS) {
278  vanDerWaalsEnergy = calcMMFF94VanDerWaalsEnergy<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
279  interactionData->getVanDerWaalsInteractions().getElementsEnd(),
280  coords);
281  totalEnergy += vanDerWaalsEnergy;
282 
283  } else
284  vanDerWaalsEnergy = ValueType();
285 
286  return totalEnergy;
287 }
288 
289 template <typename ValueType>
291 {
292  return totalEnergy;
293 }
294 
295 template <typename ValueType>
297 {
298  return bondStretchingEnergy;
299 }
300 
301 template <typename ValueType>
303 {
304  return angleBendingEnergy;
305 }
306 
307 template <typename ValueType>
309 {
310  return stretchBendEnergy;
311 }
312 
313 template <typename ValueType>
315 {
316  return outOfPlaneEnergy;
317 }
318 
319 template <typename ValueType>
321 {
322  return torsionEnergy;
323 }
324 
325 template <typename ValueType>
327 {
328  return electrostaticEnergy;
329 }
330 
331 template <typename ValueType>
333 {
334  return vanDerWaalsEnergy;
335 }
336 
337 // \endcond
338 
339 #endif // CDPL_FORCEFIELD_MMFF94ENERGYCALCULATOR_HPP
Utility functions used in the calculation of force field energies and gradients.
Definition of constants in namespace CDPL::ForceField::InteractionType.
Functions for the calculation of MMFF94 interaction energies.
Definition of class CDPL::ForceField::MMFF94InteractionData.
Calculates the total MMFF94 force field energy for a set of atom 3D coordinates.
Definition: MMFF94EnergyCalculator.hpp:57
MMFF94EnergyCalculator(const MMFF94InteractionData &ia_data)
Constructs the calculator and associates it with the supplied ForceField::MMFF94InteractionData insta...
const ValueType & getTorsionEnergy() const
Returns the torsion 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.
unsigned int getEnabledInteractionTypes() const
Returns the currently enabled interaction-type contributions.
const ValueType & getOutOfPlaneBendingEnergy() const
Returns the out-of-plane bending energy contribution computed by the most recent operator()() call.
void setEnabledInteractionTypes(unsigned int types)
Enables/disables specific MMFF94 interaction-type contributions.
MMFF94EnergyCalculator()
Constructs the calculator without an associated ForceField::MMFF94InteractionData instance.
const ValueType & getBondStretchingEnergy() const
Returns the bond-stretching energy contribution computed by the most recent operator()() call.
const ValueType & getStretchBendEnergy() const
Returns the stretch-bend coupling energy contribution computed by the most recent operator()() call.
const ValueType & getElectrostaticEnergy() const
Returns the electrostatic 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.
void setup(const MMFF94InteractionData &ia_data)
Associates the calculator with the supplied ForceField::MMFF94InteractionData instance.
const ValueType & getTotalEnergy() const
Returns the total MMFF94 energy computed by the most recent operator()() call.
const ValueType & operator()(const CoordsArray &coords)
Computes the total MMFF94 energy of the conformation specified by coords.
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
The namespace of the Chemical Data Processing Library.