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