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