RDKit: FourthDimContrib.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

FourthDimContrib.h
Go to the documentation of this file.
1 //
2 // Created by Santosh Putta, Nov 2006
3 //
4 #ifndef __RD_FOURTHDIMCONTRIB_H__
5 #define __RD_FOURTHDIMCONTRIB_H__
6
7 #include <RDGeneral/Invariant.h>
8 #include <ForceField/Contrib.h>
9 #include <ForceField/ForceField.h>
10
11 namespace DistGeom {
12 //! A term used in penalizing chirality violations
13 //!
14 class FourthDimContrib : public ForceFields::ForceFieldContrib {
15 public:
16 FourthDimContrib() : d_idx(0), d_weight(0.0){};
17
18 //! Constructor
19 /*!
20 \param owner pointer to the owning ForceField
21 \param idx the index of the atom to be considered
22 \param weight (optional) the weight to be used for this contrib
23
24 */
25 FourthDimContrib(ForceFields::ForceField *owner, unsigned int idx,
26 double weight)
27 : d_idx(idx), d_weight(weight) {
28 PRECONDITION(owner, "bad force field");
29 PRECONDITION(owner->dimension() == 4, "force field has wrong dimension");
30 dp_forceField = owner;
31 };
32
33 //! return the contribution of this contrib to the energy of a given state
34 double getEnergy(double *pos) const {
35 PRECONDITION(dp_forceField, "no owner");
36 PRECONDITION(dp_forceField->dimension() == 4,
37 "force field has wrong dimension");
38 PRECONDITION(pos, "bad vector");
39 unsigned int pid = d_idx * dp_forceField->dimension() + 3;
40 return d_weight * pos[pid] * pos[pid];
41 }
42
43 //! calculate the contribution of this contrib to the gradient at a given
44 //state
45 void getGrad(double *pos, double *grad) const {
46 PRECONDITION(dp_forceField, "no owner");
47 PRECONDITION(dp_forceField->dimension() == 4,
48 "force field has wrong dimension");
49 PRECONDITION(pos, "bad vector");
50 unsigned int pid = d_idx * dp_forceField->dimension() + 3;
51 grad[pid] += d_weight * pos[pid];
52 }
53 virtual FourthDimContrib *copy() const {
54 return new FourthDimContrib(*this);
55 };
56
57 private:
58 unsigned int d_idx;
59 double d_weight;
60 };
61 }
62
63 #endif
Invariant.h
DistGeom
Definition: BoundsMatrix.h:19
ForceField.h
ForceFields::ForceFieldContrib
abstract base class for contributions to ForceFields
Definition: Contrib.h:17
ForceFields::ForceFieldContrib::dp_forceField
ForceField * dp_forceField
our owning ForceField
Definition: Contrib.h:35
DistGeom::FourthDimContrib::FourthDimContrib
FourthDimContrib(ForceFields::ForceField *owner, unsigned int idx, double weight)
Constructor.
Definition: FourthDimContrib.h:25
DistGeom::FourthDimContrib::getGrad
void getGrad(double *pos, double *grad) const
calculate the contribution of this contrib to the gradient at a given
Definition: FourthDimContrib.h:45
Contrib.h
DistGeom::FourthDimContrib::FourthDimContrib
FourthDimContrib()
Definition: FourthDimContrib.h:16
DistGeom::FourthDimContrib::getEnergy
double getEnergy(double *pos) const
return the contribution of this contrib to the energy of a given state
Definition: FourthDimContrib.h:34
DistGeom::FourthDimContrib
Definition: FourthDimContrib.h:14
DistGeom::FourthDimContrib::copy
virtual FourthDimContrib * copy() const
return a copy
Definition: FourthDimContrib.h:53
PRECONDITION
#define PRECONDITION(expr, mess)
Definition: Invariant.h:103
ForceFields::ForceField::dimension
unsigned int dimension() const
returns the dimension of the forcefield
Definition: ForceField.h:177
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition: ForceField.h:56