Subsections

 
3.6 OEForceField

class OEMolPotential::OEForceField : public OEMolPotential::OEMolFunc1

This abstract class defines interface for the collection of functions which are naturally associated with a force field. OEForceField is a trivial extension of the OEMolFunc1 class. Classes derived from OEMolFunc1 are commonly force field components, or parts of force fields. Force field components are collected into full force field implementation. The final collection of components into a force field usually needs to be done concombinant with one or more OEFFParams derived classes. Classes derived from OEForceField are able to collect interaction and parameter retrieval classes into a single class, while providing external interfaces to the collected functions.

3.6.1 operator()

double operator()(const double *coord)
double operator()(const double *coord, double *grad)

These methods perform an energy evaluation given a set of Cartesian coordinates for a molecule or conformer. In addition, the second of the two methods populates an array of gradients given a set of coordinates. The gradient array must be initialized before the call to the method, although this is normally performed by an optimizer (Section 3.18). The first three elements of the gradient array are the X, Y, and Z gradients for the first atom in the molecule, followed by the X, Y, and Z gradients of the second atom and so on up to the last atom.

3.6.2 Add

bool Add(OEMolPotential::OEMolFunc1 &f,bool own=false)

This method pure virtual method defines the interface for adding externally declared function to an OEForceField derived instance. The second argument denotes whether the OEForceField derived instance is to take ownership of the memory occupied by the external function. If ownership is passed to the OEForceField derived instance then the C++ delete operator will be called for the function inside the destructor of the OEForceField derived class. Any object derived from the OEMolFunc1 (Section 3.15) abstract class may be added using this method. The method returns true if the OEMolFunc1 is successfully added. Only one copy of a OEMolFunc1 may be added to an OEForceField instance. Subsequent attempts to add the an OEMolFunc1 to already contained in a OEForceField derived class will fail with a return value of false.

bool Add(const OEFFParams &ffp)

This pure virtual method defines the interface for adding a copy of an externally declared OEFFParams derived class to an internally stored list. The OEForceField::PrepMol method will call OEFFParams::PrepMol for each internally stored OEFFParams instance.

3.6.3 GetFComponents

OESystem::OEIterBase<OEOpt::OEFComponent> *GetFComponents(const double *coord)

This method takes a pointer to a set of Cartesian coordinates, and returns an iterator over the names and component energies (Section 3.4) calculated for the coordinates.

3.6.4 NumVar

unsigned int NumVar() const

This pure virtual method returns the number of variables for which an OEForceField instance has been initialized using the OEForceField::Setup method. The value is normally equivalent to three times OEMolBase::GetMaxAtomIdx().

3.6.5 Remove

bool Remove(OEMolPotential::OEMolFunc1 &f)

The pure virtual Remove method provides the ablity to remove a function previously added to an OEForceField instance. If the function is not contained in the OEForceField instance then the method will return false. If the OEMolFunc1 found and removed successfully, then the method will return true. If an OEMolFunc1 is owned by the OEForceField instance for which the method was called, then the OEMolFunc1's delete operator will be called.

3.6.6 Set

bool Set(const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &pred,
         unsigned int functype)
bool Set(const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &pred,
         unsigned int functype)
bool Set(const OESystem::OEBinaryPredicate<OEChem::OEAtomBase,
                                           OEChem::OEAtomBase> &pred,
         unsigned int functype)
bool Set(const OESystem::OEBinaryPredicate<OEChem::OEBondBase,
                                           OEChem::OEBondBase> &pred,
         unsigned int functype)

These methods assign interaction-control predicates to the components contained in the OEForceField instance. The first argument is the predicate type to be passed to the interaction component. The second argument is a value or a set of binary OR'ed values taken from the OEFuncType namespace which specifies the intended target for the predicate assignment.

3.6.7 Setup

bool Setup(const OEChem::OEMolBase &mol)

This method prepares an OEForceField derived class for perfoming energy and gradient calculations for conformers of a molecule. The OEMolFunc1::Setup methods are called for all functions contained within the OEForceField derived class. This method should only be called after the molecule has been prepared by the overriding OEForceField::PrepMol method. If the method returns true then all interactions and parameters were perceived properly and the OEForceField instance is ready for energy calculations. If the method returns false then a failure was detected. Setup failures normally occur when at least one interaction requires parameters which are not defined for the force field. The return value for this method should always be verified prior to calling either overriding OEForceField::operator() method.

3.6.8 PrepMol

bool PrepMol(OEChem::OEMolBase &mol,bool sweep = true) const

PrepMol methods call OEFFParams::PrepMol methods for all contained OEFFParams instances in OEForceField derived classes. The OEFFParams::PrepMol override methods apply changes to the molecule passed as the function argument that are necessary preparation for force field setup (OEMolFunc1::Setup). The second argument to the method specifies whether a call to OEMolBase::Sweep is allowed during the preparation. By default, sweeping a molecule is allowed by the method. Methods that override PrepMol may alter the contents of the passed molecule. If all OEFFParams::PrepMol methods return true then OEForceField::PrepMol will return true. If any OEFFParams::PrepMol method returns false then OEForceField::PrepMol will return false.