Loading...
Searching...
No Matches
EnergyCalculator Class Referenceabstract
Inheritance diagram for EnergyCalculator:

## Public Member Functions

virtual EnergyCalculator * | newInstance () const =0
virtual std::string | identifier () const =0
virtual std::string | name () const =0
virtual std::string | description () const =0
virtual std::string | userOptions () const
| Return a JSON object string describing optional user-editable settings for this model. Empty string means no user options.
virtual bool | setUserOptions (const std::string &optionsJson)
| Set user-selected options serialized as a JSON object string.
virtual Core::Molecule::ElementMask | elements () const =0
| Indicate if your method only treats a subset of elements.
virtual bool | acceptsUnitCell () const
| Indicate if your method can handle unit cells.
virtual bool | acceptsIons () const
| Indicate if your method can handle ions Many methods only treat neutral systems, either a neutral molecule or a neutral unit cell.
virtual bool | acceptsRadicals () const
| Indicate if your method can handle radicals Most methods only treat closed-shell molecules.
virtual Real | value (const Eigen::VectorXd &x)=0
virtual void | gradient (const Eigen::VectorXd &x, Eigen::VectorXd &grad)
void | finiteGradient (const Eigen::VectorXd &x, Eigen::VectorXd &grad, int accuracy=0)
virtual Real | evaluate (const Eigen::VectorXd &x, Eigen::VectorXd *grad=nullptr)
virtual void | hessian (const Eigen::VectorXd &x, Eigen::MatrixXd &hess)
void | finiteHessian (const Eigen::VectorXd &x, Eigen::MatrixXd &hess, int accuracy=0)
void | cleanGradients (Eigen::VectorXd &grad)
Real | constraintEnergies (const Eigen::VectorXd &x)
void | constraintGradients (const Eigen::VectorXd &x, Eigen::VectorXd &grad)
std::vector< Core::Constraint > | constraints () const
void | setConstraints (const std::vector< Core::Constraint > &constraints)
void | setMask (Eigen::VectorXd mask)
Eigen::VectorXd | mask () const
virtual void | setMolecule (Core::Molecule *mol)=0

## Protected Member Functions

void | appendError (const std::string &errorString, bool newLine=true) const
| Append an error to the error string for the model.

## Protected Attributes

Eigen::VectorXd | m_mask
std::vector< Core::Constraint > | m_distanceConstraints
std::vector< Core::Constraint > | m_angleConstraints
std::vector< Core::Constraint > | m_torsionConstraints
std::vector< Core::Constraint > | m_outOfPlaneConstraints

## Member Function Documentation

## newInstance()

virtual EnergyCalculator * newInstance | ( |  | ) | const

pure virtual

Create a new instance of the model. Ownership passes to the caller.

Implemented in LennardJones, and UFF.

## identifier()

virtual std::string identifier | ( |  | ) | const

pure virtual

Returns
  a unique identifier for this calculator.

Implemented in LennardJones, and UFF.

## name()

virtual std::string name | ( |  | ) | const

pure virtual

Returns
  A short translatable name for this method (e.g., MMFF94, UFF, etc.)

Implemented in LennardJones, and UFF.

## description()

virtual std::string description | ( |  | ) | const

pure virtual

Returns
  a description of the method

Implemented in LennardJones, and UFF.

## setUserOptions()

virtual bool setUserOptions | ( | const std::string & | optionsJson | ) |

virtual

Returns
  True on success.

## elements()

virtual Core::Molecule::ElementMask elements | ( |  | ) | const

pure virtual

Returns
  an element mask corresponding to the defined subset

Implemented in LennardJones, and UFF.

## acceptsUnitCell()

virtual bool acceptsUnitCell | ( |  | ) | const

virtual

Returns
  true if unit cells are supported

Reimplemented in LennardJones, and UFF.

## acceptsIons()

virtual bool acceptsIons | ( |  | ) | const

virtual

Returns
  true if ions are supported

Reimplemented in LennardJones, and UFF.

## acceptsRadicals()

virtual bool acceptsRadicals | ( |  | ) | const

virtual

Returns
  true if radicals are supported

Reimplemented in LennardJones, and UFF.

## value()

virtual Real value | ( | const Eigen::VectorXd & | x | ) |

pure virtual

Calculate the energy for this method.

Implemented in LennardJones, and UFF.

## gradient()

virtual void gradient | ( | const Eigen::VectorXd & | x,
|  | Eigen::VectorXd & | grad )

virtual

Calculate the gradients for this method, defaulting to numerical finite-difference methods

Reimplemented in LennardJones, and UFF.

## finiteGradient()

void finiteGradient | ( | const Eigen::VectorXd & | x,
|  | Eigen::VectorXd & | grad,
|  | int | accuracy = 0 )

Calculate numerical gradients for this method.

## evaluate()

virtual Real evaluate | ( | const Eigen::VectorXd & | x,
|  | Eigen::VectorXd * | grad = nullptr )

virtual

Evaluate the energy and optionally gradients in one call.

Derived classes with efficient fused implementations should override this.

Reimplemented in LennardJones, and UFF.

## hessian()

virtual void hessian | ( | const Eigen::VectorXd & | x,
|  | Eigen::MatrixXd & | hess )

virtual

Calculate the Hessian matrix for this method, defaulting to numerical finite-difference methods.

## finiteHessian()

void finiteHessian | ( | const Eigen::VectorXd & | x,
|  | Eigen::MatrixXd & | hess,
|  | int | accuracy = 0 )

Calculate numerical Hessian for this method.

## cleanGradients()

void cleanGradients | ( | Eigen::VectorXd & | grad | ) |

Called to 'clean' gradients

Parameters

  grad | (e.g., for constraints)

## constraintEnergies()

Real constraintEnergies | ( | const Eigen::VectorXd & | x | ) |

Called to get the energies for the current set of constraints. which should be added to the value() method for real energies in derived classes

Returns
  the sum of the constraint energies

## constraintGradients()

void constraintGradients | ( | const Eigen::VectorXd & | x,
|  | Eigen::VectorXd & | grad )

Called to get the gradients for the current set of constraints. which should be added to the gradient() method in derived classes.

Parameters

  x | the current coordinates
  grad | the gradient vector to be updated with constraint gradients

## constraints()

std::vector< Core::Constraint > constraints | ( |  | ) | const

Called to get the constraints for this method.

Returns
  the constraints for this method

## setMask()

void setMask | ( | Eigen::VectorXd | mask | ) |

Called to update the "frozen" mask (e.g., during editing)

## mask()

Eigen::VectorXd mask | ( |  | ) | const

Returns
  the frozen atoms mask

## setMolecule()

virtual void setMolecule | ( | Core::Molecule * | mol | ) |

pure virtual

Called when the current molecule changes.

Implemented in LennardJones, and UFF.

## appendError()

void appendError | ( | const std::string & | errorString,
|  | bool | newLine = true ) const

protected

Parameters

  errorString | The error to be added.
  newLine | Add a new line after the error string?

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

- energycalculator.h