| 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 |
|
|---|
| 19 | #include "CodePatterns/Assert.hpp"
|
|---|
| 20 |
|
|---|
| 21 | #include "Potentials/EmpiricalPotential.hpp"
|
|---|
| 22 | #include "FunctionApproximation/FunctionModel.hpp"
|
|---|
| 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 : virtual public EmpiricalPotential, virtual public FunctionModel
|
|---|
| 32 | {
|
|---|
| 33 | //!> grant unit test access to internal parts
|
|---|
| 34 | friend class ManyBodyPotential_TersoffTest;
|
|---|
| 35 | // some repeated typedefs to avoid ambiguities
|
|---|
| 36 | typedef FunctionModel::arguments_t arguments_t;
|
|---|
| 37 | typedef FunctionModel::result_t result_t;
|
|---|
| 38 | typedef FunctionModel::results_t results_t;
|
|---|
| 39 | typedef EmpiricalPotential::derivative_components_t derivative_components_t;
|
|---|
| 40 | typedef FunctionModel::parameters_t parameters_t;
|
|---|
| 41 | public:
|
|---|
| 42 | /** Constructor for class ManyBodyPotential_Tersoff.
|
|---|
| 43 | *
|
|---|
| 44 | * @param _triplefunction function that returns a list of triples (i.e. the
|
|---|
| 45 | * two remaining distances) to a given pair of points (contained as
|
|---|
| 46 | * indices within the argument)
|
|---|
| 47 | */
|
|---|
| 48 | ManyBodyPotential_Tersoff(
|
|---|
| 49 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction
|
|---|
| 50 | );
|
|---|
| 51 |
|
|---|
| 52 | /** Constructor for class ManyBodyPotential_Tersoff.
|
|---|
| 53 | *
|
|---|
| 54 | * @param _R offset for cutoff
|
|---|
| 55 | * @param _S halfwidth for cutoff relative to \a _R
|
|---|
| 56 | * @param A
|
|---|
| 57 | * @param B
|
|---|
| 58 | * @param lambda
|
|---|
| 59 | * @param mu
|
|---|
| 60 | * @param lambda3
|
|---|
| 61 | * @param alpha
|
|---|
| 62 | * @param beta
|
|---|
| 63 | * @param chi
|
|---|
| 64 | * @param omega
|
|---|
| 65 | * @param n
|
|---|
| 66 | * @param c
|
|---|
| 67 | * @param d
|
|---|
| 68 | * @param h
|
|---|
| 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 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,
|
|---|
| 89 | boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction);
|
|---|
| 90 |
|
|---|
| 91 | /** Destructor of class ManyBodyPotential_Tersoff.
|
|---|
| 92 | *
|
|---|
| 93 | */
|
|---|
| 94 | virtual ~ManyBodyPotential_Tersoff() {}
|
|---|
| 95 |
|
|---|
| 96 | /** Evaluates the Tersoff potential for the given arguments.
|
|---|
| 97 | *
|
|---|
| 98 | * @param arguments single distance
|
|---|
| 99 | * @return value of the potential function
|
|---|
| 100 | */
|
|---|
| 101 | results_t operator()(const arguments_t &arguments) const;
|
|---|
| 102 |
|
|---|
| 103 | /** Evaluates the derivative of the Tersoff potential with respect to the
|
|---|
| 104 | * input variables.
|
|---|
| 105 | *
|
|---|
| 106 | * @param arguments single distance
|
|---|
| 107 | * @return vector with components of the derivative
|
|---|
| 108 | */
|
|---|
| 109 | derivative_components_t derivative(const arguments_t &arguments) const;
|
|---|
| 110 |
|
|---|
| 111 | /** Evaluates the derivative of the function with the given \a arguments
|
|---|
| 112 | * with respect to a specific parameter indicated by \a index.
|
|---|
| 113 | *
|
|---|
| 114 | * \param arguments set of arguments as input variables to the function
|
|---|
| 115 | * \param index derivative of which parameter
|
|---|
| 116 | * \return result vector containing the derivative with respect to the given
|
|---|
| 117 | * input
|
|---|
| 118 | */
|
|---|
| 119 | results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
|
|---|
| 120 |
|
|---|
| 121 | private:
|
|---|
| 122 | /** Prohibit private default constructor.
|
|---|
| 123 | *
|
|---|
| 124 | * We essentially need the triplefunction, hence without this function cannot
|
|---|
| 125 | * be.
|
|---|
| 126 | */
|
|---|
| 127 | ManyBodyPotential_Tersoff();
|
|---|
| 128 |
|
|---|
| 129 | private:
|
|---|
| 130 | /** This function represents the cutoff \f$ f_C \f$.
|
|---|
| 131 | *
|
|---|
| 132 | * @param distance variable of the function
|
|---|
| 133 | * @return a value in [0,1].
|
|---|
| 134 | */
|
|---|
| 135 | result_t function_cutoff(
|
|---|
| 136 | const double &distance
|
|---|
| 137 | ) const;
|
|---|
| 138 | /** This function has the exponential feature from the Morse potential.
|
|---|
| 139 | *
|
|---|
| 140 | * @param prefactor prefactor parameter to exp function
|
|---|
| 141 | * @param lambda scale parameter of exp function's argument
|
|---|
| 142 | * @param distance variable of the function
|
|---|
| 143 | * @return
|
|---|
| 144 | */
|
|---|
| 145 | result_t function_smoother(
|
|---|
| 146 | const double &prefactor,
|
|---|
| 147 | const double &lambda,
|
|---|
| 148 | const double &distance
|
|---|
| 149 | ) const;
|
|---|
| 150 |
|
|---|
| 151 | /** This function represents \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$.
|
|---|
| 152 | *
|
|---|
| 153 | * @param alpha prefactor to eta function
|
|---|
| 154 | * @param r_ij distance argument
|
|---|
| 155 | * @param eta result value of eta or zeta
|
|---|
| 156 | * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
|
|---|
| 157 | */
|
|---|
| 158 | result_t function_prefactor(
|
|---|
| 159 | const double &alpha,
|
|---|
| 160 | const double &eta
|
|---|
| 161 | ) const;
|
|---|
| 162 |
|
|---|
| 163 | result_t
|
|---|
| 164 | function_eta(
|
|---|
| 165 | const argument_t &r_ij
|
|---|
| 166 | ) const;
|
|---|
| 167 |
|
|---|
| 168 | result_t
|
|---|
| 169 | function_zeta(
|
|---|
| 170 | const argument_t &r_ij
|
|---|
| 171 | ) const;
|
|---|
| 172 |
|
|---|
| 173 | result_t
|
|---|
| 174 | function_angle(
|
|---|
| 175 | const double &r_ij,
|
|---|
| 176 | const double &r_ik,
|
|---|
| 177 | const double &r_jk
|
|---|
| 178 | ) const;
|
|---|
| 179 |
|
|---|
| 180 | private:
|
|---|
| 181 | enum parameter_enum_t {
|
|---|
| 182 | A,
|
|---|
| 183 | B,
|
|---|
| 184 | lambda,
|
|---|
| 185 | mu,
|
|---|
| 186 | beta,
|
|---|
| 187 | n,
|
|---|
| 188 | c,
|
|---|
| 189 | d,
|
|---|
| 190 | h,
|
|---|
| 191 | // R,
|
|---|
| 192 | // S,
|
|---|
| 193 | // lambda3,
|
|---|
| 194 | // alpha,
|
|---|
| 195 | // chi,
|
|---|
| 196 | // omega,
|
|---|
| 197 | MAXPARAMS
|
|---|
| 198 | };
|
|---|
| 199 | //!> parameter vector with parameters as in enum parameter_enum_t
|
|---|
| 200 | parameters_t params;
|
|---|
| 201 |
|
|---|
| 202 | public:
|
|---|
| 203 | // some internal parameters which are fixed
|
|---|
| 204 | const double R;
|
|---|
| 205 | const double S;
|
|---|
| 206 | const double lambda3;
|
|---|
| 207 | const double alpha;
|
|---|
| 208 | const double chi;
|
|---|
| 209 | const double omega;
|
|---|
| 210 |
|
|---|
| 211 | public:
|
|---|
| 212 | /** Setter for parameters as required by FunctionModel interface.
|
|---|
| 213 | *
|
|---|
| 214 | * \param _params given set of parameters
|
|---|
| 215 | */
|
|---|
| 216 | void setParameters(const parameters_t &_params)
|
|---|
| 217 | {
|
|---|
| 218 | ASSERT( _params.size() == getParameterDimension(),
|
|---|
| 219 | "ManyBodyPotential_Tersoff::setParameters() - we need exactly "
|
|---|
| 220 | +toString(getParameterDimension())+" parameters.");
|
|---|
| 221 | params = _params;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | /** Getter for parameters as required by FunctionModel interface.
|
|---|
| 225 | *
|
|---|
| 226 | * \return set of parameters
|
|---|
| 227 | */
|
|---|
| 228 | parameters_t getParameters() const
|
|---|
| 229 | {
|
|---|
| 230 | return params;
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | /** Getter for the number of parameters of this model function.
|
|---|
| 234 | *
|
|---|
| 235 | * \return number of parameters
|
|---|
| 236 | */
|
|---|
| 237 | size_t getParameterDimension() const
|
|---|
| 238 | {
|
|---|
| 239 | return MAXPARAMS;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | private:
|
|---|
| 243 | //!> bound function that obtains the triples for the internal coordinationb summation.
|
|---|
| 244 | const boost::function< std::vector< arguments_t >(const argument_t &, const double)> &triplefunction;
|
|---|
| 245 | };
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | #endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
|
|---|