source: src/Potentials/Specifics/ManyBodyPotential_Tersoff.cpp@ e7579e

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

Changed ManyBodyPotential_Tersoff to also have parameters_t instead of single member variable definitions.

  • added enum to give each entry in params a meaning.
  • modified setter and getter for parameters accordingly.
  • default constructor is now private, as we always need the triplefunction.
  • changed other constructors accordingly.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2012 University of Bonn. All rights reserved.
5 * Please see the COPYING file or "Copyright notice" in builder.cpp for details.
6 *
7 *
8 * This file is part of MoleCuilder.
9 *
10 * MoleCuilder is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * MoleCuilder is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24/*
25 * ManyBodyPotential_Tersoff.cpp
26 *
27 * Created on: Sep 26, 2012
28 * Author: heber
29 */
30
31
32// include config.h
33#ifdef HAVE_CONFIG_H
34#include <config.h>
35#endif
36
37#include "CodePatterns/MemDebug.hpp"
38
39#include "ManyBodyPotential_Tersoff.hpp"
40
41#include <boost/bind.hpp>
42#include <cmath>
43
44#include "CodePatterns/Assert.hpp"
45
46#include "Potentials/helpers.hpp"
47
48ManyBodyPotential_Tersoff::ManyBodyPotential_Tersoff(
49 boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction
50 ) :
51 params(parameters_t(MAXPARAMS, 0.)),
52 triplefunction(_triplefunction)
53{}
54
55ManyBodyPotential_Tersoff::ManyBodyPotential_Tersoff(
56 const double &_cutoff_offset,
57 const double &_cutoff_halfwidth,
58 const double &_A,
59 const double &_B,
60 const double &_lambda1,
61 const double &_lambda2,
62 const double &_lambda3,
63 const double &_alpha,
64 const double &_beta,
65 const double &_n,
66 const double &_c,
67 const double &_d,
68 const double &_h,
69 boost::function< std::vector<arguments_t>(const argument_t &, const double)> &_triplefunction) :
70 params(parameters_t(MAXPARAMS, 0.)),
71 triplefunction(_triplefunction)
72{
73 params[cutoff_offset] = _cutoff_offset;
74 params[cutoff_halfwidth] = _cutoff_halfwidth;
75 params[A] = _A;
76 params[B] = _B;
77 params[lambda1] = _lambda1;
78 params[lambda2] = _lambda2;
79 params[lambda3] = _lambda3;
80 params[alpha] = _alpha;
81 params[beta] = _beta;
82 params[n] = _n;
83 params[c] = _c;
84 params[d] = _d;
85 params[h] = _h;
86}
87
88ManyBodyPotential_Tersoff::results_t
89ManyBodyPotential_Tersoff::operator()(
90 const arguments_t &arguments
91 ) const
92{
93 const double &distance = arguments[0].distance;
94 const double cutoff = function_cutoff(distance);
95 const double result = (cutoff == 0.) ? 0. : cutoff * (
96 function_prefactor(
97 alpha,
98 boost::bind(&ManyBodyPotential_Tersoff::function_eta,
99 boost::cref(*this),
100 boost::cref(arguments[0])))
101 * function_smoother(
102 distance,
103 A,
104 lambda1)
105 +
106 function_prefactor(
107 beta,
108 boost::bind(&ManyBodyPotential_Tersoff::function_zeta,
109 boost::cref(*this),
110 boost::cref(arguments[0])))
111 * function_smoother(
112 distance,
113 -B,
114 lambda2)
115 );
116 return std::vector<result_t>(1, result);
117}
118
119ManyBodyPotential_Tersoff::result_t
120ManyBodyPotential_Tersoff::function_cutoff(
121 const double &distance
122 ) const
123{
124 const double offset = (distance - cutoff_offset);
125 if (offset < - cutoff_halfwidth)
126 return 1.;
127 else if (offset > cutoff_halfwidth)
128 return 0.;
129 else {
130 return (0.5 - 0.5 * sin( .5 * M_PI * offset/cutoff_halfwidth));
131 }
132}
133
134ManyBodyPotential_Tersoff::result_t
135ManyBodyPotential_Tersoff::function_prefactor(
136 const double &alpha,
137 boost::function<result_t()> etafunction
138 ) const
139{
140 return pow(
141 (1. + Helpers::pow(alpha * etafunction(), n)),
142 -1./(2.*n));
143}
144
145ManyBodyPotential_Tersoff::result_t
146ManyBodyPotential_Tersoff::function_eta(
147 const argument_t &r_ij
148 ) const
149{
150 result_t result = 0.;
151
152 // get all triples within the cutoff
153 std::vector<arguments_t> triples = triplefunction(r_ij, cutoff_offset+cutoff_halfwidth);
154 for (std::vector<arguments_t>::const_iterator iter = triples.begin();
155 iter != triples.end(); ++iter) {
156 ASSERT( iter->size() == 2,
157 "ManyBodyPotential_Tersoff::function_zeta() - the triples result must contain of exactly two distances.");
158 const argument_t &r_ik = (*iter)[0];
159 result += function_cutoff(r_ik.distance)
160 * exp( Helpers::pow(lambda3 * (r_ij.distance - r_ik.distance) ,3));
161 }
162
163 return result;
164}
165
166ManyBodyPotential_Tersoff::result_t
167ManyBodyPotential_Tersoff::function_zeta(
168 const argument_t &r_ij
169 ) const
170{
171 result_t result = 0.;
172
173 // get all triples within the cutoff
174 std::vector<arguments_t> triples = triplefunction(r_ij, cutoff_offset+cutoff_halfwidth);
175 for (std::vector<arguments_t>::const_iterator iter = triples.begin();
176 iter != triples.end(); ++iter) {
177 ASSERT( iter->size() == 2,
178 "ManyBodyPotential_Tersoff::function_zeta() - the triples result must contain exactly two distances.");
179 const argument_t &r_ik = (*iter)[0];
180 const argument_t &r_jk = (*iter)[1];
181 result +=
182 function_cutoff(r_ik.distance)
183 * function_angle(r_ij.distance, r_ik.distance, r_jk.distance)
184 * exp( Helpers::pow(lambda3 * (r_ij.distance - r_ik.distance) ,3));
185 }
186
187 return result;
188}
189
190ManyBodyPotential_Tersoff::result_t
191ManyBodyPotential_Tersoff::function_angle(
192 const double &r_ij,
193 const double &r_ik,
194 const double &r_jk
195 ) const
196{
197 const double angle = Helpers::pow(r_ij,2) + Helpers::pow(r_ik,2) - Helpers::pow(r_jk,2);
198 const double divisor = r_ij * r_ik;
199 const double result =
200 1.
201 + (Helpers::pow(c, 2)/Helpers::pow(d, 2))
202 - Helpers::pow(c, 2)/(Helpers::pow(d, 2) +
203 Helpers::pow(h - cos(angle/divisor),2));
204 return result;
205}
Note: See TracBrowser for help on using the repository browser.