RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
DistViolationContribs.h
Go to the documentation of this file.
1//
2// Copyright (C) 2024 Greg Landrum and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef RD_DISTVIOLATIONCONTRIBS_H
12#define RD_DISTVIOLATIONCONTRIBS_H
13
14#include <vector>
15#include <ForceField/Contrib.h>
16
17namespace DistGeom {
18
20 unsigned int idx1{0}; //!< index of end1 in the ForceField's positions
21 unsigned int idx2{0}; //!< index of end2 in the ForceField's positions
22 double ub{1000.0}; //!< upper bound on the distance
23 double lb{0.0}; //!< lower bound on the distance
24 double weight{1.0}; //!< used to adjust relative contribution weights
25 DistViolationContribsParams(unsigned int i1, unsigned int i2, double u,
26 double l, double w = 1.0)
27 : idx1(i1), idx2(i2), ub(u), lb(l), weight(w) {};
28};
29//! A term to capture all violations of the upper and lower bounds by
30//! distance between two points
33 public:
35
36 //! Constructor
37 /*!
38 \param owner pointer to the owning ForceField
39 */
41
42 double getEnergy(double *pos) const override;
43
44 void getGrad(double *pos, double *grad) const override;
45 DistViolationContribs *copy() const override {
46 return new DistViolationContribs(*this);
47 }
48
49 void addContrib(unsigned int idx1, unsigned int idx2, double ub, double lb,
50 double weight = 1.0) {
51 d_contribs.emplace_back(idx1, idx2, ub, lb, weight);
52 }
53 bool empty() const { return d_contribs.empty(); }
54 unsigned int size() const { return d_contribs.size(); }
55
56 private:
57 std::vector<DistViolationContribsParams> d_contribs;
58};
59} // namespace DistGeom
60
61#endif
void addContrib(unsigned int idx1, unsigned int idx2, double ub, double lb, double weight=1.0)
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
DistViolationContribs * copy() const override
return a copy
DistViolationContribs(ForceFields::ForceField *owner)
Constructor.
abstract base class for contributions to ForceFields
Definition Contrib.h:18
A class to store forcefields and handle minimization.
Definition ForceField.h:79
#define RDKIT_DISTGEOMETRY_EXPORT
Definition export.h:129
double weight
used to adjust relative contribution weights
double lb
lower bound on the distance
double ub
upper bound on the distance
unsigned int idx1
index of end1 in the ForceField's positions
unsigned int idx2
index of end2 in the ForceField's positions
DistViolationContribsParams(unsigned int i1, unsigned int i2, double u, double l, double w=1.0)