| 1 | /* | 
|---|
| 2 | * EmpiricalPotential.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Sep 26, 2012 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef EMPIRICALPOTENTIAL_HPP_ | 
|---|
| 9 | #define EMPIRICALPOTENTIAL_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 | // include config.h | 
|---|
| 13 | #ifdef HAVE_CONFIG_H | 
|---|
| 14 | #include <config.h> | 
|---|
| 15 | #endif | 
|---|
| 16 |  | 
|---|
| 17 | #include <vector> | 
|---|
| 18 |  | 
|---|
| 19 | /** An EmpiricalPotential is a function that is given a vector of objects as | 
|---|
| 20 | * arguments which it uses to evaluate an internal function and returns a | 
|---|
| 21 | * value representing the energy of this configuration indicated by the | 
|---|
| 22 | * arguments. | 
|---|
| 23 | * | 
|---|
| 24 | * It is to be used inside an std::accumulate function after a vector of | 
|---|
| 25 | * arguments (i.e. a vector of a vector) has been prepared initially. | 
|---|
| 26 | * | 
|---|
| 27 | */ | 
|---|
| 28 | class EmpiricalPotential | 
|---|
| 29 | { | 
|---|
| 30 | public: | 
|---|
| 31 | /** This class encapsulates all information with respect to a single argument | 
|---|
| 32 | *  for a empirical potential function. | 
|---|
| 33 | */ | 
|---|
| 34 | struct argument_t | 
|---|
| 35 | { | 
|---|
| 36 | //!> indices between which the distance is given | 
|---|
| 37 | std::pair<size_t, size_t> indices; | 
|---|
| 38 | //!> distance | 
|---|
| 39 | double distance; | 
|---|
| 40 | }; | 
|---|
| 41 |  | 
|---|
| 42 | //!> typedef on the result value of operator() | 
|---|
| 43 | typedef double result_t; | 
|---|
| 44 | //!> typedef on the result value of derivative() | 
|---|
| 45 | typedef std::vector<result_t> derivative_components_t; | 
|---|
| 46 | //!> typedef for the list of argument_t to be given to operator(). | 
|---|
| 47 | typedef std::vector<argument_t> arguments_t; | 
|---|
| 48 | public: | 
|---|
| 49 | /** Default constructor for class EmpiricalPotential. | 
|---|
| 50 | * | 
|---|
| 51 | */ | 
|---|
| 52 | EmpiricalPotential(); | 
|---|
| 53 |  | 
|---|
| 54 | /** Destructor for class EmpiricalPotential. | 
|---|
| 55 | * | 
|---|
| 56 | */ | 
|---|
| 57 | virtual ~EmpiricalPotential() {} | 
|---|
| 58 |  | 
|---|
| 59 | /** This evaluates the internal function with the given list of \a arguments. | 
|---|
| 60 | * | 
|---|
| 61 | * @param arguments arguments for the internal function | 
|---|
| 62 | * @return result of the function evaluation | 
|---|
| 63 | */ | 
|---|
| 64 | result_t operator()(const arguments_t &arguments) const; | 
|---|
| 65 |  | 
|---|
| 66 | /** This evaluates the first derivative of the internal function with the | 
|---|
| 67 | * given list of \a arguments. | 
|---|
| 68 | * | 
|---|
| 69 | * @param arguments arguments for the internal function | 
|---|
| 70 | * @return result vector with same number of components as \a arguments | 
|---|
| 71 | */ | 
|---|
| 72 | derivative_components_t derivative(const arguments_t &arguments) const; | 
|---|
| 73 | }; | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 | #endif /* EMPIRICALPOTENTIAL_HPP_ */ | 
|---|