RDCode: TorsionAngle.h Source File

# TorsionAngle.h

Go to the documentation of this file.

    00001 //
    00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
    00003 //
    00004 //   @@ All Rights Reserved  @@
    00005 //
    00006 #ifndef __RD_TORSIONANGLE_H__
    00007 #define __RD_TORSIONANGLE_H__
    00008
    00009 #include <ForceField/Contrib.h>
    00010
    00011 // we need this so that we get the hybridizations:
    00012 #include <GraphMol/Atom.h>
    00013 //#include <Geometry/point.h>
    00014
    00015 namespace RDGeom {
    00016   class Point3D;
    00017 }
    00018
    00019 namespace ForceFields {
    00020   namespace UFF {
    00021     class AtomicParams;
    00022
    00023     //! the torsion term for the Universal Force Field
    00024     class TorsionAngleContrib : public ForceFieldContrib {
    00025     public:
    00026       TorsionAngleContrib() : d_at1Idx(-1), d_at2Idx(-1), d_at3Idx(-1), d_at4Idx(-1), d_order(0) {};
    00027       //! Constructor
    00028       /*!
    00029         The torsion is between atom1 - atom2 - atom3 - atom4
    00030         (i.e the angle between bond atom1-atom2 and bond atom3-atom4
    00031         while looking down bond atom2-atom3)
    00032
    00033         \param owner       pointer to the owning ForceField
    00034         \param idx1        index of atom1 in the ForceField's positions
    00035         \param idx2        index of atom2 in the ForceField's positions
    00036         \param idx3        index of atom3 in the ForceField's positions
    00037         \param idx4        index of atom4 in the ForceField's positions
    00038         \param bondOrder23 order of the torsional bond between atoms 2 and 3 (as a double)
    00039         \param atNum2      atomic number of atom2
    00040         \param atNum3      atomic number of atom3
    00041         \param hyb2        hybridization of atom2
    00042         \param hyb3        hybridization of atom3
    00043         \param at2Params   pointer to the parameters for atom 2
    00044         \param at3Params   pointer to the parameters for atom 3
    00045         \param endAtomIsSP2 (optional)
    00046           This boolean is used to signal whether either atom1 or atom4 are
    00047           RDKit::Atom::SP2 hybridized.
    00048           This triggers a special case when either of these cases holds:
    00049            - atom1 is RDKit::Atom::SP2, atom2 is RDKit::Atom::SP2
    00050              and atom3 is RDKit::Atom::SP3
    00051            - atom4 is RDKit::Atom::SP2, atom3 is RDKit::Atom::SP2
    00052              and atom2 is RDKit::Atom::SP3
    00053       */
    00054       TorsionAngleContrib(ForceField *owner,
    00055                           unsigned int idx1,unsigned int idx2,
    00056                           unsigned int idx3,unsigned int idx4,
    00057                           double bondOrder23,
    00058                           int atNum2,int atNum3,
    00059                           RDKit::Atom::HybridizationType hyb2,
    00060                           RDKit::Atom::HybridizationType hyb3,
    00061                           const AtomicParams *at2Params,
    00062                           const AtomicParams *at3Params,
    00063                           bool endAtomIsSP2=false);
    00064       double getEnergy(double *pos) const;
    00065       void getGrad(double *pos,double *grad) const;
    00066       void scaleForceConstant(unsigned int count) { this->d_forceConstant /= static_cast<double>(count); };
    00067     private:
    00068       int d_at1Idx,d_at2Idx,d_at3Idx,d_at4Idx;
    00069       unsigned int d_order;
    00070       double d_forceConstant,d_cosTerm;
    00071
    00072       //! returns dE/dTheta
    00073       double getThetaDeriv(double cosTheta,double sinTheta) const;
    00074
    00075       //! calculate default values of the torsion parameters.
    00076       /*!
    00077          see the constructor for an explanation of the arguments
    00078       */
    00079       void calcTorsionParams(double bondOrder23,
    00080                              int atNum2,int atNum3,
    00081                              RDKit::Atom::HybridizationType hyb2,
    00082                              RDKit::Atom::HybridizationType hyb3,
    00083                              const AtomicParams *at2Params,
    00084                              const AtomicParams *at3Params,
    00085                              bool endAtomIsSP2);
    00086
    00087     };
    00088
    00089     namespace Utils {
    00090       //! calculates and returns the cosine of a torsion angle
    00091       double calculateCosTorsion(const RDGeom::Point3D &p1,const RDGeom::Point3D &p2,
    00092                                  const RDGeom::Point3D &p3,const RDGeom::Point3D &p4);
    00093     }
    00094   }
    00095 }
    00096 #endif