RDKit
Open-source cheminformatics and machine learning.
UFF/TorsionAngle.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef __RD_TORSIONANGLE_H__
11 #define __RD_TORSIONANGLE_H__
12 
13 #include <ForceField/Contrib.h>
14 #include <Geometry/point.h>
15 
16 // we need this so that we get the hybridizations:
17 #include <GraphMol/Atom.h>
18 
19 namespace RDGeom {
20 class Point3D;
21 }
22 
23 namespace ForceFields {
24 namespace UFF {
25 class AtomicParams;
26 
27 //! the torsion term for the Universal Force Field
29  public:
31  : d_at1Idx(-1), d_at2Idx(-1), d_at3Idx(-1), d_at4Idx(-1), d_order(0){};
32  //! Constructor
33  /*!
34  The torsion is between atom1 - atom2 - atom3 - atom4
35  (i.e the angle between bond atom1-atom2 and bond atom3-atom4
36  while looking down bond atom2-atom3)
37 
38  \param owner pointer to the owning ForceField
39  \param idx1 index of atom1 in the ForceField's positions
40  \param idx2 index of atom2 in the ForceField's positions
41  \param idx3 index of atom3 in the ForceField's positions
42  \param idx4 index of atom4 in the ForceField's positions
43  \param bondOrder23 order of the torsional bond between atoms 2 and 3 (as a
44  double)
45  \param atNum2 atomic number of atom2
46  \param atNum3 atomic number of atom3
47  \param hyb2 hybridization of atom2
48  \param hyb3 hybridization of atom3
49  \param at2Params pointer to the parameters for atom 2
50  \param at3Params pointer to the parameters for atom 3
51  \param endAtomIsSP2 (optional)
52  This boolean is used to signal whether either atom1 or atom4 are
53  RDKit::Atom::SP2 hybridized.
54  This triggers a special case when either of these cases holds:
55  - atom1 is RDKit::Atom::SP2, atom2 is RDKit::Atom::SP2
56  and atom3 is RDKit::Atom::SP3
57  - atom4 is RDKit::Atom::SP2, atom3 is RDKit::Atom::SP2
58  and atom2 is RDKit::Atom::SP3
59  */
60  TorsionAngleContrib(ForceField *owner, unsigned int idx1, unsigned int idx2,
61  unsigned int idx3, unsigned int idx4, double bondOrder23,
62  int atNum2, int atNum3,
65  const AtomicParams *at2Params,
66  const AtomicParams *at3Params, bool endAtomIsSP2 = false);
67  double getEnergy(double *pos) const;
68  void getGrad(double *pos, double *grad) const;
69  void scaleForceConstant(unsigned int count) {
70  this->d_forceConstant /= static_cast<double>(count);
71  };
72  virtual TorsionAngleContrib *copy() const {
73  return new TorsionAngleContrib(*this);
74  };
75 
76  private:
77  int d_at1Idx, d_at2Idx, d_at3Idx, d_at4Idx;
78  unsigned int d_order;
79  double d_forceConstant, d_cosTerm;
80 
81  //! returns dE/dTheta
82  double getThetaDeriv(double cosTheta, double sinTheta) const;
83 
84  //! calculate default values of the torsion parameters.
85  /*!
86  see the constructor for an explanation of the arguments
87  */
88  void calcTorsionParams(double bondOrder23, int atNum2, int atNum3,
91  const AtomicParams *at2Params,
92  const AtomicParams *at3Params, bool endAtomIsSP2);
93 };
94 
95 namespace Utils {
96 //! calculates and returns the cosine of a torsion angle
97 double calculateCosTorsion(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2,
98  const RDGeom::Point3D &p3,
99  const RDGeom::Point3D &p4);
100 void calcTorsionGrad(RDGeom::Point3D *r, RDGeom::Point3D *t, double *d,
101  double **g, double &sinTerm, double &cosPhi);
102 double equation17(double bondOrder23, const AtomicParams *at2Params,
103  const AtomicParams *at3Params);
104 bool isInGroup6(int num);
105 }
106 }
107 }
108 #endif
class to store atomic parameters for the Universal Force Field
Definition: UFF/Params.h:71
bool isInGroup6(int num)
double calculateCosTorsion(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2, const RDGeom::Point3D &p3, const RDGeom::Point3D &p4)
calculates and returns the cosine of a torsion angle
abstract base class for contributions to ForceFields
Definition: Contrib.h:17
double equation17(double bondOrder23, const AtomicParams *at2Params, const AtomicParams *at3Params)
void calcTorsionGrad(RDGeom::Point3D *r, RDGeom::Point3D *t, double *d, double **g, double &sinTerm, double &cosPhi)
the torsion term for the Universal Force Field
virtual TorsionAngleContrib * copy() const
return a copy
HybridizationType
store hybridization
Definition: Atom.h:80
void scaleForceConstant(unsigned int count)
Defines the Atom class and associated typedefs.
A class to store forcefields and handle minimization.
Definition: ForceField.h:57