source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp@ ff90e3

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since ff90e3 was 0f5d38, checked in by Frederik Heber <heber@…>, 12 years ago

Added getSpecificFilter() and getSpecificArgumentCount() to FunctionModel.

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