Chemical Data Processing Library C++ API - Version 1.1.1
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 
44  template <typename ValueType>
46  {
47 
48  public:
50 
52 
53  void setEnabledInteractionTypes(unsigned int types);
54 
55  unsigned int getEnabledInteractionTypes() const;
56 
57  void setup(const MMFF94InteractionData& ia_data);
58 
59  template <typename CoordsArray>
60  const ValueType& operator()(const CoordsArray& coords);
61 
62  const ValueType& getTotalEnergy() const;
63 
64  const ValueType& getBondStretchingEnergy() const;
65 
66  const ValueType& getAngleBendingEnergy() const;
67 
68  const ValueType& getStretchBendEnergy() const;
69 
70  const ValueType& getOutOfPlaneBendingEnergy() const;
71 
72  const ValueType& getTorsionEnergy() const;
73 
74  const ValueType& getElectrostaticEnergy() const;
75 
76  const ValueType& getVanDerWaalsEnergy() const;
77 
78  private:
79  const MMFF94InteractionData* interactionData;
80  ValueType totalEnergy;
81  ValueType bondStretchingEnergy;
82  ValueType angleBendingEnergy;
83  ValueType stretchBendEnergy;
84  ValueType outOfPlaneEnergy;
85  ValueType torsionEnergy;
86  ValueType electrostaticEnergy;
87  ValueType vanDerWaalsEnergy;
88  unsigned int interactionTypes;
89  };
90  } // namespace ForceField
91 } // namespace CDPL
92 
93 
94 // Implementation
95 // \cond DOC_IMPL_DETAILS
96 
97 template <typename ValueType>
99  interactionData(0), totalEnergy(), bondStretchingEnergy(), angleBendingEnergy(),
100  stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
101  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
102 {}
103 
104 template <typename ValueType>
106  interactionData(&ia_data), totalEnergy(), bondStretchingEnergy(),
107  angleBendingEnergy(), stretchBendEnergy(), outOfPlaneEnergy(), torsionEnergy(), electrostaticEnergy(),
108  vanDerWaalsEnergy(), interactionTypes(InteractionType::ALL)
109 {}
110 
111 template <typename ValueType>
113 {
114  interactionTypes = types;
115 }
116 
117 template <typename ValueType>
119 {
120  return interactionTypes;
121 }
122 
123 template <typename ValueType>
124 void CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::setup(const MMFF94InteractionData& ia_data)
125 {
126  interactionData = &ia_data;
127 }
128 
129 template <typename ValueType>
130 template <typename CoordsArray>
131 const ValueType& CDPL::ForceField::MMFF94EnergyCalculator<ValueType>::operator()(const CoordsArray& coords)
132 {
133  if (!interactionData) {
134  totalEnergy = ValueType();
135  bondStretchingEnergy = ValueType();
136  angleBendingEnergy = ValueType();
137  stretchBendEnergy = ValueType();
138  outOfPlaneEnergy = ValueType();
139  torsionEnergy = ValueType();
140  electrostaticEnergy = ValueType();
141  vanDerWaalsEnergy = ValueType();
142 
143  return totalEnergy;
144  }
145 
146  totalEnergy = ValueType();
147 
148  if (interactionTypes & InteractionType::BOND_STRETCHING) {
149  bondStretchingEnergy = calcMMFF94BondStretchingEnergy<ValueType>(interactionData->getBondStretchingInteractions().getElementsBegin(),
150  interactionData->getBondStretchingInteractions().getElementsEnd(),
151  coords);
152  totalEnergy += bondStretchingEnergy;
153 
154  } else
155  bondStretchingEnergy = ValueType();
156 
157 
158  if (interactionTypes & InteractionType::ANGLE_BENDING) {
159  angleBendingEnergy = calcMMFF94AngleBendingEnergy<ValueType>(interactionData->getAngleBendingInteractions().getElementsBegin(),
160  interactionData->getAngleBendingInteractions().getElementsEnd(),
161  coords);
162  totalEnergy += angleBendingEnergy;
163 
164  } else
165  angleBendingEnergy = ValueType();
166 
167  if (interactionTypes & InteractionType::STRETCH_BEND) {
168  stretchBendEnergy = calcMMFF94StretchBendEnergy<ValueType>(interactionData->getStretchBendInteractions().getElementsBegin(),
169  interactionData->getStretchBendInteractions().getElementsEnd(),
170  coords);
171  totalEnergy += stretchBendEnergy;
172 
173  } else
174  stretchBendEnergy = ValueType();
175 
176  if (interactionTypes & InteractionType::OUT_OF_PLANE_BENDING) {
177  outOfPlaneEnergy = calcMMFF94OutOfPlaneBendingEnergy<ValueType>(interactionData->getOutOfPlaneBendingInteractions().getElementsBegin(),
178  interactionData->getOutOfPlaneBendingInteractions().getElementsEnd(),
179  coords);
180  totalEnergy += outOfPlaneEnergy;
181 
182  } else
183  outOfPlaneEnergy = ValueType();
184 
185  if (interactionTypes & InteractionType::TORSION) {
186  torsionEnergy = calcMMFF94TorsionEnergy<ValueType>(interactionData->getTorsionInteractions().getElementsBegin(),
187  interactionData->getTorsionInteractions().getElementsEnd(),
188  coords);
189  totalEnergy += torsionEnergy;
190 
191  } else
192  torsionEnergy = ValueType();
193 
194  if (interactionTypes & InteractionType::ELECTROSTATIC) {
195  electrostaticEnergy = calcMMFF94ElectrostaticEnergy<ValueType>(interactionData->getElectrostaticInteractions().getElementsBegin(),
196  interactionData->getElectrostaticInteractions().getElementsEnd(),
197  coords);
198  totalEnergy += electrostaticEnergy;
199 
200  } else
201  electrostaticEnergy = ValueType();
202 
203  if (interactionTypes & InteractionType::VAN_DER_WAALS) {
204  vanDerWaalsEnergy = calcMMFF94VanDerWaalsEnergy<ValueType>(interactionData->getVanDerWaalsInteractions().getElementsBegin(),
205  interactionData->getVanDerWaalsInteractions().getElementsEnd(),
206  coords);
207  totalEnergy += vanDerWaalsEnergy;
208 
209  } else
210  vanDerWaalsEnergy = ValueType();
211 
212  return totalEnergy;
213 }
214 
215 template <typename ValueType>
217 {
218  return totalEnergy;
219 }
220 
221 template <typename ValueType>
223 {
224  return bondStretchingEnergy;
225 }
226 
227 template <typename ValueType>
229 {
230  return angleBendingEnergy;
231 }
232 
233 template <typename ValueType>
235 {
236  return stretchBendEnergy;
237 }
238 
239 template <typename ValueType>
241 {
242  return outOfPlaneEnergy;
243 }
244 
245 template <typename ValueType>
247 {
248  return torsionEnergy;
249 }
250 
251 template <typename ValueType>
253 {
254  return electrostaticEnergy;
255 }
256 
257 template <typename ValueType>
259 {
260  return vanDerWaalsEnergy;
261 }
262 
263 // \endcond
264 
265 #endif // CDPL_FORCEFIELD_MMFF94ENERGYCALCULATOR_HPP
CDPL::ForceField::MMFF94InteractionData
Definition: MMFF94InteractionData.hpp:51
CDPL::ForceField::MMFF94EnergyCalculator::setup
void setup(const MMFF94InteractionData &ia_data)
CDPL::ForceField::MMFF94EnergyCalculator::getVanDerWaalsEnergy
const ValueType & getVanDerWaalsEnergy() const
CDPL::ForceField::InteractionType::TORSION
const unsigned int TORSION
Definition: InteractionType.hpp:50
MMFF94EnergyFunctions.hpp
Functions for the calculation of MMFF94 interaction energies.
CDPL::Chem::ReactionRole::ALL
const unsigned int ALL
Specifies reactants, agents and products of a reaction.
Definition: ReactionRole.hpp:74
CDPL::ForceField::MMFF94EnergyCalculator::getElectrostaticEnergy
const ValueType & getElectrostaticEnergy() const
UtilityFunctions.hpp
Utility functions used in the calculation of force field energies and gradients.
CDPL::ForceField::MMFF94EnergyCalculator::operator()
const ValueType & operator()(const CoordsArray &coords)
CDPL::ForceField::MMFF94EnergyCalculator::getStretchBendEnergy
const ValueType & getStretchBendEnergy() const
CDPL::ForceField::InteractionType::BOND_STRETCHING
const unsigned int BOND_STRETCHING
Definition: InteractionType.hpp:46
CDPL::ForceField::MMFF94EnergyCalculator
Definition: MMFF94EnergyCalculator.hpp:46
CDPL::ForceField::InteractionType::ANGLE_BENDING
const unsigned int ANGLE_BENDING
Definition: InteractionType.hpp:47
CDPL::ForceField::InteractionType::VAN_DER_WAALS
const unsigned int VAN_DER_WAALS
Definition: InteractionType.hpp:51
CDPL::ForceField::InteractionType::ELECTROSTATIC
const unsigned int ELECTROSTATIC
Definition: InteractionType.hpp:52
CDPL::ForceField::MMFF94EnergyCalculator::getOutOfPlaneBendingEnergy
const ValueType & getOutOfPlaneBendingEnergy() const
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::ForceField::MMFF94EnergyCalculator::getTotalEnergy
const ValueType & getTotalEnergy() const
CDPL::ForceField::MMFF94EnergyCalculator::getBondStretchingEnergy
const ValueType & getBondStretchingEnergy() const
CDPL::ForceField::MMFF94EnergyCalculator::getTorsionEnergy
const ValueType & getTorsionEnergy() const
CDPL::ForceField::InteractionType::STRETCH_BEND
const unsigned int STRETCH_BEND
Definition: InteractionType.hpp:48
CDPL::ForceField::MMFF94EnergyCalculator::getAngleBendingEnergy
const ValueType & getAngleBendingEnergy() const
CDPL::ForceField::MMFF94EnergyCalculator::setEnabledInteractionTypes
void setEnabledInteractionTypes(unsigned int types)
InteractionType.hpp
Definition of constants in namespace CDPL::ForceField::InteractionType.
CDPL::ForceField::MMFF94EnergyCalculator::getEnabledInteractionTypes
unsigned int getEnabledInteractionTypes() const
CDPL::ForceField::MMFF94EnergyCalculator::MMFF94EnergyCalculator
MMFF94EnergyCalculator(const MMFF94InteractionData &ia_data)
CDPL::ForceField::MMFF94EnergyCalculator::MMFF94EnergyCalculator
MMFF94EnergyCalculator()
CDPL::ForceField::InteractionType::OUT_OF_PLANE_BENDING
const unsigned int OUT_OF_PLANE_BENDING
Definition: InteractionType.hpp:49
MMFF94InteractionData.hpp
Definition of the class CDPL::ForceField::MMFF94InteractionData.