DistanceConstraint.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_DISTANCECONSTRAINT_H__
00011 #define __RD_DISTANCECONSTRAINT_H__
00012 #include <iostream>
00013 #include <ForceField/Contrib.h>
00014 
00015 namespace ForceFields {
00016   namespace UFF {
00017 
00018     //! A distance range constraint modelled after a BondStretchContrib
00019     class DistanceConstraintContrib : public ForceFieldContrib {
00020     public:
00021       DistanceConstraintContrib() : d_end1Idx(-1), d_end2Idx(-1) {};
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 minLen      minimum distance
00028         \param maxLen      maximum distance
00029         \param forceConst  force Constant
00030         
00031       */
00032       DistanceConstraintContrib(ForceField *owner,unsigned int idx1,unsigned int idx2,
00033                                 double minLen,double maxLen,double forceConst);
00034 
00035       ~DistanceConstraintContrib() {
00036         //std::cerr << " ==== Destroy constraint " << d_end1Idx << " " << d_end2Idx << std::endl;
00037       }
00038       double getEnergy(double *pos) const;
00039 
00040       void getGrad(double *pos,double *grad) const;
00041     private:
00042       int d_end1Idx,d_end2Idx; //!< indices of end points
00043       double d_minLen,d_maxLen;        //!< rest length of the bond
00044       double d_forceConstant;  //!< force constant of the bond
00045 
00046     };
00047   }
00048 }
00049 #endif