11#ifndef RD_FFCONVENIENCE_H
12#define RD_FFCONVENIENCE_H
18namespace ForceFieldsHelper {
20#ifdef RDK_BUILD_THREADSAFE_SSS
23 std::vector<std::pair<int, double>> *
res,
unsigned int threadIdx,
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();
48 std::vector<std::pair<int, double>> &
res,
50 std::vector<std::thread>
tg;
51 for (
int ti = 0;
ti < numThreads; ++
ti) {
52 tg.emplace_back(std::thread(detail::OptimizeMoleculeConfsHelper_,
ff, &mol,
55 for (
auto &thread :
tg) {
56 if (thread.joinable()) {
64 std::vector<std::pair<int, double>> &
res,
67 "res.size() must be >= mol.getNumConformers()");
72 ff.positions()[
aidx] = &(*cit)->getAtomPos(
aidx);
76 double e =
ff.calcEnergy();
98 double e =
ff.calcEnergy();
99 return std::make_pair(
res,
e);
116 std::vector<std::pair<int, double>> &
res,
117 int numThreads = 1,
int maxIters = 1000) {
120 if (numThreads == 1) {
123#ifdef RDK_BUILD_THREADSAFE_SSS
125 detail::OptimizeMoleculeConfsMT(mol,
ff,
res, numThreads,
maxIters);
138 ROMol &mol,
int confId = -1) {
139 auto res = std::make_unique<ForceFields::ForceField>();
141 for (
auto &
pt :
conf.getPositions()) {
142 res->positions().push_back(&
pt);
#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
const Conformer & getConformer(int id=-1) const
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::unique_ptr< ForceFields::ForceField > createEmptyForceFieldForMol(ROMol &mol, int confId=-1)
std::pair< int, double > OptimizeMolecule(ForceFields::ForceField &ff, int maxIters=1000)
bool rdvalue_is(const RDValue_cast_t)
unsigned int getNumThreadsToUse(int target)