1 //
2 //  Copyright (C) 2013 Paolo Tosco
3 //
4 //  Copyright (C) 2004-2006 Rational Discovery LLC
5 //
6 //   @@ All Rights Reserved @@
7 //  This file is part of the RDKit.
8 //  The contents are covered by the terms of the BSD license
9 //  which is included in the file license.txt, found at the root
10 //  of the RDKit source tree.
11 //
12 #include <RDGeneral/export.h>
13 #ifndef __RD_MMFFSTRETCHBEND_H__
14 #define __RD_MMFFSTRETCHBEND_H__
15 
16 #include <utility>
17 #include <ForceField/Contrib.h>
18 
19 namespace ForceFields {
20 namespace MMFF {
21 class MMFFBond;
22 class MMFFAngle;
23 class MMFFStbn;
24 class MMFFProp;
25 
26 //! The angle-bend term for MMFF
27 class RDKIT_FORCEFIELD_EXPORT StretchBendContrib : public ForceFieldContrib {
28  public:
StretchBendContrib()29   StretchBendContrib()  {};
30   //! Constructor
31   /*!
32     The angle is between atom1 - atom2 - atom3
33 
34     \param owner       pointer to the owning ForceField
35     \param idx1        index of atom1 in the ForceField's positions
36     \param idx2        index of atom2 in the ForceField's positions
37     \param idx3        index of atom3 in the ForceField's positions
38     \param angleType   MMFF type of the angle (as an unsigned int)
39 
40   */
41   StretchBendContrib(ForceField *owner, const unsigned int idx1,
42                      const unsigned int idx2, const unsigned int idx3,
43                      const MMFFStbn *mmffStbnParams,
44                      const MMFFAngle *mmffAngleParams,
45                      const MMFFBond *mmffBondParams1,
46                      const MMFFBond *mmffBondParams2);
47 
48   double getEnergy(double *pos) const;
49   void getGrad(double *pos, double *grad) const;
copy()50   virtual StretchBendContrib *copy() const {
51     return new StretchBendContrib(*this);
52   };
53 
54  private:
55   int d_at1Idx{-1}, d_at2Idx{-1}, d_at3Idx{-1};
56   double d_restLen1, d_restLen2, d_theta0;
57   std::pair<double, double> d_forceConstants;
58 };
59 namespace Utils {
60 //! returns the std::pair of stretch-bend force constants for an angle
61 RDKIT_FORCEFIELD_EXPORT std::pair<double, double> calcStbnForceConstants(
62     const MMFFStbn *mmffStbnParams);
63 //! calculates and returns the stretch-bending MMFF energy
64 RDKIT_FORCEFIELD_EXPORT std::pair<double, double> calcStretchBendEnergy(
65     const double deltaDist1, const double deltaDist2, const double deltaTheta,
66     const std::pair<double, double> forceConstants);
67 }  // namespace Utils
68 }  // namespace MMFF
69 }  // namespace ForceFields
70 #endif
71