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