[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"
|
---|
[ed2551] | 21 | #include "Potentials/SerializablePotential.hpp"
|
---|
[4f82f8] | 22 | #include "FunctionApproximation/FunctionModel.hpp"
|
---|
| 23 |
|
---|
[d52819] | 24 | class TrainingData;
|
---|
| 25 |
|
---|
[610c11] | 26 | /** This class is the implementation of the Tersoff potential function.
|
---|
| 27 | *
|
---|
| 28 | * \note The arguments_t argument list is here in the following order:
|
---|
[dd966f] | 29 | * -# first \f$ r_{ij} \f$,
|
---|
| 30 | * -# then all \f$ r_{ik} \f$ that are within the cutoff, i.e. \f$ r_{ik} < R + D\f$
|
---|
[610c11] | 31 | *
|
---|
| 32 | */
|
---|
[ed2551] | 33 | class ManyBodyPotential_Tersoff :
|
---|
| 34 | virtual public EmpiricalPotential,
|
---|
| 35 | virtual public FunctionModel,
|
---|
| 36 | virtual public SerializablePotential
|
---|
[610c11] | 37 | {
|
---|
[ffc368] | 38 | //!> grant unit test access to internal parts
|
---|
| 39 | friend class ManyBodyPotential_TersoffTest;
|
---|
[3ccea3] | 40 | // some repeated typedefs to avoid ambiguities
|
---|
| 41 | typedef FunctionModel::arguments_t arguments_t;
|
---|
| 42 | typedef FunctionModel::result_t result_t;
|
---|
| 43 | typedef FunctionModel::results_t results_t;
|
---|
| 44 | typedef EmpiricalPotential::derivative_components_t derivative_components_t;
|
---|
[e7579e] | 45 | typedef FunctionModel::parameters_t parameters_t;
|
---|
[610c11] | 46 | public:
|
---|
| 47 | /** Constructor for class ManyBodyPotential_Tersoff.
|
---|
| 48 | *
|
---|
| 49 | * @param _triplefunction function that returns a list of triples (i.e. the
|
---|
| 50 | * two remaining distances) to a given pair of points (contained as
|
---|
| 51 | * indices within the argument)
|
---|
| 52 | */
|
---|
| 53 | ManyBodyPotential_Tersoff(
|
---|
[ed2551] | 54 | const ParticleTypes_t &_ParticleTypes,
|
---|
[e7579e] | 55 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction
|
---|
| 56 | );
|
---|
| 57 |
|
---|
| 58 | /** Constructor for class ManyBodyPotential_Tersoff.
|
---|
| 59 | *
|
---|
[ffc368] | 60 | * @param _R offset for cutoff
|
---|
| 61 | * @param _S halfwidth for cutoff relative to \a _R
|
---|
[e7579e] | 62 | * @param A
|
---|
| 63 | * @param B
|
---|
[ffc368] | 64 | * @param lambda
|
---|
| 65 | * @param mu
|
---|
[e7579e] | 66 | * @param lambda3
|
---|
| 67 | * @param alpha
|
---|
| 68 | * @param beta
|
---|
[ffc368] | 69 | * @param chi
|
---|
| 70 | * @param omega
|
---|
[e7579e] | 71 | * @param n
|
---|
| 72 | * @param c
|
---|
| 73 | * @param d
|
---|
| 74 | * @param h
|
---|
[56c5de4] | 75 | * @param offset
|
---|
[e7579e] | 76 | * @param _triplefunction function that returns a list of triples (i.e. the
|
---|
| 77 | * two remaining distances) to a given pair of points (contained as
|
---|
| 78 | * indices within the argument)
|
---|
| 79 | */
|
---|
| 80 | ManyBodyPotential_Tersoff(
|
---|
[ed2551] | 81 | const ParticleTypes_t &_ParticleTypes,
|
---|
[ffc368] | 82 | const double &_R,
|
---|
| 83 | const double &_S,
|
---|
| 84 | const double &_A,
|
---|
| 85 | const double &_B,
|
---|
| 86 | const double &_lambda,
|
---|
| 87 | const double &_mu,
|
---|
| 88 | const double &_lambda3,
|
---|
| 89 | const double &_alpha,
|
---|
| 90 | const double &_beta,
|
---|
| 91 | const double &_chi,
|
---|
| 92 | const double &_omega,
|
---|
| 93 | const double &_n,
|
---|
| 94 | const double &_c,
|
---|
| 95 | const double &_d,
|
---|
| 96 | const double &_h,
|
---|
[56c5de4] | 97 | const double &_offset,
|
---|
[e7579e] | 98 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction);
|
---|
| 99 |
|
---|
[610c11] | 100 | /** Destructor of class ManyBodyPotential_Tersoff.
|
---|
| 101 | *
|
---|
| 102 | */
|
---|
| 103 | virtual ~ManyBodyPotential_Tersoff() {}
|
---|
| 104 |
|
---|
| 105 | /** Evaluates the Tersoff potential for the given arguments.
|
---|
| 106 | *
|
---|
| 107 | * @param arguments single distance
|
---|
| 108 | * @return value of the potential function
|
---|
| 109 | */
|
---|
[4f82f8] | 110 | results_t operator()(const arguments_t &arguments) const;
|
---|
[610c11] | 111 |
|
---|
| 112 | /** Evaluates the derivative of the Tersoff potential with respect to the
|
---|
| 113 | * input variables.
|
---|
| 114 | *
|
---|
| 115 | * @param arguments single distance
|
---|
| 116 | * @return vector with components of the derivative
|
---|
| 117 | */
|
---|
| 118 | derivative_components_t derivative(const arguments_t &arguments) const;
|
---|
| 119 |
|
---|
[3ccea3] | 120 | /** Evaluates the derivative of the function with the given \a arguments
|
---|
| 121 | * with respect to a specific parameter indicated by \a index.
|
---|
| 122 | *
|
---|
| 123 | * \param arguments set of arguments as input variables to the function
|
---|
| 124 | * \param index derivative of which parameter
|
---|
| 125 | * \return result vector containing the derivative with respect to the given
|
---|
| 126 | * input
|
---|
| 127 | */
|
---|
[e7579e] | 128 | results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
|
---|
| 129 |
|
---|
[6efcae] | 130 | /** Return the token name of this specific potential.
|
---|
[67cd3a] | 131 | *
|
---|
[6efcae] | 132 | * \return token name of the potential
|
---|
[67cd3a] | 133 | */
|
---|
[ed2551] | 134 | const std::string& getToken() const
|
---|
| 135 | { return potential_token; }
|
---|
| 136 |
|
---|
| 137 | /** Returns a vector of parameter names.
|
---|
| 138 | *
|
---|
| 139 | * This is required from the specific implementation
|
---|
| 140 | *
|
---|
| 141 | * \return vector of strings containing parameter names
|
---|
| 142 | */
|
---|
| 143 | const ParameterNames_t& getParameterNames() const
|
---|
| 144 | { return ParameterNames; }
|
---|
[67cd3a] | 145 |
|
---|
[d03292] | 146 | /** States whether lower and upper boundaries should be used to constraint
|
---|
| 147 | * the parameter search for this function model.
|
---|
| 148 | *
|
---|
| 149 | * \return true - constraints should be used, false - else
|
---|
| 150 | */
|
---|
| 151 | bool isBoxConstraint() const {
|
---|
| 152 | return true;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /** Returns a vector which are the lower boundaries for each parameter_t
|
---|
| 156 | * of this FunctionModel.
|
---|
| 157 | *
|
---|
| 158 | * \return vector of parameter_t resembling lowest allowed values
|
---|
| 159 | */
|
---|
| 160 | parameters_t getLowerBoxConstraints() const {
|
---|
| 161 | parameters_t lowerbound(getParameterDimension(), -std::numeric_limits<double>::max());
|
---|
| 162 | // lowerbound[R] = 0.;
|
---|
| 163 | // lowerbound[S] = 0.;
|
---|
| 164 | // lowerbound[lambda3] = 0.;
|
---|
| 165 | // lowerbound[alpha] = 0.;
|
---|
| 166 | lowerbound[beta] = std::numeric_limits<double>::min();
|
---|
| 167 | lowerbound[n] = std::numeric_limits<double>::min();
|
---|
| 168 | lowerbound[c] = std::numeric_limits<double>::min();
|
---|
| 169 | lowerbound[d] = std::numeric_limits<double>::min();
|
---|
| 170 | return lowerbound;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | /** Returns a vector which are the upper boundaries for each parameter_t
|
---|
| 174 | * of this FunctionModel.
|
---|
| 175 | *
|
---|
| 176 | * \return vector of parameter_t resembling highest allowed values
|
---|
| 177 | */
|
---|
| 178 | parameters_t getUpperBoxConstraints() const {
|
---|
| 179 | return parameters_t(getParameterDimension(), std::numeric_limits<double>::max());
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[7b019a] | 182 | /** Returns a bound function to be used with TrainingData, extracting distances
|
---|
| 183 | * from a Fragment.
|
---|
| 184 | *
|
---|
| 185 | * \param charges vector of charges to be extracted
|
---|
| 186 | * \return bound function extracting distances from a fragment
|
---|
| 187 | */
|
---|
| 188 | FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
|
---|
| 189 |
|
---|
[e7579e] | 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();
|
---|
[3ccea3] | 197 |
|
---|
[610c11] | 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
|
---|
[ffc368] | 211 | * @param distance variable of the function
|
---|
[610c11] | 212 | * @return
|
---|
| 213 | */
|
---|
| 214 | result_t function_smoother(
|
---|
| 215 | const double &prefactor,
|
---|
[ffc368] | 216 | const double &lambda,
|
---|
| 217 | const double &distance
|
---|
| 218 | ) const;
|
---|
[610c11] | 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
|
---|
[ffc368] | 224 | * @param eta result value of eta or zeta
|
---|
[610c11] | 225 | * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
|
---|
| 226 | */
|
---|
| 227 | result_t function_prefactor(
|
---|
| 228 | const double &alpha,
|
---|
[ffc368] | 229 | const double &eta
|
---|
[610c11] | 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 |
|
---|
[f904d5] | 242 | result_t
|
---|
| 243 | function_theta(
|
---|
| 244 | const double &r_ij,
|
---|
| 245 | const double &r_ik,
|
---|
| 246 | const double &r_jk
|
---|
| 247 | ) const;
|
---|
| 248 |
|
---|
[610c11] | 249 | result_t
|
---|
| 250 | function_angle(
|
---|
| 251 | const double &r_ij,
|
---|
| 252 | const double &r_ik,
|
---|
| 253 | const double &r_jk
|
---|
| 254 | ) const;
|
---|
| 255 |
|
---|
[e7579e] | 256 | private:
|
---|
[ca8d82] | 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:
|
---|
[e7579e] | 273 | enum parameter_enum_t {
|
---|
[752dc7] | 274 | A,
|
---|
| 275 | B,
|
---|
| 276 | lambda,
|
---|
| 277 | mu,
|
---|
| 278 | beta,
|
---|
| 279 | n,
|
---|
| 280 | c,
|
---|
| 281 | d,
|
---|
| 282 | h,
|
---|
[56c5de4] | 283 | offset,
|
---|
[752dc7] | 284 | // R,
|
---|
| 285 | // S,
|
---|
| 286 | // lambda3,
|
---|
| 287 | // alpha,
|
---|
| 288 | // chi,
|
---|
| 289 | // omega,
|
---|
[e7579e] | 290 | MAXPARAMS
|
---|
| 291 | };
|
---|
[f48ad3] | 292 |
|
---|
| 293 | private:
|
---|
[e7579e] | 294 | //!> parameter vector with parameters as in enum parameter_enum_t
|
---|
| 295 | parameters_t params;
|
---|
| 296 |
|
---|
[752dc7] | 297 | public:
|
---|
[990a62] | 298 | // some internal parameters which are fixed
|
---|
[752dc7] | 299 | const double R;
|
---|
| 300 | const double S;
|
---|
[990a62] | 301 | const double lambda3;
|
---|
| 302 | const double alpha;
|
---|
| 303 | const double chi;
|
---|
| 304 | const double omega;
|
---|
| 305 |
|
---|
[e7579e] | 306 | public:
|
---|
| 307 | /** Setter for parameters as required by FunctionModel interface.
|
---|
| 308 | *
|
---|
| 309 | * \param _params given set of parameters
|
---|
| 310 | */
|
---|
[086070] | 311 | void setParameters(const parameters_t &_params);
|
---|
[e7579e] | 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 |
|
---|
[d52819] | 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 |
|
---|
[e7579e] | 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 |
|
---|
[610c11] | 337 | private:
|
---|
| 338 | //!> bound function that obtains the triples for the internal coordinationb summation.
|
---|
| 339 | const boost::function< std::vector< arguments_t >(const argument_t &, const double)> &triplefunction;
|
---|
[ed2551] | 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;
|
---|
[610c11] | 346 | };
|
---|
| 347 |
|
---|
| 348 |
|
---|
| 349 | #endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
|
---|