mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* First try at using DistViolationContribs only the most basic of testing has been done also add ForceField::distance2 to allow some optimizations * allow testing using old approach * optimization At this point testUFFForceFieldHelpers fails since the check for std::max_element in the e_contribs vector at Embedder.cpp:513 is now doing something totally different (instead of a bunch of small distance violation contribs, we have one big one). We'll need to come up with something for this. With the benchmarking set that I'm using - 500 DG conformers for ~465 COD molecules using 10 threads - this runs in almost 10% less time than master. * backup; builds, tests do not pass * all tests pass except the old failure * more constification * backup/debugging * add fourthdim contribs the same way * tests now pass * deprecations * remove unused vars and code * changes in response to review
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
//
|
|
// Created by Santosh Putta, Nov 2006
|
|
//
|
|
#include <RDGeneral/export.h>
|
|
#ifndef __RD_FOURTHDIMCONTRIB_H__
|
|
#define __RD_FOURTHDIMCONTRIB_H__
|
|
|
|
#include <RDGeneral/Invariant.h>
|
|
#include <ForceField/Contrib.h>
|
|
#include <ForceField/ForceField.h>
|
|
|
|
namespace DistGeom {
|
|
//! DEPRECATED: use FourthDimContribs instead
|
|
//! A term used in penalizing chirality violations
|
|
//!
|
|
class RDKIT_DISTGEOMETRY_EXPORT FourthDimContrib
|
|
: public ForceFields::ForceFieldContrib {
|
|
public:
|
|
FourthDimContrib() {}
|
|
|
|
//! Constructor
|
|
/*!
|
|
\param owner pointer to the owning ForceField
|
|
\param idx the index of the atom to be considered
|
|
\param weight (optional) the weight to be used for this contrib
|
|
|
|
*/
|
|
FourthDimContrib(ForceFields::ForceField *owner, unsigned int idx,
|
|
double weight)
|
|
: d_idx(idx), d_weight(weight) {
|
|
PRECONDITION(owner, "bad force field");
|
|
PRECONDITION(owner->dimension() == 4, "force field has wrong dimension");
|
|
dp_forceField = owner;
|
|
}
|
|
|
|
//! return the contribution of this contrib to the energy of a given state
|
|
double getEnergy(double *pos) const override {
|
|
PRECONDITION(dp_forceField, "no owner");
|
|
PRECONDITION(dp_forceField->dimension() == 4,
|
|
"force field has wrong dimension");
|
|
PRECONDITION(pos, "bad vector");
|
|
unsigned int pid = d_idx * dp_forceField->dimension() + 3;
|
|
return d_weight * pos[pid] * pos[pid];
|
|
}
|
|
|
|
//! calculate the contribution of this contrib to the gradient at a given
|
|
/// state
|
|
void getGrad(double *pos, double *grad) const override {
|
|
PRECONDITION(dp_forceField, "no owner");
|
|
PRECONDITION(dp_forceField->dimension() == 4,
|
|
"force field has wrong dimension");
|
|
PRECONDITION(pos, "bad vector");
|
|
unsigned int pid = d_idx * dp_forceField->dimension() + 3;
|
|
grad[pid] += d_weight * pos[pid];
|
|
}
|
|
FourthDimContrib *copy() const override {
|
|
return new FourthDimContrib(*this);
|
|
}
|
|
|
|
private:
|
|
unsigned int d_idx{0};
|
|
double d_weight{0.0};
|
|
};
|
|
} // namespace DistGeom
|
|
|
|
#endif
|