94 const Eigen::Vector3d center = (grid_pos -
pos_);
95 const double distsq = center.squaredNorm();
97 Eigen::VectorXd& AOvalues = AO.
values;
103 const double alpha = gaussian.getDecay();
104 const double contraction = gaussian.getContraction();
106 const double expofactor =
107 gaussian.getPowfactor() * std::exp(-alpha * distsq);
108 const Eigen::Vector3d second_term = -2.0 * alpha * center;
112 double AOvalue = contraction * expofactor;
113 AOvalues(0) += AOvalue;
114 gradAOvalues.row(0) += second_term * AOvalue;
117 const double factor = 2. * sqrt(alpha) * contraction * expofactor;
119 double AOvalue = factor * center.y();
120 AOvalues(0) += AOvalue;
121 gradAOvalues.row(0) += second_term * AOvalue;
122 gradAOvalues(0, 1) += factor;
124 AOvalue = factor * center.z();
125 AOvalues(1) += AOvalue;
126 gradAOvalues.row(1) += second_term * AOvalue;
127 gradAOvalues(1, 2) += factor;
129 AOvalue = factor * center.x();
130 AOvalues(2) += AOvalue;
131 gradAOvalues(2, 0) += factor;
132 gradAOvalues.row(2) += second_term * AOvalue;
135 const double factor = 2. * alpha * contraction * expofactor;
136 const double factor_1 = factor / sqrt(3.);
138 double AOvalue = 2. * factor * (center.x() * center.y());
139 AOvalues(0) += AOvalue;
140 Eigen::Array3d coeff = {2 * center.y(), 2 * center.x(), 0};
141 gradAOvalues.row(0) += factor * coeff.matrix() + second_term * AOvalue;
143 AOvalue = 2. * factor * (center.y() * center.z());
144 AOvalues(1) += AOvalue;
145 coeff = {0, 2 * center.z(), 2 * center.y()};
146 gradAOvalues.row(1) += factor * coeff.matrix() + second_term * AOvalue;
148 AOvalue = factor_1 * (3. * center.z() * center.z() - distsq);
149 AOvalues(2) += AOvalue;
151 gradAOvalues.row(2) += (factor_1 * coeff * center.array()).matrix() +
152 second_term * AOvalue;
154 AOvalue = 2. * factor * (center.x() * center.z());
155 AOvalues(3) += AOvalue;
156 coeff = {2 * center.z(), 0, 2 * center.x()};
157 gradAOvalues.row(3) += factor * coeff.matrix() + second_term * AOvalue;
160 (center.x() * center.x() - center.y() * center.y());
161 AOvalues(4) += AOvalue;
162 coeff = {2 * center.x(), -2 * center.y(), 0};
163 gradAOvalues.row(4) += factor * coeff.matrix() + second_term * AOvalue;
166 const double factor = 2. * pow(alpha, 1.5) * contraction * expofactor;
167 const double factor_1 = factor * 2. / sqrt(15.);
168 const double factor_2 = factor * sqrt(2.) / sqrt(5.);
169 const double factor_3 = factor * sqrt(2.) / sqrt(3.);
173 factor_3 * center.y() * (3. * c.
xx() - c.
yy());
174 AOvalues(0) += AOvalue;
175 Eigen::Array3d coeff = {6. * c.
xy(), 3. * (c.
xx() - c.
yy()), 0};
176 gradAOvalues.row(0) +=
177 factor_3 * coeff.matrix() + second_term * AOvalue;
179 AOvalue = 4. * factor * center.x() * center.y() * center.z();
180 AOvalues(1) += AOvalue;
181 coeff = {c.
yz(), c.
xz(), c.
xy()};
182 gradAOvalues.row(1) +=
183 4 * factor * coeff.matrix() + second_term * AOvalue;
185 AOvalue = factor_2 * center.y() * (5. * c.
zz() - distsq);
186 AOvalues(2) += AOvalue;
187 coeff = {-2. * c.
xy(), 4. * c.
zz() - c.
xx() - 3. * c.
yy(), 8. * c.
yz()};
188 gradAOvalues.row(2) +=
189 factor_2 * coeff.matrix() + second_term * AOvalue;
191 AOvalue = factor_1 * center.z() * (5. * c.
zz() - 3. * distsq);
192 AOvalues(3) += AOvalue;
193 coeff = {-6. * c.
xz(), -6. * c.
yz(), 3. * (3. * c.
zz() - distsq)};
194 gradAOvalues.row(3) +=
195 factor_1 * coeff.matrix() + second_term * AOvalue;
197 AOvalue = factor_2 * center.x() * (5. * c.
zz() - distsq);
198 AOvalues(4) += AOvalue;
199 coeff = {4. * c.
zz() - c.
yy() - 3. * c.
xx(), -2. * c.
xy(), 8. * c.
xz()};
200 gradAOvalues.row(4) +=
201 factor_2 * coeff.matrix() + second_term * AOvalue;
203 AOvalue = 2. * factor * center.z() * (c.
xx() - c.
yy());
204 AOvalues(5) += AOvalue;
205 coeff = {2. * c.
xz(), -2. * c.
yz(), c.
xx() - c.
yy()};
206 gradAOvalues.row(5) +=
207 2 * factor * coeff.matrix() + second_term * AOvalue;
209 AOvalue = factor_3 * center.x() * (c.
xx() - 3. * c.
yy());
210 AOvalues(6) += AOvalue;
211 coeff = {3. * (c.
xx() - c.
yy()), -6. * c.
xy(), 0};
212 gradAOvalues.row(6) +=
213 factor_3 * coeff.matrix() + second_term * AOvalue;
216 const double factor =
217 2. / sqrt(3.) * alpha * alpha * contraction * expofactor;
218 const double factor_1 = factor / sqrt(35.);
219 const double factor_2 = factor * 4. / sqrt(14.);
220 const double factor_3 = factor * 2. / sqrt(7.);
221 const double factor_4 = factor * 2. * sqrt(2.);
224 double AOvalue = 4. * factor * c.
xy() * (c.
xx() - c.
yy());
225 AOvalues(0) += AOvalue;
226 Eigen::Array3d coeff = {center.y() * (3. * c.
xx() - c.
yy()),
227 center.x() * (c.
xx() - 3. * c.
yy()), 0};
228 gradAOvalues.row(0) +=
229 4 * factor * coeff.matrix() + second_term * AOvalue;
231 AOvalue = factor_4 * c.
yz() * (3. * c.
xx() - c.
yy());
232 AOvalues(1) += AOvalue;
233 coeff = {6. * center.x() * c.
yz(), 3. * center.z() * (c.
xx() - c.
yy()),
234 center.y() * (3. * c.
xx() - c.
yy())};
235 gradAOvalues.row(1) +=
236 factor_4 * coeff.matrix() + second_term * AOvalue;
238 AOvalue = 2. * factor_3 * c.
xy() * (7. * c.
zz() - distsq);
239 AOvalues(2) += AOvalue;
240 coeff = {center.y() * (6. * c.
zz() - 3. * c.
xx() - c.
yy()),
241 center.x() * (6. * c.
zz() - c.
xx() - 3. * c.
yy()),
242 12. * center.z() * c.
xy()};
243 gradAOvalues.row(2) +=
244 2 * factor_3 * coeff.matrix() + second_term * AOvalue;
246 AOvalue = factor_2 * c.
yz() * (7. * c.
zz() - 3. * distsq);
247 AOvalues(3) += AOvalue;
248 coeff = {(-6. * center.x() * c.
yz()),
249 center.z() * (4. * c.
zz() - 3. * c.
xx() - 9. * c.
yy()),
250 3. * center.y() * (5. * c.
zz() - distsq)};
251 gradAOvalues.row(3) +=
252 factor_2 * coeff.matrix() + second_term * AOvalue;
254 AOvalue = factor_1 * (35. * c.
zz() * c.
zz() - 30. * c.
zz() * distsq +
255 3. * distsq * distsq);
256 AOvalues(4) += AOvalue;
257 coeff = {12. * center.x() * (distsq - 5. * c.
zz()),
258 12. * center.y() * (distsq - 5. * c.
zz()),
259 16. * center.z() * (5. * c.
zz() - 3. * distsq)};
261 gradAOvalues.row(4) +=
262 factor_1 * coeff.matrix() + second_term * AOvalue;
264 AOvalue = factor_2 * c.
xz() * (7. * c.
zz() - 3. * distsq);
265 AOvalues(5) += AOvalue;
266 coeff = {center.z() * (4. * c.
zz() - 9. * c.
xx() - 3. * c.
yy()),
267 (-6. * center.y() * c.
xz()),
268 3. * center.x() * (5. * c.
zz() - distsq)};
269 gradAOvalues.row(5) +=
270 factor_2 * coeff.matrix() + second_term * AOvalue;
273 factor_3 * (c.
xx() - c.
yy()) * (7. * c.
zz() - distsq);
274 AOvalues(6) += AOvalue;
275 coeff = {4. * center.x() * (3. * c.
zz() - c.
xx()),
276 4. * center.y() * (c.
yy() - 3. * c.
zz()),
277 12. * center.z() * (c.
xx() - c.
yy())};
278 gradAOvalues.row(6) +=
279 factor_3 * coeff.matrix() + second_term * AOvalue;
281 AOvalue = factor_4 * c.
xz() * (c.
xx() - 3. * c.
yy());
282 AOvalues(7) += AOvalue;
283 coeff = {3. * center.z() * (c.
xx() - c.
yy()),
284 (-6. * center.y() * c.
xz()),
285 center.x() * (c.
xx() - 3. * c.
yy())};
286 gradAOvalues.row(7) +=
287 factor_4 * coeff.matrix() + second_term * AOvalue;
289 AOvalue = factor * (c.
xx() * c.
xx() - 6. * c.
xx() * c.
yy() +
291 AOvalues(8) += AOvalue;
292 coeff = {center.x() * (c.
xx() - 3. * c.
yy()),
293 center.y() * (c.
yy() - 3. * c.
xx()), 0};
294 gradAOvalues.row(8) +=
295 4 * factor * coeff.matrix() + second_term * AOvalue;