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