Template Class SimplePairwisePotential#

Inheritance Relationships#

Base Type#

Class Documentation#

template<typename pairwise_interaction, typename distance_policy = cartesian_distance<3>>
class SimplePairwisePotential : public pele::PairwisePotentialInterface#

Define a base class for potentials with simple pairwise interactions that depend only on magnitude of the atom separation.

This class loops though atom pairs, computes the distances and get’s the value of the energy and gradient from the class pairwise_interaction. pairwise_interaction is a passed parameter and defines the actual potential function.

Public Functions

inline virtual ~SimplePairwisePotential()#
inline virtual size_t get_ndim() const#

Return the number of dimensions (box dimensions).

Ideally this should be overloaded.

inline virtual double get_energy(Array<double> const &x)#

Return the energy of configuration x.

This is the only function which must be overloaded

inline virtual double get_energy_change(
Array<double> const &old_coords,
Array<double> const &new_coords,
std::vector<size_t> const &changed_atoms
)#

Return the change in energy when configuration A is changed to configuration B.

It also takes in the vector of indices of atoms changed to recalculate energies changed by those atoms.

inline virtual double get_energy_gradient(
Array<double> const &x,
Array<double> &grad
)#

compute the energy and gradient.

If not overloaded it will compute the numerical gradient

inline virtual double get_energy_gradient(
Array<double> const &x,
Array<double> &grad,
Array<uint8_t> not_rattlers
)#
inline virtual double get_energy_gradient(
Array<double> const &x,
std::vector<xsum_small_accumulator> &exact_grad
)#
inline virtual double get_energy_gradient_hessian(
Array<double> const &x,
Array<double> &grad,
Array<double> &hess
)#

compute the energy and gradient and Hessian.

If not overloaded it will compute the Hessian numerically and use get_energy_gradient to get the energy and gradient.

inline virtual double get_energy_gradient_hessian_rattlers(
Array<double> const &x,
Array<double> &grad,
Array<double> &hess,
Array<uint8_t> not_rattlers
)#
inline virtual void get_hessian(Array<double> const &x, Array<double> &hess)#

compute the hessian.

If not overloaded it will call get_energy_gradient_hessian

inline virtual double add_energy_gradient(
Array<double> const &x,
Array<double> &grad
)#

compute the energy and gradient, but don’t initialize the gradient to zero

inline virtual double add_energy_gradient(
Array<double> const &x,
Array<double> &grad,
Array<uint8_t> not_rattlers
)#
inline virtual double add_energy_gradient(
Array<double> const &x,
std::vector<xsum_small_accumulator> &exact_grad
)#
inline virtual double add_energy_gradient_hessian(
Array<double> const &x,
Array<double> &grad,
Array<double> &hess
)#

compute the energy, gradient, and Hessian, but don’t initialize the gradient or hessian to zero

inline virtual double add_energy_gradient_hessian(
Array<double> const &x,
Array<double> &grad,
Array<double> &hess,
Array<uint8_t> not_rattlers
)#
inline virtual void add_hessian(Array<double> const &x, Array<double> &hess)#
virtual void get_neighbors(
pele::Array<double> const &coords,
pele::Array<std::vector<size_t>> &neighbor_indss,
pele::Array<std::vector<std::vector<double>>> &neighbor_distss,
const double cutoff_factor = 1.0
)#

Return lists of neighbors.

virtual void get_neighbors_picky(
pele::Array<double> const &coords,
pele::Array<std::vector<size_t>> &neighbor_indss,
pele::Array<std::vector<std::vector<double>>> &neighbor_distss,
pele::Array<short> const &include_atoms,
const double cutoff_factor = 1.0
)#

Return lists of neighbors considering only certain atoms.

virtual std::vector<size_t> get_overlaps(Array<double> const &coords)#

Return linearized vector of overlapping atoms.

Every two entries in the resulting vector correspond to a pair of overlapping atoms.

inline virtual void get_rij(
double *const r_ij,
double const *const r1,
double const *const r2
) const#

Return the distance as measured by the distance policy.

inline virtual double get_interaction_energy_gradient(
double r2,
double *gij,
size_t atom_i,
size_t atom_j
) const#

Return energy_gradient of interaction.

inline virtual double get_interaction_energy_gradient_hessian(
double r2,
double *gij,
double *hij,
size_t atom_i,
size_t atom_j
) const#

Return gradient and Hessian of interaction.

inline virtual double compute_norm(pele::Array<double> const &x)#

compute a meaningful norm of all coordinates

Protected Functions

inline SimplePairwisePotential(
std::shared_ptr<pairwise_interaction> interaction,
const Array<double> radii,
NonAdditiveCutoffCalculator cutoff_calculator,
std::shared_ptr<distance_policy> dist = NULL,
const double radii_sca = 0.0,
bool exact_sum = false
)#
inline SimplePairwisePotential(
std::shared_ptr<pairwise_interaction> interaction,
const Array<double> radii,
std::shared_ptr<distance_policy> dist = NULL,
const double radii_sca = 0.0,
bool exact_sum = false,
double non_additivity = 0.0
)#
inline SimplePairwisePotential(
std::shared_ptr<pairwise_interaction> interaction,
std::shared_ptr<distance_policy> dist = NULL,
bool exact_sum = false
)#

Protected Attributes

const double m_radii_sca#
bool exact_sum#
std::shared_ptr<std::vector<xsum_small_accumulator>> exact_gradient#
bool exact_gradient_initialized#

Protected Static Attributes

static const size_t m_ndim = distance_policy::_ndim#