RDKit: ForceFields::ForceField Class Reference

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ForceFields::ForceField Class Reference

A class to store forcefields and handle minimization. More...

`#include <ForceField.h>`

## Public Member Functions
| ForceField (unsigned int dimension=3)
| construct with a dimension More...
| ~ForceField ()
| ForceField (const ForceField &other)
| copy ctor, copies contribs. More...
void | initialize ()
| does initialization More...
double | calcEnergy () const
| calculates and returns the energy (in kcal/mol) based on existing More...
double | calcEnergy (double *pos)
| calculates and returns the energy of the position passed in More...
void | calcGrad (double *forces) const
| calculates the gradient of the energy at the current position More...
void | calcGrad (double *pos, double *forces)
| calculates the gradient of the energy at the provided position More...
int | minimize (unsigned int maxIts=200, double forceTol=1e-4, double energyTol=1e-6)
| minimizes the energy of the system by following gradients More...
RDGeom::PointPtrVect & | positions ()
| returns a reference to our points (a PointPtrVect) More...
const RDGeom::PointPtrVect & | positions () const
ContribPtrVect & | contribs ()
| returns a reference to our contribs (a ContribPtrVect) More...
const ContribPtrVect & | contribs () const
double | distance (unsigned int i, unsigned int j, double *pos=0)
| returns the distance between two points More...
double | distance (unsigned int i, unsigned int j, double *pos=0) const
| returns the distance between two points More...
unsigned int | dimension () const
| returns the dimension of the forcefield More...
unsigned int | numPoints () const
| returns the number of points the ForceField is handling More...
INT_VECT & | fixedPoints ()
const INT_VECT & | fixedPoints () const

## Protected Member Functions
void | scatter (double *pos) const
| scatter our positions into an array More...
void | gather (double *pos)
| update our positions from an array More...
void | initDistanceMatrix ()
| initializes our internal distance matrix More...

## Protected Attributes
unsigned int | d_dimension
bool | df_init
| whether or not we've been initialized More...
unsigned int | d_numPoints
| the number of active points More...
double * | dp_distMat
| our internal distance matrix More...
RDGeom::PointPtrVect | d_positions
| pointers to the points we're using More...
ContribPtrVect | d_contribs
| contributions to the energy More...
INT_VECT | d_fixedPoints
unsigned int | d_matSize

## Detailed Description

A class to store forcefields and handle minimization.

A force field is used like this (schematically):

      ForceField ff;

      // add contributions:
      for contrib in contribs:
        ff.contribs().push_back(contrib);

      // set up the points:
      for positionPtr in positions:
        ff.positions().push_back(point);

      // initialize:
      ff.initialize()

      // and minimize:
      needsMore = ff.minimize();

Notes:

- The ForceField owns its contributions, which are stored using smart pointers.
- Distance calculations are currently lazy; the full distance matrix is never generated. In systems where the distance matrix is not sparse, this is almost certainly inefficient.

Definition at line 56 of file ForceField.h.

## Constructor & Destructor Documentation

ForceFields::ForceField::ForceField | ( | unsigned int | dimension = `3` | ) |
| inline

construct with a dimension

Definition at line 59 of file ForceField.h.

ForceFields::ForceField::~ForceField | ( |  | ) |

ForceFields::ForceField::ForceField | ( | const ForceField & | other | ) |

copy ctor, copies contribs.

## Member Function Documentation

double ForceFields::ForceField::calcEnergy | ( |  | ) | const

calculates and returns the energy (in kcal/mol) based on existing

Returns
  the current energy

Note: This function is less efficient than calcEnergy with postions passed in as double * the positions need to be converted to double * here

Referenced by RDKit::MMFF::MMFFOptimizeMolecule(), RDKit::MMFF::MMFFOptimizeMoleculeConfs(), and RDKit::UFF::UFFOptimizeMolecule().

double ForceFields::ForceField::calcEnergy | ( | double * | pos | ) |

calculates and returns the energy of the position passed in

Parameters

  pos | an array of doubles. Should be `3*this->numPoints()` long.

Returns
  the current energy

Side effects:

- Calling this resets the current distance matrix
- The individual contributions may further update the distance matrix

void ForceFields::ForceField::calcGrad | ( | double * | forces | ) | const

calculates the gradient of the energy at the current position

Parameters

  forces | an array of doubles. Should be `3*this->numPoints()` long.

Note: This function is less efficient than calcGrad with positions passed in the positions need to be converted to double * here

void ForceFields::ForceField::calcGrad | ( | double * | pos,
|  | double * | forces
| ) |  |

calculates the gradient of the energy at the provided position

Parameters

  pos | an array of doubles. Should be `3*this->numPoints()` long.
  forces | an array of doubles. Should be `3*this->numPoints()` long.

Side effects:

- The individual contributions may modify the distance matrix

ContribPtrVect& ForceFields::ForceField::contribs | ( |  | ) |
| inline

returns a reference to our contribs (a ContribPtrVect)

Definition at line 142 of file ForceField.h.

References d_contribs.

const ContribPtrVect& ForceFields::ForceField::contribs | ( |  | ) | const
| inline

Definition at line 143 of file ForceField.h.

References d_contribs.

unsigned int ForceFields::ForceField::dimension | ( |  | ) | const
| inline

returns the dimension of the forcefield

Definition at line 177 of file ForceField.h.

References d_dimension.

Referenced by DistGeom::FourthDimContrib::FourthDimContrib(), DistGeom::FourthDimContrib::getEnergy(), and DistGeom::FourthDimContrib::getGrad().

double ForceFields::ForceField::distance | ( | unsigned int | i,
|  | unsigned int | j,
|  | double * | pos = `0`
| ) |  |

returns the distance between two points

Parameters

  i | point index
  j | point index
  pos | (optional) If this argument is provided, it will be used to provide the positions of points. `pos` should be `3*this->numPoints()` long.

Returns
  the distance

Side effects:

- if the distance between i and j has not previously been calculated, our internal distance matrix will be updated.

double ForceFields::ForceField::distance | ( | unsigned int | i,
|  | unsigned int | j,
|  | double * | pos = `0`
| ) |  | const

returns the distance between two points

Parameters

  i | point index
  j | point index
  pos | (optional) If this argument is provided, it will be used to provide the positions of points. `pos` should be `3*this->numPoints()` long.

Returns
  the distance

Note: The internal distance matrix is not updated in this case

INT_VECT& ForceFields::ForceField::fixedPoints | ( |  | ) |
| inline

Definition at line 182 of file ForceField.h.

References d_fixedPoints.

const INT_VECT& ForceFields::ForceField::fixedPoints | ( |  | ) | const
| inline

Definition at line 183 of file ForceField.h.

References d_fixedPoints.

void ForceFields::ForceField::gather | ( | double * | pos | ) |
| protected

update our positions from an array

Parameters

  pos | should be `3*this->numPoints()` long;

void ForceFields::ForceField::initDistanceMatrix | ( |  | ) |
| protected

initializes our internal distance matrix

void ForceFields::ForceField::initialize | ( |  | ) |

does initialization

Referenced by RDKit::MMFF::MMFFOptimizeMolecule(), RDKit::MMFF::MMFFOptimizeMoleculeConfs(), and RDKit::UFF::UFFOptimizeMolecule().

int ForceFields::ForceField::minimize | ( | unsigned int | maxIts = `200`,
|  | double | forceTol = `1e-4`,
|  | double | energyTol = `1e-6`
| ) |  |

minimizes the energy of the system by following gradients

Parameters

  maxIts | the maximum number of iterations to try
  forceTol | the convergence criterion for forces
  energyTol | the convergence criterion for energies

Returns
  an integer value indicating whether or not the convergence criteria were achieved:
  - 0: indicates success
  - 1: the minimization did not converge in `maxIts` iterations.

Referenced by RDKit::MMFF::MMFFOptimizeMolecule(), RDKit::MMFF::MMFFOptimizeMoleculeConfs(), and RDKit::UFF::UFFOptimizeMolecule().

unsigned int ForceFields::ForceField::numPoints | ( |  | ) | const
| inline

returns the number of points the ForceField is handling

Definition at line 180 of file ForceField.h.

References d_numPoints.

RDGeom::PointPtrVect& ForceFields::ForceField::positions | ( |  | ) |
| inline

returns a reference to our points (a PointPtrVect)

Definition at line 138 of file ForceField.h.

References d_positions.

Referenced by RDKit::MMFF::MMFFOptimizeMoleculeConfs().

const RDGeom::PointPtrVect& ForceFields::ForceField::positions | ( |  | ) | const
| inline

Definition at line 139 of file ForceField.h.

References d_positions.

void ForceFields::ForceField::scatter | ( | double * | pos | ) | const
| protected

scatter our positions into an array

Parameters

  pos | should be `3*this->numPoints()` long;

## Member Data Documentation

ContribPtrVect ForceFields::ForceField::d_contribs
| protected

contributions to the energy

Definition at line 191 of file ForceField.h.

Referenced by contribs().

unsigned int ForceFields::ForceField::d_dimension
| protected

Definition at line 183 of file ForceField.h.

Referenced by dimension().

INT_VECT ForceFields::ForceField::d_fixedPoints
| protected

Definition at line 192 of file ForceField.h.

Referenced by fixedPoints().

unsigned int ForceFields::ForceField::d_matSize
| protected

Definition at line 193 of file ForceField.h.

unsigned int ForceFields::ForceField::d_numPoints
| protected

the number of active points

Definition at line 188 of file ForceField.h.

Referenced by numPoints().

RDGeom::PointPtrVect ForceFields::ForceField::d_positions
| protected

pointers to the points we're using

Definition at line 190 of file ForceField.h.

Referenced by positions().

bool ForceFields::ForceField::df_init
| protected

whether or not we've been initialized

Definition at line 187 of file ForceField.h.

double* ForceFields::ForceField::dp_distMat
| protected

our internal distance matrix

Definition at line 189 of file ForceField.h.

The documentation for this class was generated from the following file:

- ForceField.h