RDKit
Open-source cheminformatics and machine learning.
UFF/DistanceConstraint.h
Go to the documentation of this file.
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 #ifndef __RD_UFFDISTANCECONSTRAINT_H__
13 #define __RD_UFFDISTANCECONSTRAINT_H__
14 #include <iostream>
15 #include <ForceField/Contrib.h>
16 
17 namespace ForceFields {
18 namespace UFF {
19 
20 //! A distance range constraint modelled after a BondStretchContrib
22  public:
23  DistanceConstraintContrib() : d_end1Idx(-1), d_end2Idx(-1){};
24  //! Constructor
25  /*!
26  \param owner pointer to the owning ForceField
27  \param idx1 index of end1 in the ForceField's positions
28  \param idx2 index of end2 in the ForceField's positions
29  \param minLen minimum distance
30  \param maxLen maximum distance
31  \param forceConst force Constant
32 
33  */
34  DistanceConstraintContrib(ForceField *owner, unsigned int idx1,
35  unsigned int idx2, double minLen, double maxLen,
36  double forceConst);
37  DistanceConstraintContrib(ForceField *owner, unsigned int idx1,
38  unsigned int idx2, bool relative, double minLen,
39  double maxLen, double forceConst);
40 
42  // std::cerr << " ==== Destroy constraint " << d_end1Idx << " " << d_end2Idx
43  // << std::endl;
44  }
45  double getEnergy(double *pos) const;
46 
47  void getGrad(double *pos, double *grad) const;
48  virtual DistanceConstraintContrib *copy() const {
49  return new DistanceConstraintContrib(*this);
50  };
51 
52  private:
53  int d_end1Idx, d_end2Idx; //!< indices of end points
54  double d_minLen, d_maxLen; //!< rest length of the bond
55  double d_forceConstant; //!< force constant of the bond
56 };
57 }
58 }
59 #endif
A distance range constraint modelled after a BondStretchContrib.
abstract base class for contributions to ForceFields
Definition: Contrib.h:17
virtual DistanceConstraintContrib * copy() const
return a copy
void getGrad(double *pos, double *grad) const
calculates our contribution to the gradients of a position
A class to store forcefields and handle minimization.
Definition: ForceField.h:57
double getEnergy(double *pos) const
returns our contribution to the energy of a position