Loading...
Searching...
No Matches
DistViolationContribs.h
Go to the documentation of this file.
//
// Copyright (C) 2024-2025 Greg Landrum and other RDKit contributors
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef RD_DISTVIOLATIONCONTRIBS_H
#define RD_DISTVIOLATIONCONTRIBS_H
#include <vector>
#include <ForceField/Contrib.h>
namespace DistGeom {
struct DistViolationContribsParams {
unsigned int idx1{0}; //!< index of end1 in the ForceField's positions
unsigned int idx2{0}; //!< index of end2 in the ForceField's positions
double ub{1000.0}; //!< upper bound on the distance
double lb{0.0}; //!< lower bound on the distance
double ub2{1000000.0}; //!< squared upper bound on the distance
double lb2{0.0}; //!< squared lower bound on the distance
double weight{1.0}; //!< used to adjust relative contribution weights
DistViolationContribsParams(unsigned int i1, unsigned int i2, double u,
double l, double w = 1.0)
: idx1(i1), idx2(i2), ub(u), lb(l), ub2(u * u), lb2(l * l), weight(w) {};
};
//! A term to capture all violations of the upper and lower bounds by
//! distance between two points
class RDKIT_DISTGEOMETRY_EXPORT DistViolationContribs
: public ForceFields::ForceFieldContrib {
public:
DistViolationContribs() = default;
//! Constructor
/*!
\param owner pointer to the owning ForceField
*/
DistViolationContribs(ForceFields::ForceField *owner);
double getEnergy(double *pos) const override;
void getGrad(double *pos, double *grad) const override;
DistViolationContribs *copy() const override {
return new DistViolationContribs(*this);
}
void addContrib(unsigned int idx1, unsigned int idx2, double ub, double lb,
double weight = 1.0) {
d_contribs.emplace_back(idx1, idx2, ub, lb, weight);
}
bool empty() const { return d_contribs.empty(); }
unsigned int size() const { return d_contribs.size(); }
private:
std::vector<DistViolationContribsParams> d_contribs;
};
} // namespace DistGeom
#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