source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp

stable v1.7.0
Last change on this file was a0d8aa, checked in by Frederik Heber <frederik.heber@…>, 8 weeks ago

PotentialFactory exposes particle type numbers.

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