RDKit: DistViolationContribs.h Source File

| 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-2025 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
19 struct DistViolationContribsParams {
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 ub2{1000000.0}; //!< squared upper bound on the distance
25 double lb2{0.0}; //!< squared lower bound on the distance
26 double weight{1.0}; //!< used to adjust relative contribution weights
27 DistViolationContribsParams(unsigned int i1, unsigned int i2, double u,
28 double l, double w = 1.0)
29 : idx1(i1), idx2(i2), ub(u), lb(l), ub2(u * u), lb2(l * l), weight(w) {};
30};
31//! A term to capture all violations of the upper and lower bounds by
32//! distance between two points
33 class RDKIT_DISTGEOMETRY_EXPORT DistViolationContribs
34 : public ForceFields::ForceFieldContrib {
35 public:
36 DistViolationContribs() = default;
37
38 //! Constructor
39 /*!
40 \param owner pointer to the owning ForceField
41 */
42 DistViolationContribs(ForceFields::ForceField *owner);
43
44 double getEnergy(double *pos) const override;
45
46 void getGrad(double *pos, double *grad) const override;
47 DistViolationContribs *copy() const override {
48 return new DistViolationContribs(*this);
49 }
50
51 void addContrib(unsigned int idx1, unsigned int idx2, double ub, double lb,
52 double weight = 1.0) {
53 d_contribs.emplace_back(idx1, idx2, ub, lb, weight);
54 }
55 bool empty() const { return d_contribs.empty(); }
56 unsigned int size() const { return d_contribs.size(); }
57
58 private:
59 std::vector<DistViolationContribsParams> d_contribs;
60};
61} // namespace DistGeom
62
63#endif
Contrib.h
DistGeom::DistViolationContribs::empty
bool empty() const
Definition DistViolationContribs.h:55
DistGeom::DistViolationContribs::addContrib
void addContrib(unsigned int idx1, unsigned int idx2, double ub, double lb, double weight=1.0)
Definition DistViolationContribs.h:51
DistGeom::DistViolationContribs::getGrad
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
DistGeom::DistViolationContribs::size
unsigned int size() const
Definition DistViolationContribs.h:56
DistGeom::DistViolationContribs::getEnergy
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
DistGeom::DistViolationContribs::copy
DistViolationContribs * copy() const override
return a copy
Definition DistViolationContribs.h:47
DistGeom::DistViolationContribs::DistViolationContribs
DistViolationContribs()=default
DistGeom::DistViolationContribs::DistViolationContribs
DistViolationContribs(ForceFields::ForceField *owner)
Constructor.
ForceFields::ForceFieldContrib
abstract base class for contributions to ForceFields
Definition Contrib.h:18
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition ForceField.h:79
export.h
RDKIT_DISTGEOMETRY_EXPORT
#define RDKIT_DISTGEOMETRY_EXPORT
Definition export.h:137
DistGeom
Definition BoundsMatrix.h:19
DistGeom::DistViolationContribsParams::weight
double weight
used to adjust relative contribution weights
Definition DistViolationContribs.h:26
DistGeom::DistViolationContribsParams::lb
double lb
lower bound on the distance
Definition DistViolationContribs.h:23
DistGeom::DistViolationContribsParams::ub
double ub
upper bound on the distance
Definition DistViolationContribs.h:22
DistGeom::DistViolationContribsParams::lb2
double lb2
squared lower bound on the distance
Definition DistViolationContribs.h:25
DistGeom::DistViolationContribsParams::idx1
unsigned int idx1
index of end1 in the ForceField's positions
Definition DistViolationContribs.h:20
DistGeom::DistViolationContribsParams::ub2
double ub2
squared upper bound on the distance
Definition DistViolationContribs.h:24
DistGeom::DistViolationContribsParams::idx2
unsigned int idx2
index of end2 in the ForceField's positions
Definition DistViolationContribs.h:21
DistGeom::DistViolationContribsParams::DistViolationContribsParams
DistViolationContribsParams(unsigned int i1, unsigned int i2, double u, double l, double w=1.0)
Definition DistViolationContribs.h:27