1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
//
// 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
|