Avogadro::Calc::ChargeModel#

class ChargeModel#

General API for charge / electrostatics models.

This serves as the common base class for electrostatics models. Many use atomic point charges, but we also allow for custom models for Slater / Gaussian distributions, distributed electrostatics, use of quantum mechanics, etc.

Author

Geoffrey R. Hutchison

Key methods are to determine either atomic partial charges or electrostatic potentials at particular points in space.

There is a default implementation for the electrostatic potential at points in space, based on the atomic partial charges. If you implement a different mechanism, you should override this method.

Subclassed by DefaultModel

Public Functions

ChargeModel() = default#
virtual ~ChargeModel() = default#
virtual ChargeModel *newInstance() const = 0#

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

virtual std::string identifier() const = 0#

A unique identifier, used to retrieve models programmatically. EEM2, NPA, etc. A runtime warning will be generated if the identifier is not unique.

virtual std::string name() const = 0#

A user-visible name of the model (e.g., “Natural Population

Analysis”)

virtual Core::Molecule::ElementMask elements() const = 0#

Indicate if your method only treats a subset of elements.

Returns:

an element mask corresponding to the defined subset

inline virtual void setDielectric(float dielectric)#

Set the dielectric constant for the model.

Parameters:

dielectric – constant.

inline virtual float dielectric() const#
Returns:

The dielectric constant.

virtual MatrixX partialCharges(Core::Molecule &mol) const = 0#
virtual MatrixX partialCharges(const Core::Molecule &mol) const = 0#
virtual Vector3 dipoleMoment(const Core::Molecule &mol) const#

Calculate the dipole moment of the molecule.

Defaults to using the partial charges and atomic positions to calculate the net dipole moment.

Returns:

The dipole moment vector of the molecule

virtual double potential(Core::Molecule &mol, const Vector3 &point) const#

Calculate the electrostatic potential at a particular point in space.

Parameters:
  • mol – The molecule to calculate the potential for.

  • point – The point in space to calculate the potential at.

Returns:

The electrostatic potential at the point.

virtual Core::Array<double> potentials(Core::Molecule &mol, const Core::Array<Vector3> &points) const#

Calculate the electrostatic potential at multiple points.

This method is used for batch calculation and defaults to simply calculating each point at a time. Some methods work faster in batches.

Parameters:
  • mol – The molecule to calculate the potential for.

  • points – The points in space to calculate the potential at.

Returns:

The electrostatic potential at the points in an array.

Protected Functions

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

Append an error to the error string for the model.

Parameters:
  • errorString – The error to be added.

  • newLine – Add a new line after the error string?