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 
56  template <typename ValueType>
58  {
59 
60  public:
67 
73 
79  void setEnabledInteractionTypes(unsigned int types);
80 
85  unsigned int getEnabledInteractionTypes() const;
86 
91  void setup(const MMFF94InteractionData& ia_data);
92 
102  template <typename CoordsArray>
103  const ValueType& operator()(const CoordsArray& coords);
104 
109  const ValueType& getTotalEnergy() const;
110 
115  const ValueType& getBondStretchingEnergy() const;
116 
121  const ValueType& getAngleBendingEnergy() const;
122 
127  const ValueType& getStretchBendEnergy() const;
128 
133  const ValueType& getOutOfPlaneBendingEnergy() const;
134 
139  const ValueType& getTorsionEnergy() const;
140 
145  const ValueType& getElectrostaticEnergy() const;
146 
151  const ValueType& getVanDerWaalsEnergy() const;
152 
153  private:
154  const MMFF94InteractionData* interactionData;
155  ValueType totalEnergy;
156  ValueType bondStretchingEnergy;
157  ValueType angleBendingEnergy;
158  ValueType stretchBendEnergy;
159  ValueType outOfPlaneEnergy;
160  ValueType torsionEnergy;
161  ValueType electrostaticEnergy;
162  ValueType vanDerWaalsEnergy;
163  unsigned int interactionTypes;
164  };
165  } // namespace ForceField
166 } // namespace CDPL
167 
168 
169 // Implementation
170 // \cond DOC_IMPL_DETAILS
171 
172 template <typename ValueType>
174  interactionData(0), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
175  stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
176  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
177 {}
178 
179 template <typename ValueType>
181  interactionData(&ia_data), totalEnergy(), bondStretchingEnergy(),
182  angleBendingEnergy(), stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
183  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
184 {}
185 
186 template <typename ValueType>
188 {
189  interactionTypes = types;
190 }
191 
192 template <typename ValueType>
194 {
195  return interactionTypes;
196 }
197 
198 template <typename ValueType>
199 void CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::setup(const MMFF94InteractionData& ia_data)
200 {
201  interactionData = &ia_data;
202 }
203 
204 template <typename ValueType>
205 template <typename CoordsArray>
206 const ValueType& CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::operator()(const CoordsArray& coords)
207 {
208  if (!interactionData) {
209  totalEnergy = ValueType();
210  bondStretchingEnergy = ValueType();
211  angleBendingEnergy = ValueType();
212  stretchBendEnergy = ValueType();
213  outOfPlaneEnergy = ValueType();
214  torsionEnergy = ValueType();
215  electrostaticEnergy = ValueType();
216  vanDerWaalsEnergy = ValueType();
217 
218  return totalEnergy;
219  }
220 
221  totalEnergy = ValueType();
222 
223  if (interactionTypes & InteractionType::BOND_STRETCHING) {
224  bondStretchingEnergy = calcMMFF94BondStretchingEnergy<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
225  interactionData->getBondStretchingInteractions().getElementsEnd(),
226  coords);
227  totalEnergy += bondStretchingEnergy;
228 
229  } else
230  bondStretchingEnergy = ValueType();
231 
232 
233  if (interactionTypes & InteractionType::ANGLE_BENDING) {
234  angleBendingEnergy = calcMMFF94AngleBendingEnergy<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
235  interactionData->getAngleBendingInteractions().getElementsEnd(),
236  coords);
237  totalEnergy += angleBendingEnergy;
238 
239  } else
240  angleBendingEnergy = ValueType();
241 
242  if (interactionTypes & InteractionType::STRETCH_BEND) {
243  stretchBendEnergy = calcMMFF94StretchBendEnergy<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
244  interactionData->getStretchBendInteractions().getElementsEnd(),
245  coords);
246  totalEnergy += stretchBendEnergy;
247 
248  } else
249  stretchBendEnergy = ValueType();
250 
251  if (interactionTypes & InteractionType::OUT_OF_PLANE_BENDING) {
252  outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingEnergy<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
253  interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
254  coords);
255  totalEnergy += outOfPlaneEnergy;
256 
257  } else
258  outOfPlaneEnergy = ValueType();
259 
260  if (interactionTypes & InteractionType::TORSION) {
261  torsionEnergy = calcMMFF94TorsionEnergy<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
262  interactionData->getTorsionInteractions().getElementsEnd(),
263  coords);
264  totalEnergy += torsionEnergy;
265 
266  } else
267  torsionEnergy = ValueType();
268 
269  if (interactionTypes & InteractionType::ELECTROSTATIC) {
270  electrostaticEnergy = calcMMFF94ElectrostaticEnergy<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
271  interactionData->getElectrostaticInteractions().getElementsEnd(),
272  coords);
273  totalEnergy += electrostaticEnergy;
274 
275  } else
276  electrostaticEnergy = ValueType();
277 
278  if (interactionTypes & InteractionType::VAN_DER_WAALS) {
279  vanDerWaalsEnergy = calcMMFF94VanDerWaalsEnergy<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
280  interactionData->getVanDerWaalsInteractions().getElementsEnd(),
281  coords);
282  totalEnergy += vanDerWaalsEnergy;
283 
284  } else
285  vanDerWaalsEnergy = ValueType();
286 
287  return totalEnergy;
288 }
289 
290 template <typename ValueType>
292 {
293  return totalEnergy;
294 }
295 
296 template <typename ValueType>
298 {
299  return bondStretchingEnergy;
300 }
301 
302 template <typename ValueType>
304 {
305  return angleBendingEnergy;
306 }
307 
308 template <typename ValueType>
310 {
311  return stretchBendEnergy;
312 }
313 
314 template <typename ValueType>
316 {
317  return outOfPlaneEnergy;
318 }
319 
320 template <typename ValueType>
322 {
323  return torsionEnergy;
324 }
325 
326 template <typename ValueType>
328 {
329  return electrostaticEnergy;
330 }
331 
332 template <typename ValueType>
334 {
335  return vanDerWaalsEnergy;
336 }
337 
338 // \endcond
339 
340 #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:58
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 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
The namespace of the Chemical Data Processing Library.