11#ifndef RD_FFCONVENIENCE_H
12#define RD_FFCONVENIENCE_H
18namespace ForceFieldsHelper {
20#ifdef RDK_BUILD_THREADSAFE_SSS
22 std::vector<std::pair<int, double>> *
res,
24 unsigned int numThreads,
int maxIters) {
28 "res->size() must be >= mol->getNumConformers()");
37 ff.positions()[
aidx] = &(*cit)->getAtomPos(
aidx);
41 double e =
ff.calcEnergy();
47 std::vector<std::pair<int, double>> &
res,
49 std::vector<std::thread>
tg;
50 for (
int ti = 0;
ti < numThreads; ++
ti) {
51 tg.emplace_back(std::thread(detail::OptimizeMoleculeConfsHelper_,
ff, &mol,
54 for (
auto &thread :
tg) {
55 if (thread.joinable()) {
63 std::vector<std::pair<int, double>> &
res,
66 "res.size() must be >= mol.getNumConformers()");
71 ff.positions()[
aidx] = &(*cit)->getAtomPos(
aidx);
75 double e =
ff.calcEnergy();
97 double e =
ff.calcEnergy();
98 return std::make_pair(
res,
e);
115 std::vector<std::pair<int, double>> &
res,
116 int numThreads = 1,
int maxIters = 1000) {
119 if (numThreads == 1) {
122#ifdef RDK_BUILD_THREADSAFE_SSS
124 detail::OptimizeMoleculeConfsMT(mol,
ff,
res, numThreads,
maxIters);
#define PRECONDITION(expr, mess)
A class to store forcefields and handle minimization.
unsigned int getNumConformers() const
unsigned int getNumAtoms() const
returns our number of atoms
ConformerIterator beginConformers()
ConformerIterator endConformers()
void OptimizeMoleculeConfsST(ROMol &mol, ForceFields::ForceField &ff, std::vector< std::pair< int, double > > &res, int maxIters)
void OptimizeMoleculeConfs(ROMol &mol, ForceFields::ForceField &ff, std::vector< std::pair< int, double > > &res, int numThreads=1, int maxIters=1000)
std::pair< int, double > OptimizeMolecule(ForceFields::ForceField &ff, int maxIters=1000)
bool rdvalue_is(const RDValue_cast_t)
unsigned int getNumThreadsToUse(int target)