11 #ifndef RD_FFCONVENIENCE_H 12 #define RD_FFCONVENIENCE_H 18 namespace ForceFieldsHelper {
20 #ifdef RDK_THREADSAFE_SSS 22 std::vector<std::pair<int, double>> *res,
23 unsigned int threadIdx,
24 unsigned int numThreads,
int maxIters) {
32 if (i % numThreads != threadIdx)
continue;
33 for (
unsigned int aidx = 0; aidx < mol->
getNumAtoms(); ++aidx) {
34 ff.
positions()[aidx] = &(*cit)->getAtomPos(aidx);
37 int needsMore = ff.
minimize(maxIters);
39 (*res)[i] = std::make_pair(needsMore, e);
44 std::vector<std::pair<int, double>> &res,
45 int numThreads,
int maxIters) {
46 std::vector<std::thread> tg;
47 for (
int ti = 0; ti < numThreads; ++ti) {
48 tg.emplace_back(std::thread(detail::OptimizeMoleculeConfsHelper_,
49 ff, &mol, &res, ti, numThreads, maxIters));
51 for (
auto &thread : tg) {
52 if (thread.joinable()) thread.join();
58 std::vector<std::pair<int, double>> &res,
64 for (
unsigned int aidx = 0; aidx < mol.
getNumAtoms(); ++aidx) {
65 ff.
positions()[aidx] = &(*cit)->getAtomPos(aidx);
68 int needsMore = ff.
minimize(maxIters);
70 res[i] = std::make_pair(needsMore, e);
90 return std::make_pair(res, e);
107 std::vector<std::pair<int, double>> &res,
108 int numThreads = 1,
int maxIters = 1000) {
111 if (numThreads == 1) {
114 #ifdef RDK_THREADSAFE_SSS 116 detail::OptimizeMoleculeConfsMT(mol, ff, res, numThreads, maxIters);
void OptimizeMoleculeConfs(ROMol &mol, ForceFields::ForceField &ff, std::vector< std::pair< int, double >> &res, int numThreads=1, int maxIters=1000)
Convenience function for optimizing all of a molecule's conformations using.
int minimize(unsigned int snapshotFreq, RDKit::SnapshotVect *snapshotVect, unsigned int maxIts=200, double forceTol=1e-4, double energyTol=1e-6)
minimizes the energy of the system by following gradients
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
RDGeom::PointPtrVect & positions()
returns a reference to our points (a PointPtrVect)
double calcEnergy(std::vector< double > *contribs=NULL) const
calculates and returns the energy (in kcal/mol) based on existing
unsigned int getNumConformers() const
void initialize()
does initialization
unsigned int getNumThreadsToUse(int target)
void OptimizeMoleculeConfsST(ROMol &mol, ForceFields::ForceField &ff, std::vector< std::pair< int, double >> &res, int maxIters)
std::pair< int, double > OptimizeMolecule(ForceFields::ForceField &ff, int maxIters=1000)
Convenience function for optimizing a molecule using a pre-generated force-field. ...
#define PRECONDITION(expr, mess)
ConformerIterator endConformers()
ConformerIterator beginConformers()
A class to store forcefields and handle minimization.