[155cc2] | 1 | /*
|
---|
| 2 | * PairPotential_Morse.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Oct 03, 2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef PAIRPOTENTIAL_MORSE_HPP_
|
---|
| 9 | #define PAIRPOTENTIAL_MORSE_HPP_
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | // include config.h
|
---|
| 13 | #ifdef HAVE_CONFIG_H
|
---|
| 14 | #include <config.h>
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
[d03292] | 17 | #include <limits>
|
---|
| 18 |
|
---|
[155cc2] | 19 | #include "CodePatterns/Assert.hpp"
|
---|
| 20 |
|
---|
| 21 | #include "Potentials/EmpiricalPotential.hpp"
|
---|
[ed2551] | 22 | #include "Potentials/SerializablePotential.hpp"
|
---|
[155cc2] | 23 | #include "FunctionApproximation/FunctionModel.hpp"
|
---|
| 24 |
|
---|
| 25 | /** This is the implementation of a harmonic pair potential.
|
---|
| 26 | *
|
---|
| 27 | * This evaluates \f$ k \cdot (r -r_0)^2 \f$.
|
---|
| 28 | *
|
---|
| 29 | */
|
---|
[ed2551] | 30 | class PairPotential_Morse :
|
---|
| 31 | virtual public EmpiricalPotential,
|
---|
| 32 | virtual public FunctionModel,
|
---|
| 33 | virtual public SerializablePotential
|
---|
[155cc2] | 34 | {
|
---|
[76cbd0] | 35 | //!> grant unit test access to internal parts
|
---|
| 36 | friend class PairPotential_MorseTest;
|
---|
[155cc2] | 37 | // some repeated typedefs to avoid ambiguities
|
---|
| 38 | typedef FunctionModel::arguments_t arguments_t;
|
---|
| 39 | typedef FunctionModel::result_t result_t;
|
---|
| 40 | typedef FunctionModel::results_t results_t;
|
---|
| 41 | typedef EmpiricalPotential::derivative_components_t derivative_components_t;
|
---|
| 42 | typedef FunctionModel::parameters_t parameters_t;
|
---|
| 43 | public:
|
---|
[ed2551] | 44 | PairPotential_Morse(const ParticleTypes_t &_ParticleTypes);
|
---|
[155cc2] | 45 | PairPotential_Morse(
|
---|
[ed2551] | 46 | const ParticleTypes_t &_ParticleTypes,
|
---|
[155cc2] | 47 | const double _spring_constant,
|
---|
| 48 | const double _equilibrium_distance,
|
---|
| 49 | const double _dissociation_energy,
|
---|
| 50 | const double _energy_offset);
|
---|
| 51 | virtual ~PairPotential_Morse() {}
|
---|
| 52 |
|
---|
| 53 | /** Setter for parameters as required by FunctionModel interface.
|
---|
| 54 | *
|
---|
| 55 | * \param _params given set of parameters
|
---|
| 56 | */
|
---|
[086070] | 57 | void setParameters(const parameters_t &_params);
|
---|
[155cc2] | 58 |
|
---|
| 59 | /** Getter for parameters as required by FunctionModel interface.
|
---|
| 60 | *
|
---|
| 61 | * \return set of parameters
|
---|
| 62 | */
|
---|
| 63 | parameters_t getParameters() const
|
---|
| 64 | {
|
---|
| 65 | return params;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | /** Getter for the number of parameters of this model function.
|
---|
| 69 | *
|
---|
| 70 | * \return number of parameters
|
---|
| 71 | */
|
---|
| 72 | size_t getParameterDimension() const
|
---|
| 73 | {
|
---|
| 74 | return 4;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /** Evaluates the harmonic potential function for the given arguments.
|
---|
| 78 | *
|
---|
| 79 | * @param arguments single distance
|
---|
| 80 | * @return value of the potential function
|
---|
| 81 | */
|
---|
| 82 | results_t operator()(const arguments_t &arguments) const;
|
---|
| 83 |
|
---|
| 84 | /** Evaluates the derivative of the potential function.
|
---|
| 85 | *
|
---|
| 86 | * @param arguments single distance
|
---|
| 87 | * @return vector with derivative with respect to the input degrees of freedom
|
---|
| 88 | */
|
---|
| 89 | derivative_components_t derivative(const arguments_t &arguments) const;
|
---|
| 90 |
|
---|
| 91 | /** Evaluates the derivative of the function with the given \a arguments
|
---|
| 92 | * with respect to a specific parameter indicated by \a index.
|
---|
| 93 | *
|
---|
| 94 | * \param arguments set of arguments as input variables to the function
|
---|
| 95 | * \param index derivative of which parameter
|
---|
| 96 | * \return result vector containing the derivative with respect to the given
|
---|
| 97 | * input
|
---|
| 98 | */
|
---|
| 99 | results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
|
---|
| 100 |
|
---|
[6efcae] | 101 | /** Return the token name of this specific potential.
|
---|
[67cd3a] | 102 | *
|
---|
[6efcae] | 103 | * \return token name of the potential
|
---|
[67cd3a] | 104 | */
|
---|
[ed2551] | 105 | const std::string& getToken() const
|
---|
| 106 | { return potential_token; }
|
---|
| 107 |
|
---|
| 108 | /** Returns a vector of parameter names.
|
---|
| 109 | *
|
---|
| 110 | * This is required from the specific implementation
|
---|
| 111 | *
|
---|
| 112 | * \return vector of strings containing parameter names
|
---|
| 113 | */
|
---|
| 114 | const ParameterNames_t& getParameterNames() const
|
---|
| 115 | { return ParameterNames; }
|
---|
[67cd3a] | 116 |
|
---|
[d03292] | 117 | /** States whether lower and upper boundaries should be used to constraint
|
---|
| 118 | * the parameter search for this function model.
|
---|
| 119 | *
|
---|
| 120 | * \return true - constraints should be used, false - else
|
---|
| 121 | */
|
---|
| 122 | bool isBoxConstraint() const {
|
---|
| 123 | return true;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | /** Returns a vector which are the lower boundaries for each parameter_t
|
---|
| 127 | * of this FunctionModel.
|
---|
| 128 | *
|
---|
| 129 | * \return vector of parameter_t resembling lowest allowed values
|
---|
| 130 | */
|
---|
| 131 | parameters_t getLowerBoxConstraints() const {
|
---|
| 132 | parameters_t lowerbound(getParameterDimension(), -std::numeric_limits<double>::max());
|
---|
| 133 | lowerbound[equilibrium_distance] = 0.;
|
---|
| 134 | return lowerbound;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | /** Returns a vector which are the upper boundaries for each parameter_t
|
---|
| 138 | * of this FunctionModel.
|
---|
| 139 | *
|
---|
| 140 | * \return vector of parameter_t resembling highest allowed values
|
---|
| 141 | */
|
---|
| 142 | parameters_t getUpperBoxConstraints() const {
|
---|
| 143 | return parameters_t(getParameterDimension(), std::numeric_limits<double>::max());
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[155cc2] | 146 | enum parameter_enum_t {
|
---|
| 147 | spring_constant=0,
|
---|
| 148 | equilibrium_distance=1,
|
---|
| 149 | dissociation_energy=2,
|
---|
| 150 | energy_offset=3,
|
---|
| 151 | MAXPARAMS
|
---|
| 152 | };
|
---|
[f48ad3] | 153 |
|
---|
| 154 | private:
|
---|
[155cc2] | 155 | //!> parameter vector with parameters as in enum parameter_enum_t
|
---|
| 156 | parameters_t params;
|
---|
[ed2551] | 157 |
|
---|
| 158 | //!> static definitions of the parameter name for this potential
|
---|
| 159 | static const ParameterNames_t ParameterNames;
|
---|
| 160 |
|
---|
| 161 | //!> static token of this potential type
|
---|
| 162 | static const std::string potential_token;
|
---|
[155cc2] | 163 | };
|
---|
| 164 |
|
---|
| 165 | #endif /* PAIRPOTENTIAL_MORSE_HPP_ */
|
---|