Potential

class Potential

A potential represents both the model and the method used to compute the model (e.g., VisitModel) for a given Configuration. A potential also allows customization of the model parameters templated but separate from those in the Configuration.

Public Functions

Potential(const argtype &args = argtype())

Construct with the default visitor and default model (emtpy).

args:

  • group_index: set the index of the group in the configuration which contributes to this potential (default: 0, representing entire config).

  • cell_index: set the index of the cell, only to be used with VisitModelCell. This also overrides group_index.

  • prevent_cache: set this to true in order to prevent the use of cache (default: False)

int group_index() const

Return the index of the group.

int cell_index() const

Return the index of the cell.

Potential(std::shared_ptr<Model> model, const argtype &args = argtype())

Constract with model and default visitor.

const Model &model() const

Return the model.

Potential(std::shared_ptr<VisitModel> visit_model, const argtype &args = argtype())

Construct with visitor and default model.

const VisitModel &visit_model() const

Return the method used to compute.

Potential(std::shared_ptr<Model> model, std::shared_ptr<VisitModel> visit_model, const argtype &args = argtype())

Construct with model and visitor.

void set(const ModelParams &model_params)

Set the model parameters. If not set, use the one from configuration.

void set_model_params(const Configuration &config)

Set the model parameters to the one in the configuration.

void set_model_param(const char *name, const int site_type, const double value)

Modify model parameter of a given site type and name to value.

const ModelParams &model_params() const

Return the model parameters.

const ModelParams &model_params(const Configuration &config) const

Return the model parameters. Use model parameters from configuration if they have not been overridden.

void precompute(Configuration *config)

Precompute quantities for optimizations before calculation of energies.

virtual double energy(Configuration *config)

Compute the energy of the entire configuration.

virtual double select_energy(const Select &select, Configuration *config)

Compute the energy of a selection of the configuration.

double stored_energy() const

Return the last computed value of the energy.

void set_stored_energy(const double energy)

Set the last computed value of the energy.

void change_volume(const double delta_volume, const int dimension)

Change the volume.

void revert(const Select &select)

Revert any changes to the configuration due to the last energy computation.

void finalize(const Select &select)

Finalize changes to the configuration due to the last energy computation.

const Cache &cache() const

Return the cache.

void load_cache(const bool load)

Set Cache to load.

void unload_cache(const Potential &potential)

Set Cache to unload.

void serialize(std::ostream &ostr) const

Serialize.

Potential(std::istream &istr)

Deserialize.