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 |
|
---|
48 | ManyBodyPotential_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 |
|
---|
55 | ManyBodyPotential_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 |
|
---|
88 | ManyBodyPotential_Tersoff::results_t
|
---|
89 | ManyBodyPotential_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 |
|
---|
119 | ManyBodyPotential_Tersoff::result_t
|
---|
120 | ManyBodyPotential_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 |
|
---|
134 | ManyBodyPotential_Tersoff::result_t
|
---|
135 | ManyBodyPotential_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 |
|
---|
145 | ManyBodyPotential_Tersoff::result_t
|
---|
146 | ManyBodyPotential_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 |
|
---|
166 | ManyBodyPotential_Tersoff::result_t
|
---|
167 | ManyBodyPotential_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 |
|
---|
190 | ManyBodyPotential_Tersoff::result_t
|
---|
191 | ManyBodyPotential_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 | }
|
---|