[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 | #include "FunctionApproximation/FunctionModel.hpp"
|
---|
| 22 |
|
---|
[610c11] | 23 | /** This class is the implementation of the Tersoff potential function.
|
---|
| 24 | *
|
---|
| 25 | * \note The arguments_t argument list is here in the following order:
|
---|
[dd966f] | 26 | * -# first \f$ r_{ij} \f$,
|
---|
| 27 | * -# then all \f$ r_{ik} \f$ that are within the cutoff, i.e. \f$ r_{ik} < R + D\f$
|
---|
[610c11] | 28 | *
|
---|
| 29 | */
|
---|
[3ccea3] | 30 | class ManyBodyPotential_Tersoff : virtual public EmpiricalPotential, virtual public FunctionModel
|
---|
[610c11] | 31 | {
|
---|
[ffc368] | 32 | //!> grant unit test access to internal parts
|
---|
| 33 | friend class ManyBodyPotential_TersoffTest;
|
---|
[3ccea3] | 34 | // some repeated typedefs to avoid ambiguities
|
---|
| 35 | typedef FunctionModel::arguments_t arguments_t;
|
---|
| 36 | typedef FunctionModel::result_t result_t;
|
---|
| 37 | typedef FunctionModel::results_t results_t;
|
---|
| 38 | typedef EmpiricalPotential::derivative_components_t derivative_components_t;
|
---|
[e7579e] | 39 | typedef FunctionModel::parameters_t parameters_t;
|
---|
[610c11] | 40 | public:
|
---|
| 41 | /** Constructor for class ManyBodyPotential_Tersoff.
|
---|
| 42 | *
|
---|
| 43 | * @param _triplefunction function that returns a list of triples (i.e. the
|
---|
| 44 | * two remaining distances) to a given pair of points (contained as
|
---|
| 45 | * indices within the argument)
|
---|
| 46 | */
|
---|
| 47 | ManyBodyPotential_Tersoff(
|
---|
[e7579e] | 48 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction
|
---|
| 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
|
---|
[56c5de4] | 68 | * @param offset
|
---|
[e7579e] | 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(
|
---|
[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,
|
---|
| 88 | const double &_h,
|
---|
[56c5de4] | 89 | const double &_offset,
|
---|
[e7579e] | 90 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction);
|
---|
| 91 |
|
---|
[610c11] | 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 | */
|
---|
[4f82f8] | 102 | results_t operator()(const arguments_t &arguments) const;
|
---|
[610c11] | 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 |
|
---|
[3ccea3] | 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 | */
|
---|
[e7579e] | 120 | results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
|
---|
| 121 |
|
---|
[d03292] | 122 | /** States whether lower and upper boundaries should be used to constraint
|
---|
| 123 | * the parameter search for this function model.
|
---|
| 124 | *
|
---|
| 125 | * \return true - constraints should be used, false - else
|
---|
| 126 | */
|
---|
| 127 | bool isBoxConstraint() const {
|
---|
| 128 | return true;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /** Returns a vector which are the lower boundaries for each parameter_t
|
---|
| 132 | * of this FunctionModel.
|
---|
| 133 | *
|
---|
| 134 | * \return vector of parameter_t resembling lowest allowed values
|
---|
| 135 | */
|
---|
| 136 | parameters_t getLowerBoxConstraints() const {
|
---|
| 137 | parameters_t lowerbound(getParameterDimension(), -std::numeric_limits<double>::max());
|
---|
| 138 | // lowerbound[R] = 0.;
|
---|
| 139 | // lowerbound[S] = 0.;
|
---|
| 140 | // lowerbound[lambda3] = 0.;
|
---|
| 141 | // lowerbound[alpha] = 0.;
|
---|
| 142 | lowerbound[beta] = std::numeric_limits<double>::min();
|
---|
| 143 | lowerbound[n] = std::numeric_limits<double>::min();
|
---|
| 144 | lowerbound[c] = std::numeric_limits<double>::min();
|
---|
| 145 | lowerbound[d] = std::numeric_limits<double>::min();
|
---|
| 146 | return lowerbound;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | /** Returns a vector which are the upper boundaries for each parameter_t
|
---|
| 150 | * of this FunctionModel.
|
---|
| 151 | *
|
---|
| 152 | * \return vector of parameter_t resembling highest allowed values
|
---|
| 153 | */
|
---|
| 154 | parameters_t getUpperBoxConstraints() const {
|
---|
| 155 | return parameters_t(getParameterDimension(), std::numeric_limits<double>::max());
|
---|
| 156 | }
|
---|
| 157 |
|
---|
[e7579e] | 158 | private:
|
---|
| 159 | /** Prohibit private default constructor.
|
---|
| 160 | *
|
---|
| 161 | * We essentially need the triplefunction, hence without this function cannot
|
---|
| 162 | * be.
|
---|
| 163 | */
|
---|
| 164 | ManyBodyPotential_Tersoff();
|
---|
[3ccea3] | 165 |
|
---|
[610c11] | 166 | private:
|
---|
| 167 | /** This function represents the cutoff \f$ f_C \f$.
|
---|
| 168 | *
|
---|
| 169 | * @param distance variable of the function
|
---|
| 170 | * @return a value in [0,1].
|
---|
| 171 | */
|
---|
| 172 | result_t function_cutoff(
|
---|
| 173 | const double &distance
|
---|
| 174 | ) const;
|
---|
| 175 | /** This function has the exponential feature from the Morse potential.
|
---|
| 176 | *
|
---|
| 177 | * @param prefactor prefactor parameter to exp function
|
---|
| 178 | * @param lambda scale parameter of exp function's argument
|
---|
[ffc368] | 179 | * @param distance variable of the function
|
---|
[610c11] | 180 | * @return
|
---|
| 181 | */
|
---|
| 182 | result_t function_smoother(
|
---|
| 183 | const double &prefactor,
|
---|
[ffc368] | 184 | const double &lambda,
|
---|
| 185 | const double &distance
|
---|
| 186 | ) const;
|
---|
[610c11] | 187 |
|
---|
| 188 | /** This function represents \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$.
|
---|
| 189 | *
|
---|
| 190 | * @param alpha prefactor to eta function
|
---|
| 191 | * @param r_ij distance argument
|
---|
[ffc368] | 192 | * @param eta result value of eta or zeta
|
---|
[610c11] | 193 | * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
|
---|
| 194 | */
|
---|
| 195 | result_t function_prefactor(
|
---|
| 196 | const double &alpha,
|
---|
[ffc368] | 197 | const double &eta
|
---|
[610c11] | 198 | ) const;
|
---|
| 199 |
|
---|
| 200 | result_t
|
---|
| 201 | function_eta(
|
---|
| 202 | const argument_t &r_ij
|
---|
| 203 | ) const;
|
---|
| 204 |
|
---|
| 205 | result_t
|
---|
| 206 | function_zeta(
|
---|
| 207 | const argument_t &r_ij
|
---|
| 208 | ) const;
|
---|
| 209 |
|
---|
[f904d5] | 210 | result_t
|
---|
| 211 | function_theta(
|
---|
| 212 | const double &r_ij,
|
---|
| 213 | const double &r_ik,
|
---|
| 214 | const double &r_jk
|
---|
| 215 | ) const;
|
---|
| 216 |
|
---|
[610c11] | 217 | result_t
|
---|
| 218 | function_angle(
|
---|
| 219 | const double &r_ij,
|
---|
| 220 | const double &r_ik,
|
---|
| 221 | const double &r_jk
|
---|
| 222 | ) const;
|
---|
| 223 |
|
---|
[e7579e] | 224 | private:
|
---|
[ca8d82] | 225 | result_t
|
---|
| 226 | function_derivative_c(
|
---|
| 227 | const argument_t &r_ij
|
---|
| 228 | ) const;
|
---|
| 229 |
|
---|
| 230 | result_t
|
---|
| 231 | function_derivative_d(
|
---|
| 232 | const argument_t &r_ij
|
---|
| 233 | ) const;
|
---|
| 234 |
|
---|
| 235 | result_t
|
---|
| 236 | function_derivative_h(
|
---|
| 237 | const argument_t &r_ij
|
---|
| 238 | ) const;
|
---|
| 239 |
|
---|
| 240 | public:
|
---|
[e7579e] | 241 | enum parameter_enum_t {
|
---|
[752dc7] | 242 | A,
|
---|
| 243 | B,
|
---|
| 244 | lambda,
|
---|
| 245 | mu,
|
---|
| 246 | beta,
|
---|
| 247 | n,
|
---|
| 248 | c,
|
---|
| 249 | d,
|
---|
| 250 | h,
|
---|
[56c5de4] | 251 | offset,
|
---|
[752dc7] | 252 | // R,
|
---|
| 253 | // S,
|
---|
| 254 | // lambda3,
|
---|
| 255 | // alpha,
|
---|
| 256 | // chi,
|
---|
| 257 | // omega,
|
---|
[e7579e] | 258 | MAXPARAMS
|
---|
| 259 | };
|
---|
[f48ad3] | 260 |
|
---|
| 261 | private:
|
---|
[e7579e] | 262 | //!> parameter vector with parameters as in enum parameter_enum_t
|
---|
| 263 | parameters_t params;
|
---|
| 264 |
|
---|
[752dc7] | 265 | public:
|
---|
[990a62] | 266 | // some internal parameters which are fixed
|
---|
[752dc7] | 267 | const double R;
|
---|
| 268 | const double S;
|
---|
[990a62] | 269 | const double lambda3;
|
---|
| 270 | const double alpha;
|
---|
| 271 | const double chi;
|
---|
| 272 | const double omega;
|
---|
| 273 |
|
---|
[e7579e] | 274 | public:
|
---|
| 275 | /** Setter for parameters as required by FunctionModel interface.
|
---|
| 276 | *
|
---|
| 277 | * \param _params given set of parameters
|
---|
| 278 | */
|
---|
[086070] | 279 | void setParameters(const parameters_t &_params);
|
---|
[e7579e] | 280 |
|
---|
| 281 | /** Getter for parameters as required by FunctionModel interface.
|
---|
| 282 | *
|
---|
| 283 | * \return set of parameters
|
---|
| 284 | */
|
---|
| 285 | parameters_t getParameters() const
|
---|
| 286 | {
|
---|
| 287 | return params;
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | /** Getter for the number of parameters of this model function.
|
---|
| 291 | *
|
---|
| 292 | * \return number of parameters
|
---|
| 293 | */
|
---|
| 294 | size_t getParameterDimension() const
|
---|
| 295 | {
|
---|
| 296 | return MAXPARAMS;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
[610c11] | 299 | private:
|
---|
| 300 | //!> bound function that obtains the triples for the internal coordinationb summation.
|
---|
| 301 | const boost::function< std::vector< arguments_t >(const argument_t &, const double)> &triplefunction;
|
---|
| 302 | };
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 | #endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
|
---|