11#ifndef __RD_FORCEFIELD_H__
12#define __RD_FORCEFIELD_H__
15#include <boost/smart_ptr.hpp>
20namespace ForceFieldsHelper {
24 unsigned int idx3,
unsigned int idx4,
double *
dihedral =
nullptr,
28 const double *pos,
unsigned int idx1,
unsigned int idx2,
unsigned int idx3,
29 unsigned int idx4,
double *
dihedral =
nullptr,
double *
cosPhi =
nullptr,
31 double d[2] =
nullptr);
37 double d[2] =
nullptr);
42class ForceFieldContrib;
44typedef boost::shared_ptr<const ForceFieldContrib>
ContribPtr;
82 ForceField(
unsigned int dimension = 3) : d_dimension(dimension) {}
103 double calcEnergy(std::vector<double> *contribs =
nullptr)
const;
154 unsigned int maxIts = 200,
double forceTol = 1e-4,
155 double energyTol = 1e-6);
174 int minimize(
unsigned int maxIts = 200,
double forceTol = 1e-4,
175 double energyTol = 1e-6);
202 double distance(
unsigned int i,
unsigned int j,
double *pos =
nullptr);
217 double distance(
unsigned int i,
unsigned int j,
double *pos =
nullptr)
const;
232 double distance2(
unsigned int i,
unsigned int j,
double *pos =
nullptr)
const;
246 unsigned int d_numPoints{0};
247 double *dp_distMat{
nullptr};
251 unsigned int d_matSize = 0;
A class to store forcefields and handle minimization.
ForceField(const ForceField &other)
copy ctor, copies contribs.
const INT_VECT & fixedPoints() const
void initDistanceMatrix()
initializes our internal distance matrix
unsigned int dimension() const
returns the dimension of the forcefield
void scatter(double *pos) const
scatter our positions into an array
double distance2(unsigned int i, unsigned int j, double *pos=nullptr) const
returns the squared distance between two points
double calcEnergy(double *pos)
calculates and returns the energy of the position passed in
double calcEnergy(std::vector< double > *contribs=nullptr) const
void calcGrad(double *forces) const
calculates the gradient of the energy at the current position
ForceField(unsigned int dimension=3)
construct with a dimension
void calcGrad(double *pos, double *forces)
calculates the gradient of the energy at the provided position
const ContribPtrVect & contribs() const
ContribPtrVect d_contribs
contributions to the energy
double distance(unsigned int i, unsigned int j, double *pos=nullptr)
returns the distance between two points
int minimize(unsigned int maxIts=200, double forceTol=1e-4, double energyTol=1e-6)
minimizes the energy of the system by following gradients
RDGeom::PointPtrVect & positions()
returns a reference to our points (a PointPtrVect)
void initialize()
does initialization
unsigned int numPoints() const
returns the number of points the ForceField is handling
RDGeom::PointPtrVect d_positions
pointers to the points we're using
void gather(double *pos)
update our positions from an array
double distance(unsigned int i, unsigned int j, double *pos=nullptr) const
returns the distance between two points
ContribPtrVect & contribs()
returns a reference to our contribs (a ContribPtrVect)
const RDGeom::PointPtrVect & positions() const
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
#define RDKIT_FORCEFIELD_EXPORT
std::vector< int > INT_VECT
boost::shared_ptr< const ForceFieldContrib > ContribPtr
std::vector< ContribPtr > ContribPtrVect
std::vector< RDGeom::Point * > PointPtrVect
void RDKIT_FORCEFIELD_EXPORT normalizeAngleDeg(double &angleDeg)
void RDKIT_FORCEFIELD_EXPORT computeDihedral(const RDGeom::PointPtrVect &pos, unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, double *dihedral=nullptr, double *cosPhi=nullptr, RDGeom::Point3D r[4]=nullptr, RDGeom::Point3D t[2]=nullptr, double d[2]=nullptr)
bool rdvalue_is(const RDValue_cast_t)
std::vector< Snapshot > SnapshotVect