source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp@ 0dad5f

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 0dad5f was 775dd1a, checked in by Frederik Heber <heber@…>, 12 years ago

Triplefunction for Saturation and Tersoff potential have to be given extra.

  • this avoids a loop with TrainingData and getFragmentSpecificExtractor.
  • Property mode set to 100644
File size: 9.4 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(
193 boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction
194 )
195 {
196 triplefunction = _triplefunction;
197 }
198
199private:
200 /** Prohibit private default constructor.
201 *
202 * We essentially need the triplefunction, hence without this function cannot
203 * be.
204 */
205 ManyBodyPotential_Tersoff();
206
207private:
208 /** This function represents the cutoff \f$ f_C \f$.
209 *
210 * @param distance variable of the function
211 * @return a value in [0,1].
212 */
213 result_t function_cutoff(
214 const double &distance
215 ) const;
216 /** This function has the exponential feature from the Morse potential.
217 *
218 * @param prefactor prefactor parameter to exp function
219 * @param lambda scale parameter of exp function's argument
220 * @param distance variable of the function
221 * @return
222 */
223 result_t function_smoother(
224 const double &prefactor,
225 const double &lambda,
226 const double &distance
227 ) const;
228
229 /** This function represents \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$.
230 *
231 * @param alpha prefactor to eta function
232 * @param r_ij distance argument
233 * @param eta result value of eta or zeta
234 * @return \f$ (1 + \alpha^n \eta^n)^{-1/2n} \f$
235 */
236 result_t function_prefactor(
237 const double &alpha,
238 const double &eta
239 ) const;
240
241 result_t
242 function_eta(
243 const argument_t &r_ij
244 ) const;
245
246 result_t
247 function_zeta(
248 const argument_t &r_ij
249 ) const;
250
251 result_t
252 function_theta(
253 const double &r_ij,
254 const double &r_ik,
255 const double &r_jk
256 ) const;
257
258 result_t
259 function_angle(
260 const double &r_ij,
261 const double &r_ik,
262 const double &r_jk
263 ) const;
264
265private:
266 result_t
267 function_derivative_c(
268 const argument_t &r_ij
269 ) const;
270
271 result_t
272 function_derivative_d(
273 const argument_t &r_ij
274 ) const;
275
276 result_t
277 function_derivative_h(
278 const argument_t &r_ij
279 ) const;
280
281public:
282 enum parameter_enum_t {
283 A,
284 B,
285 lambda,
286 mu,
287 beta,
288 n,
289 c,
290 d,
291 h,
292 offset,
293// R,
294// S,
295// lambda3,
296// alpha,
297// chi,
298// omega,
299 MAXPARAMS
300 };
301
302private:
303 //!> parameter vector with parameters as in enum parameter_enum_t
304 parameters_t params;
305
306public:
307 // some internal parameters which are fixed
308 const double R;
309 const double S;
310 const double lambda3;
311 const double alpha;
312 const double chi;
313 const double omega;
314
315public:
316 /** Setter for parameters as required by FunctionModel interface.
317 *
318 * \param _params given set of parameters
319 */
320 void setParameters(const parameters_t &_params);
321
322 /** Getter for parameters as required by FunctionModel interface.
323 *
324 * \return set of parameters
325 */
326 parameters_t getParameters() const
327 {
328 return params;
329 }
330
331 /** Sets the parameter randomly within the sensible range of each parameter.
332 *
333 * \param data container with training data for guesstimating range
334 */
335 void setParametersToRandomInitialValues(const TrainingData &data);
336
337 /** Getter for the number of parameters of this model function.
338 *
339 * \return number of parameters
340 */
341 size_t getParameterDimension() const
342 {
343 return MAXPARAMS;
344 }
345
346private:
347 //!> bound function that obtains the triples for the internal coordinationb summation.
348 boost::function< std::vector< arguments_t >(const argument_t &, const double)> triplefunction;
349
350 //!> static definitions of the parameter name for this potential
351 static const ParameterNames_t ParameterNames;
352
353 //!> static token of this potential type
354 static const std::string potential_token;
355};
356
357
358#endif /* MANYBODYPOTENTIAL_TERSOFF_HPP_ */
Note: See TracBrowser for help on using the repository browser.