source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp@ 91a3f7

Fix_FitPotential_needs_atomicnumbers
Last change on this file since 91a3f7 was b794f5, checked in by Frederik Heber <heber@…>, 9 years ago

tempcommit: Add ..Potentials need to supply PotentialSubgraph instead of adjacency_list.

  • Property mode set to 100644
File size: 10.0 KB
RevLine 
[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
[713888]22class PotentialFactory;
[d52819]23class TrainingData;
24
[610c11]25/** This class is the implementation of the Tersoff potential function.
26 *
27 * \note The arguments_t argument list is here in the following order:
[dd966f]28 * -# first \f$ r_{ij} \f$,
29 * -# then all \f$ r_{ik} \f$ that are within the cutoff, i.e. \f$ r_{ik} < R + D\f$
[610c11]30 *
31 */
[ed2551]32class ManyBodyPotential_Tersoff :
[fdd23a]33 public EmpiricalPotential
[610c11]34{
[ffc368]35 //!> grant unit test access to internal parts
36 friend class ManyBodyPotential_TersoffTest;
[713888]37 //!> grant PotentialFactory access to default cstor
38 friend class PotentialFactory;
[3ccea3]39 // some repeated typedefs to avoid ambiguities
[e1fe7e]40 typedef FunctionModel::list_of_arguments_t list_of_arguments_t;
[3ccea3]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;
[713888]46private:
47 /** Private default constructor.
48 *
49 * This prevents creation of potential without set ParticleTypes_t.
50 *
51 */
52 ManyBodyPotential_Tersoff();
53
[610c11]54public:
55 /** Constructor for class ManyBodyPotential_Tersoff.
56 *
[775dd1a]57 * \param _ParticleTypes particle types for this potential
[610c11]58 */
59 ManyBodyPotential_Tersoff(
[775dd1a]60 const ParticleTypes_t &_ParticleTypes
[e7579e]61 );
62
63 /** Constructor for class ManyBodyPotential_Tersoff.
64 *
[ffc368]65 * @param _R offset for cutoff
66 * @param _S halfwidth for cutoff relative to \a _R
[e7579e]67 * @param A
68 * @param B
[ffc368]69 * @param lambda
70 * @param mu
[e7579e]71 * @param lambda3
72 * @param alpha
73 * @param beta
[ffc368]74 * @param chi
75 * @param omega
[e7579e]76 * @param n
77 * @param c
78 * @param d
79 * @param h
80 * @param _triplefunction function that returns a list of triples (i.e. the
81 * two remaining distances) to a given pair of points (contained as
82 * indices within the argument)
83 */
84 ManyBodyPotential_Tersoff(
[ed2551]85 const ParticleTypes_t &_ParticleTypes,
[ffc368]86 const double &_R,
87 const double &_S,
88 const double &_A,
89 const double &_B,
90 const double &_lambda,
91 const double &_mu,
92 const double &_lambda3,
93 const double &_alpha,
94 const double &_beta,
95 const double &_chi,
96 const double &_omega,
97 const double &_n,
98 const double &_c,
99 const double &_d,
[b15ae7]100 const double &_h);
[e7579e]101
[610c11]102 /** Destructor of class ManyBodyPotential_Tersoff.
103 *
104 */
105 virtual ~ManyBodyPotential_Tersoff() {}
106
107 /** Evaluates the Tersoff potential for the given arguments.
108 *
[e1fe7e]109 * @param listarguments list of distances
[610c11]110 * @return value of the potential function
111 */
[e1fe7e]112 results_t operator()(const list_of_arguments_t &listarguments) const;
[610c11]113
114 /** Evaluates the derivative of the Tersoff potential with respect to the
115 * input variables.
116 *
[e1fe7e]117 * @param listarguments list of distances
[610c11]118 * @return vector with components of the derivative
119 */
[e1fe7e]120 derivative_components_t derivative(const list_of_arguments_t &listarguments) const;
[610c11]121
[3ccea3]122 /** Evaluates the derivative of the function with the given \a arguments
123 * with respect to a specific parameter indicated by \a index.
124 *
[e1fe7e]125 * \param listarguments list of distances
[3ccea3]126 * \param index derivative of which parameter
127 * \return result vector containing the derivative with respect to the given
128 * input
129 */
[e1fe7e]130 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const;
[e7579e]131
[94453f1]132 /** Returns the functor that converts argument_s into the
133 * internal coordinate described by this potential function.
134 *
135 * \return coordinator functor
136 */
137 Coordinator::ptr getCoordinator() const
138 { return coordinator; }
139
[6efcae]140 /** Return the token name of this specific potential.
[67cd3a]141 *
[6efcae]142 * \return token name of the potential
[67cd3a]143 */
[ed2551]144 const std::string& getToken() const
145 { return potential_token; }
146
147 /** Returns a vector of parameter names.
148 *
149 * This is required from the specific implementation
150 *
151 * \return vector of strings containing parameter names
152 */
153 const ParameterNames_t& getParameterNames() const
154 { return ParameterNames; }
[67cd3a]155
[d03292]156 /** States whether lower and upper boundaries should be used to constraint
157 * the parameter search for this function model.
158 *
159 * \return true - constraints should be used, false - else
160 */
161 bool isBoxConstraint() const {
162 return true;
163 }
164
165 /** Returns a vector which are the lower boundaries for each parameter_t
166 * of this FunctionModel.
167 *
168 * \return vector of parameter_t resembling lowest allowed values
169 */
170 parameters_t getLowerBoxConstraints() const {
171 parameters_t lowerbound(getParameterDimension(), -std::numeric_limits<double>::max());
172// lowerbound[R] = 0.;
173// lowerbound[S] = 0.;
174// lowerbound[lambda3] = 0.;
175// lowerbound[alpha] = 0.;
176 lowerbound[beta] = std::numeric_limits<double>::min();
177 lowerbound[n] = std::numeric_limits<double>::min();
178 lowerbound[c] = std::numeric_limits<double>::min();
179 lowerbound[d] = std::numeric_limits<double>::min();
180 return lowerbound;
181 }
182
183 /** Returns a vector which are the upper boundaries for each parameter_t
184 * of this FunctionModel.
185 *
186 * \return vector of parameter_t resembling highest allowed values
187 */
188 parameters_t getUpperBoxConstraints() const {
189 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max());
190 }
191
[7b019a]192 /** Returns a bound function to be used with TrainingData, extracting distances
193 * from a Fragment.
194 *
195 * \return bound function extracting distances from a fragment
[0f5d38]196 */
197 FunctionModel::filter_t getSpecificFilter() const;
198
199 /** Returns the number of arguments the underlying function requires.
200 *
201 * \return number of arguments of the function
202 */
203 size_t getSpecificArgumentCount() const
204 { return 1; }
205
[775dd1a]206 /** Sets the magic triple function that we use for getting angle distances.
207 *
208 * @param _triplefunction function that returns a list of triples (i.e. the
209 * two remaining distances) to a given pair of points (contained as
210 * indices within the argument)
211 */
[e36ba2]212 void setTriplefunction(triplefunction_t &_triplefunction)
213 { triplefunction = _triplefunction; }
[775dd1a]214
[0b7036]215protected:
216 /** Provides the specific subgraph for this specific empirical potential.
217 *
[b794f5]218 * \return subgraph describing the potential's bonding model
[0b7036]219 */
[b794f5]220 const PotentialSubgraph& getSubgraph() const
221 { return subgraph; }
[0b7036]222
[610c11]223private:
224 /** This function represents the cutoff \f$ f_C \f$.
225 *
226 * @param distance variable of the function
227 * @return a value in [0,1].
228 */
229 result_t function_cutoff(
230 const double &distance
231 ) const;
232 /** This function has the exponential feature from the Morse potential.
233 *
234 * @param prefactor prefactor parameter to exp function
235 * @param lambda scale parameter of exp function's argument
[ffc368]236 * @param distance variable of the function
[610c11]237 * @return
238 */
239 result_t function_smoother(
240 const double &prefactor,
[ffc368]241 const double &lambda,
242 const double &distance
243 ) const;
[610c11]244
245 /** This function represents \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$.
246 *
247 * @param alpha prefactor to eta function
248 * @param r_ij distance argument
[ffc368]249 * @param eta result value of eta or zeta
[610c11]250 * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
251 */
252 result_t function_prefactor(
253 const double &alpha,
[ffc368]254 const double &eta
[610c11]255 ) const;
256
257 result_t
258 function_eta(
259 const argument_t &r_ij
260 ) const;
261
262 result_t
263 function_zeta(
264 const argument_t &r_ij
265 ) const;
266
[f904d5]267 result_t
268 function_theta(
269 const double &r_ij,
270 const double &r_ik,
271 const double &r_jk
272 ) const;
273
[610c11]274 result_t
275 function_angle(
276 const double &r_ij,
277 const double &r_ik,
278 const double &r_jk
279 ) const;
280
[e7579e]281private:
[ca8d82]282 result_t
283 function_derivative_c(
284 const argument_t &r_ij
285 ) const;
286
287 result_t
288 function_derivative_d(
289 const argument_t &r_ij
290 ) const;
291
292 result_t
293 function_derivative_h(
294 const argument_t &r_ij
295 ) const;
296
297public:
[e7579e]298 enum parameter_enum_t {
[752dc7]299 A,
300 B,
301 lambda,
302 mu,
303 beta,
304 n,
305 c,
306 d,
307 h,
308// R,
309// S,
310// lambda3,
311// alpha,
312// chi,
313// omega,
[e7579e]314 MAXPARAMS
315 };
[f48ad3]316
317private:
[e7579e]318 //!> parameter vector with parameters as in enum parameter_enum_t
319 parameters_t params;
320
[752dc7]321public:
[990a62]322 // some internal parameters which are fixed
[752dc7]323 const double R;
324 const double S;
[990a62]325 const double lambda3;
326 const double alpha;
327 const double chi;
328 const double omega;
329
[e7579e]330public:
331 /** Setter for parameters as required by FunctionModel interface.
332 *
333 * \param _params given set of parameters
334 */
[086070]335 void setParameters(const parameters_t &_params);
[e7579e]336
337 /** Getter for parameters as required by FunctionModel interface.
338 *
339 * \return set of parameters
340 */
341 parameters_t getParameters() const
342 {
343 return params;
344 }
345
[d52819]346 /** Sets the parameter randomly within the sensible range of each parameter.
347 *
348 * \param data container with training data for guesstimating range
349 */
350 void setParametersToRandomInitialValues(const TrainingData &data);
351
[e7579e]352 /** Getter for the number of parameters of this model function.
353 *
354 * \return number of parameters
355 */
356 size_t getParameterDimension() const
357 {
358 return MAXPARAMS;
359 }
360
[610c11]361private:
362 //!> bound function that obtains the triples for the internal coordinationb summation.
[775dd1a]363 boost::function< std::vector< arguments_t >(const argument_t &, const double)> triplefunction;
[ed2551]364
365 //!> static definitions of the parameter name for this potential
366 static const ParameterNames_t ParameterNames;
367
368 //!> static token of this potential type
369 static const std::string potential_token;
[94453f1]370
371 //!> internal coordinator object for converting arguments_t
372 static Coordinator::ptr coordinator;
[b794f5]373
374 //!> internal subgraph describing the subgraph modeled by this potential
375 static const PotentialSubgraph subgraph;
[610c11]376};
377
378
379#endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
Note: See TracBrowser for help on using the repository browser.