DistViolationContrib.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef __RD_DISTVIOLATIONCONTRIB_H__
00011 #define __RD_DISTVIOLATIONCONTRIB_H__
00012 
00013 #include <ForceField/Contrib.h>
00014 
00015 namespace DistGeom {
00016   //! A term to capture the violation of the upper and lower bounds by 
00017   //! distance between two points
00018   class DistViolationContrib : public ForceFields::ForceFieldContrib {
00019   public:
00020     DistViolationContrib() : d_end1Idx(0), d_end2Idx(0), d_ub(1000.0), d_lb(0.0), d_weight(1.0) {};
00021 
00022     //! Constructor
00023     /*!
00024       \param owner       pointer to the owning ForceField
00025       \param idx1        index of end1 in the ForceField's positions
00026       \param idx2        index of end2 in the ForceField's positions
00027       \param ub          Upper bound on the distance
00028       \param lb          Lower bound on the distance
00029       \param weight      optional weight for this contribution
00030     */
00031     DistViolationContrib(ForceFields::ForceField *owner,unsigned int idx1,unsigned int idx2,
00032                          double ub, double lb, double weight=1.0);
00033 
00034     double getEnergy(double *pos) const;
00035     
00036     void getGrad(double *pos, double *grad) const;
00037 
00038   private:
00039     unsigned int d_end1Idx,d_end2Idx; //!< indices of end points
00040     double d_ub; //!< upper bound on the distance between d_end1Idx,d_end2Idx
00041     double d_lb; //!< lower bound on the distance between d_end1Idx,d_end2Idx
00042     double d_weight; //!< used to adjust relative contribution weights
00043   };
00044 }
00045 
00046 #endif