source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp@ 39a07a

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 39a07a was e36ba2, checked in by Frederik Heber <heber@…>, 12 years ago

FunctionModel extended by triplefunction setter, does nothing by default.

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