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_theta(
|
---|
175 | const double &r_ij,
|
---|
176 | const double &r_ik,
|
---|
177 | const double &r_jk
|
---|
178 | ) const;
|
---|
179 |
|
---|
180 | result_t
|
---|
181 | function_angle(
|
---|
182 | const double &r_ij,
|
---|
183 | const double &r_ik,
|
---|
184 | const double &r_jk
|
---|
185 | ) const;
|
---|
186 |
|
---|
187 | private:
|
---|
188 | result_t
|
---|
189 | function_derivative_c(
|
---|
190 | const argument_t &r_ij
|
---|
191 | ) const;
|
---|
192 |
|
---|
193 | result_t
|
---|
194 | function_derivative_d(
|
---|
195 | const argument_t &r_ij
|
---|
196 | ) const;
|
---|
197 |
|
---|
198 | result_t
|
---|
199 | function_derivative_h(
|
---|
200 | const argument_t &r_ij
|
---|
201 | ) const;
|
---|
202 |
|
---|
203 | public:
|
---|
204 | enum parameter_enum_t {
|
---|
205 | A,
|
---|
206 | B,
|
---|
207 | lambda,
|
---|
208 | mu,
|
---|
209 | beta,
|
---|
210 | n,
|
---|
211 | c,
|
---|
212 | d,
|
---|
213 | h,
|
---|
214 | // R,
|
---|
215 | // S,
|
---|
216 | // lambda3,
|
---|
217 | // alpha,
|
---|
218 | // chi,
|
---|
219 | // omega,
|
---|
220 | MAXPARAMS
|
---|
221 | };
|
---|
222 | //!> parameter vector with parameters as in enum parameter_enum_t
|
---|
223 | parameters_t params;
|
---|
224 |
|
---|
225 | public:
|
---|
226 | // some internal parameters which are fixed
|
---|
227 | const double R;
|
---|
228 | const double S;
|
---|
229 | const double lambda3;
|
---|
230 | const double alpha;
|
---|
231 | const double chi;
|
---|
232 | const double omega;
|
---|
233 |
|
---|
234 | public:
|
---|
235 | /** Setter for parameters as required by FunctionModel interface.
|
---|
236 | *
|
---|
237 | * \param _params given set of parameters
|
---|
238 | */
|
---|
239 | void setParameters(const parameters_t &_params)
|
---|
240 | {
|
---|
241 | ASSERT( _params.size() <= getParameterDimension(),
|
---|
242 | "ManyBodyPotential_Tersoff::setParameters() - we need not more than "
|
---|
243 | +toString(getParameterDimension())+" parameters.");
|
---|
244 | for (size_t i=0; i< _params.size(); ++i)
|
---|
245 | params[i] = _params[i];
|
---|
246 | }
|
---|
247 |
|
---|
248 | /** Getter for parameters as required by FunctionModel interface.
|
---|
249 | *
|
---|
250 | * \return set of parameters
|
---|
251 | */
|
---|
252 | parameters_t getParameters() const
|
---|
253 | {
|
---|
254 | return params;
|
---|
255 | }
|
---|
256 |
|
---|
257 | /** Getter for the number of parameters of this model function.
|
---|
258 | *
|
---|
259 | * \return number of parameters
|
---|
260 | */
|
---|
261 | size_t getParameterDimension() const
|
---|
262 | {
|
---|
263 | return MAXPARAMS;
|
---|
264 | }
|
---|
265 |
|
---|
266 | private:
|
---|
267 | //!> bound function that obtains the triples for the internal coordinationb summation.
|
---|
268 | const boost::function< std::vector< arguments_t >(const argument_t &, const double)> &triplefunction;
|
---|
269 | };
|
---|
270 |
|
---|
271 |
|
---|
272 | #endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
|
---|