[610c11] | 1 | /*
|
---|
| 2 | * ManyBodyPotential_Tersoff.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Sep 26, 2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef MANYBODYPOTENTIAL_TERSOFF_HPP_
|
---|
| 9 | #define MANYBODYPOTENTIAL_TERSOFF_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include <boost/function.hpp>
|
---|
| 17 | #include <cmath>
|
---|
[d03292] | 18 | #include <limits>
|
---|
[610c11] | 19 |
|
---|
[4f82f8] | 20 | #include "Potentials/EmpiricalPotential.hpp"
|
---|
| 21 |
|
---|
[d52819] | 22 | class TrainingData;
|
---|
| 23 |
|
---|
[610c11] | 24 | /** This class is the implementation of the Tersoff potential function.
|
---|
| 25 | *
|
---|
| 26 | * \note The arguments_t argument list is here in the following order:
|
---|
[dd966f] | 27 | * -# first \f$ r_{ij} \f$,
|
---|
| 28 | * -# then all \f$ r_{ik} \f$ that are within the cutoff, i.e. \f$ r_{ik} < R + D\f$
|
---|
[610c11] | 29 | *
|
---|
| 30 | */
|
---|
[ed2551] | 31 | class ManyBodyPotential_Tersoff :
|
---|
[fdd23a] | 32 | public EmpiricalPotential
|
---|
[610c11] | 33 | {
|
---|
[ffc368] | 34 | //!> grant unit test access to internal parts
|
---|
| 35 | friend class ManyBodyPotential_TersoffTest;
|
---|
[3ccea3] | 36 | // some repeated typedefs to avoid ambiguities
|
---|
| 37 | typedef FunctionModel::arguments_t arguments_t;
|
---|
| 38 | typedef FunctionModel::result_t result_t;
|
---|
| 39 | typedef FunctionModel::results_t results_t;
|
---|
| 40 | typedef EmpiricalPotential::derivative_components_t derivative_components_t;
|
---|
[e7579e] | 41 | typedef FunctionModel::parameters_t parameters_t;
|
---|
[610c11] | 42 | public:
|
---|
| 43 | /** Constructor for class ManyBodyPotential_Tersoff.
|
---|
| 44 | *
|
---|
[775dd1a] | 45 | * \param _ParticleTypes particle types for this potential
|
---|
[610c11] | 46 | */
|
---|
| 47 | ManyBodyPotential_Tersoff(
|
---|
[775dd1a] | 48 | const ParticleTypes_t &_ParticleTypes
|
---|
[e7579e] | 49 | );
|
---|
| 50 |
|
---|
| 51 | /** Constructor for class ManyBodyPotential_Tersoff.
|
---|
| 52 | *
|
---|
[ffc368] | 53 | * @param _R offset for cutoff
|
---|
| 54 | * @param _S halfwidth for cutoff relative to \a _R
|
---|
[e7579e] | 55 | * @param A
|
---|
| 56 | * @param B
|
---|
[ffc368] | 57 | * @param lambda
|
---|
| 58 | * @param mu
|
---|
[e7579e] | 59 | * @param lambda3
|
---|
| 60 | * @param alpha
|
---|
| 61 | * @param beta
|
---|
[ffc368] | 62 | * @param chi
|
---|
| 63 | * @param omega
|
---|
[e7579e] | 64 | * @param n
|
---|
| 65 | * @param c
|
---|
| 66 | * @param d
|
---|
| 67 | * @param h
|
---|
| 68 | * @param _triplefunction function that returns a list of triples (i.e. the
|
---|
| 69 | * two remaining distances) to a given pair of points (contained as
|
---|
| 70 | * indices within the argument)
|
---|
| 71 | */
|
---|
| 72 | ManyBodyPotential_Tersoff(
|
---|
[ed2551] | 73 | const ParticleTypes_t &_ParticleTypes,
|
---|
[ffc368] | 74 | const double &_R,
|
---|
| 75 | const double &_S,
|
---|
| 76 | const double &_A,
|
---|
| 77 | const double &_B,
|
---|
| 78 | const double &_lambda,
|
---|
| 79 | const double &_mu,
|
---|
| 80 | const double &_lambda3,
|
---|
| 81 | const double &_alpha,
|
---|
| 82 | const double &_beta,
|
---|
| 83 | const double &_chi,
|
---|
| 84 | const double &_omega,
|
---|
| 85 | const double &_n,
|
---|
| 86 | const double &_c,
|
---|
| 87 | const double &_d,
|
---|
[b15ae7] | 88 | const double &_h);
|
---|
[e7579e] | 89 |
|
---|
[610c11] | 90 | /** Destructor of class ManyBodyPotential_Tersoff.
|
---|
| 91 | *
|
---|
| 92 | */
|
---|
| 93 | virtual ~ManyBodyPotential_Tersoff() {}
|
---|
| 94 |
|
---|
| 95 | /** Evaluates the Tersoff potential for the given arguments.
|
---|
| 96 | *
|
---|
| 97 | * @param arguments single distance
|
---|
| 98 | * @return value of the potential function
|
---|
| 99 | */
|
---|
[4f82f8] | 100 | results_t operator()(const arguments_t &arguments) const;
|
---|
[610c11] | 101 |
|
---|
| 102 | /** Evaluates the derivative of the Tersoff potential with respect to the
|
---|
| 103 | * input variables.
|
---|
| 104 | *
|
---|
| 105 | * @param arguments single distance
|
---|
| 106 | * @return vector with components of the derivative
|
---|
| 107 | */
|
---|
| 108 | derivative_components_t derivative(const arguments_t &arguments) const;
|
---|
| 109 |
|
---|
[3ccea3] | 110 | /** Evaluates the derivative of the function with the given \a arguments
|
---|
| 111 | * with respect to a specific parameter indicated by \a index.
|
---|
| 112 | *
|
---|
| 113 | * \param arguments set of arguments as input variables to the function
|
---|
| 114 | * \param index derivative of which parameter
|
---|
| 115 | * \return result vector containing the derivative with respect to the given
|
---|
| 116 | * input
|
---|
| 117 | */
|
---|
[e7579e] | 118 | results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
|
---|
| 119 |
|
---|
[6efcae] | 120 | /** Return the token name of this specific potential.
|
---|
[67cd3a] | 121 | *
|
---|
[6efcae] | 122 | * \return token name of the potential
|
---|
[67cd3a] | 123 | */
|
---|
[ed2551] | 124 | const std::string& getToken() const
|
---|
| 125 | { return potential_token; }
|
---|
| 126 |
|
---|
| 127 | /** Returns a vector of parameter names.
|
---|
| 128 | *
|
---|
| 129 | * This is required from the specific implementation
|
---|
| 130 | *
|
---|
| 131 | * \return vector of strings containing parameter names
|
---|
| 132 | */
|
---|
| 133 | const ParameterNames_t& getParameterNames() const
|
---|
| 134 | { return ParameterNames; }
|
---|
[67cd3a] | 135 |
|
---|
[d03292] | 136 | /** States whether lower and upper boundaries should be used to constraint
|
---|
| 137 | * the parameter search for this function model.
|
---|
| 138 | *
|
---|
| 139 | * \return true - constraints should be used, false - else
|
---|
| 140 | */
|
---|
| 141 | bool isBoxConstraint() const {
|
---|
| 142 | return true;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | /** Returns a vector which are the lower boundaries for each parameter_t
|
---|
| 146 | * of this FunctionModel.
|
---|
| 147 | *
|
---|
| 148 | * \return vector of parameter_t resembling lowest allowed values
|
---|
| 149 | */
|
---|
| 150 | parameters_t getLowerBoxConstraints() const {
|
---|
| 151 | parameters_t lowerbound(getParameterDimension(), -std::numeric_limits<double>::max());
|
---|
| 152 | // lowerbound[R] = 0.;
|
---|
| 153 | // lowerbound[S] = 0.;
|
---|
| 154 | // lowerbound[lambda3] = 0.;
|
---|
| 155 | // lowerbound[alpha] = 0.;
|
---|
| 156 | lowerbound[beta] = std::numeric_limits<double>::min();
|
---|
| 157 | lowerbound[n] = std::numeric_limits<double>::min();
|
---|
| 158 | lowerbound[c] = std::numeric_limits<double>::min();
|
---|
| 159 | lowerbound[d] = std::numeric_limits<double>::min();
|
---|
| 160 | return lowerbound;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | /** Returns a vector which are the upper boundaries for each parameter_t
|
---|
| 164 | * of this FunctionModel.
|
---|
| 165 | *
|
---|
| 166 | * \return vector of parameter_t resembling highest allowed values
|
---|
| 167 | */
|
---|
| 168 | parameters_t getUpperBoxConstraints() const {
|
---|
| 169 | return parameters_t(getParameterDimension(), std::numeric_limits<double>::max());
|
---|
| 170 | }
|
---|
| 171 |
|
---|
[7b019a] | 172 | /** Returns a bound function to be used with TrainingData, extracting distances
|
---|
| 173 | * from a Fragment.
|
---|
| 174 | *
|
---|
| 175 | * \return bound function extracting distances from a fragment
|
---|
| 176 | */
|
---|
[da2d5c] | 177 | FunctionModel::extractor_t getFragmentSpecificExtractor() const;
|
---|
[7b019a] | 178 |
|
---|
[775dd1a] | 179 | /** Sets the magic triple function that we use for getting angle distances.
|
---|
| 180 | *
|
---|
| 181 | * @param _triplefunction function that returns a list of triples (i.e. the
|
---|
| 182 | * two remaining distances) to a given pair of points (contained as
|
---|
| 183 | * indices within the argument)
|
---|
| 184 | */
|
---|
[e36ba2] | 185 | void setTriplefunction(triplefunction_t &_triplefunction)
|
---|
| 186 | { triplefunction = _triplefunction; }
|
---|
[775dd1a] | 187 |
|
---|
[e7579e] | 188 | private:
|
---|
| 189 | /** Prohibit private default constructor.
|
---|
| 190 | *
|
---|
| 191 | * We essentially need the triplefunction, hence without this function cannot
|
---|
| 192 | * be.
|
---|
| 193 | */
|
---|
| 194 | ManyBodyPotential_Tersoff();
|
---|
[3ccea3] | 195 |
|
---|
[610c11] | 196 | private:
|
---|
| 197 | /** This function represents the cutoff \f$ f_C \f$.
|
---|
| 198 | *
|
---|
| 199 | * @param distance variable of the function
|
---|
| 200 | * @return a value in [0,1].
|
---|
| 201 | */
|
---|
| 202 | result_t function_cutoff(
|
---|
| 203 | const double &distance
|
---|
| 204 | ) const;
|
---|
| 205 | /** This function has the exponential feature from the Morse potential.
|
---|
| 206 | *
|
---|
| 207 | * @param prefactor prefactor parameter to exp function
|
---|
| 208 | * @param lambda scale parameter of exp function's argument
|
---|
[ffc368] | 209 | * @param distance variable of the function
|
---|
[610c11] | 210 | * @return
|
---|
| 211 | */
|
---|
| 212 | result_t function_smoother(
|
---|
| 213 | const double &prefactor,
|
---|
[ffc368] | 214 | const double &lambda,
|
---|
| 215 | const double &distance
|
---|
| 216 | ) const;
|
---|
[610c11] | 217 |
|
---|
| 218 | /** This function represents \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$.
|
---|
| 219 | *
|
---|
| 220 | * @param alpha prefactor to eta function
|
---|
| 221 | * @param r_ij distance argument
|
---|
[ffc368] | 222 | * @param eta result value of eta or zeta
|
---|
[610c11] | 223 | * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
|
---|
| 224 | */
|
---|
| 225 | result_t function_prefactor(
|
---|
| 226 | const double &alpha,
|
---|
[ffc368] | 227 | const double &eta
|
---|
[610c11] | 228 | ) const;
|
---|
| 229 |
|
---|
| 230 | result_t
|
---|
| 231 | function_eta(
|
---|
| 232 | const argument_t &r_ij
|
---|
| 233 | ) const;
|
---|
| 234 |
|
---|
| 235 | result_t
|
---|
| 236 | function_zeta(
|
---|
| 237 | const argument_t &r_ij
|
---|
| 238 | ) const;
|
---|
| 239 |
|
---|
[f904d5] | 240 | result_t
|
---|
| 241 | function_theta(
|
---|
| 242 | const double &r_ij,
|
---|
| 243 | const double &r_ik,
|
---|
| 244 | const double &r_jk
|
---|
| 245 | ) const;
|
---|
| 246 |
|
---|
[610c11] | 247 | result_t
|
---|
| 248 | function_angle(
|
---|
| 249 | const double &r_ij,
|
---|
| 250 | const double &r_ik,
|
---|
| 251 | const double &r_jk
|
---|
| 252 | ) const;
|
---|
| 253 |
|
---|
[e7579e] | 254 | private:
|
---|
[ca8d82] | 255 | result_t
|
---|
| 256 | function_derivative_c(
|
---|
| 257 | const argument_t &r_ij
|
---|
| 258 | ) const;
|
---|
| 259 |
|
---|
| 260 | result_t
|
---|
| 261 | function_derivative_d(
|
---|
| 262 | const argument_t &r_ij
|
---|
| 263 | ) const;
|
---|
| 264 |
|
---|
| 265 | result_t
|
---|
| 266 | function_derivative_h(
|
---|
| 267 | const argument_t &r_ij
|
---|
| 268 | ) const;
|
---|
| 269 |
|
---|
| 270 | public:
|
---|
[e7579e] | 271 | enum parameter_enum_t {
|
---|
[752dc7] | 272 | A,
|
---|
| 273 | B,
|
---|
| 274 | lambda,
|
---|
| 275 | mu,
|
---|
| 276 | beta,
|
---|
| 277 | n,
|
---|
| 278 | c,
|
---|
| 279 | d,
|
---|
| 280 | h,
|
---|
| 281 | // R,
|
---|
| 282 | // S,
|
---|
| 283 | // lambda3,
|
---|
| 284 | // alpha,
|
---|
| 285 | // chi,
|
---|
| 286 | // omega,
|
---|
[e7579e] | 287 | MAXPARAMS
|
---|
| 288 | };
|
---|
[f48ad3] | 289 |
|
---|
| 290 | private:
|
---|
[e7579e] | 291 | //!> parameter vector with parameters as in enum parameter_enum_t
|
---|
| 292 | parameters_t params;
|
---|
| 293 |
|
---|
[752dc7] | 294 | public:
|
---|
[990a62] | 295 | // some internal parameters which are fixed
|
---|
[752dc7] | 296 | const double R;
|
---|
| 297 | const double S;
|
---|
[990a62] | 298 | const double lambda3;
|
---|
| 299 | const double alpha;
|
---|
| 300 | const double chi;
|
---|
| 301 | const double omega;
|
---|
| 302 |
|
---|
[e7579e] | 303 | public:
|
---|
| 304 | /** Setter for parameters as required by FunctionModel interface.
|
---|
| 305 | *
|
---|
| 306 | * \param _params given set of parameters
|
---|
| 307 | */
|
---|
[086070] | 308 | void setParameters(const parameters_t &_params);
|
---|
[e7579e] | 309 |
|
---|
| 310 | /** Getter for parameters as required by FunctionModel interface.
|
---|
| 311 | *
|
---|
| 312 | * \return set of parameters
|
---|
| 313 | */
|
---|
| 314 | parameters_t getParameters() const
|
---|
| 315 | {
|
---|
| 316 | return params;
|
---|
| 317 | }
|
---|
| 318 |
|
---|
[d52819] | 319 | /** Sets the parameter randomly within the sensible range of each parameter.
|
---|
| 320 | *
|
---|
| 321 | * \param data container with training data for guesstimating range
|
---|
| 322 | */
|
---|
| 323 | void setParametersToRandomInitialValues(const TrainingData &data);
|
---|
| 324 |
|
---|
[e7579e] | 325 | /** Getter for the number of parameters of this model function.
|
---|
| 326 | *
|
---|
| 327 | * \return number of parameters
|
---|
| 328 | */
|
---|
| 329 | size_t getParameterDimension() const
|
---|
| 330 | {
|
---|
| 331 | return MAXPARAMS;
|
---|
| 332 | }
|
---|
| 333 |
|
---|
[610c11] | 334 | private:
|
---|
| 335 | //!> bound function that obtains the triples for the internal coordinationb summation.
|
---|
[775dd1a] | 336 | boost::function< std::vector< arguments_t >(const argument_t &, const double)> triplefunction;
|
---|
[ed2551] | 337 |
|
---|
| 338 | //!> static definitions of the parameter name for this potential
|
---|
| 339 | static const ParameterNames_t ParameterNames;
|
---|
| 340 |
|
---|
| 341 | //!> static token of this potential type
|
---|
| 342 | static const std::string potential_token;
|
---|
[610c11] | 343 | };
|
---|
| 344 |
|
---|
| 345 |
|
---|
| 346 | #endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
|
---|