votca 2024.2-dev
Loading...
Searching...
No Matches
aoecp.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2024 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 *Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Local VOTCA includes
24#include <libecpint/ecpint.hpp>
25#include <libecpint/gshell.hpp>
26#include <libecpint/mathutil.hpp>
27
28#if defined(__clang__)
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wdeprecated-declarations"
31#elif defined(__GNUC__)
32#pragma GCC diagnostic push
33#pragma GCC diagnostic ignored "-Warray-bounds"
34#endif
35#include <libint2/solidharmonics.h>
36#if defined(__clang__)
37#pragma clang diagnostic pop
38#elif defined(__GNUC__)
39#pragma GCC diagnostic pop
40#endif
41
42namespace votca {
43namespace xtp {
44
45std::ostream& operator<<(std::ostream& out,
46 const libecpint::GaussianShell& shell) {
47 out << " Shelltype:" << xtp::EnumToString(static_cast<L>(shell.am()))
48 << " L:" << Index(shell.am()) << " Func:" << shell.nprimitive() << "\n";
49 for (int i = 0; i < shell.nprimitive(); i++) {
50 out << " Gaussian Decay: " << shell.exp(i);
51 out << " Contractions: " << shell.coef(i) << "\n";
52 }
53 return out;
54}
55
57 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
58
59void AOECP::FillPotential(const AOBasis& aobasis, const ECPAOBasis& ecp) {
60
62 Eigen::MatrixXd::Zero(aobasis.AOBasisSize(), aobasis.AOBasisSize());
63 std::vector<libecpint::GaussianShell> basis;
64 std::vector<Index> cartesian_size;
65 std::vector<Index> spherical_size;
66 for (const auto& shell : aobasis) {
67 libecpint::GaussianShell s(
68 {shell.getPos().x(), shell.getPos().y(), shell.getPos().z()},
69 int(shell.getL()));
70 spherical_size.push_back(shell.getNumFunc());
71 cartesian_size.push_back(shell.getCartesianNumFunc());
72 // The normalisation libecpint requires is identical to the libint
73 // normalisation of shells
74 libint2::Shell s_libint = shell.LibintShell();
75 for (Index i = 0; i < Index(s_libint.nprim()); i++) {
76 s.addPrim(s_libint.alpha[i], s_libint.contr[0].coeff[i]);
77 }
78 basis.push_back(s);
79 }
80 std::vector<Index> shell2bf = aobasis.getMapToBasisFunctions();
81
82 std::vector<libecpint::ECPIntegral> engines(
84 libecpint::ECPIntegral(int(aobasis.getMaxL()), int(ecp.getMaxL()), 0));
85#pragma omp parallel for schedule(guided)
86 for (Index s1 = 0; s1 < aobasis.getNumofShells(); ++s1) {
87 Index thread_id = OPENMP::getThreadId();
88 libecpint::ECPIntegral& engine = engines[thread_id];
89 Index bf1 = shell2bf[s1];
90 Index n1 = spherical_size[s1];
91 Index c1 = cartesian_size[s1];
92 for (Index s2 = 0; s2 <= s1; ++s2) {
93 Index bf2 = shell2bf[s2];
94 Index n2 = spherical_size[s2];
95 Index c2 = cartesian_size[s2];
96
97 MatrixLibInt cartesian_result = MatrixLibInt::Zero(c1, c2);
98 for (auto& ecppotential : ecp) {
99 libecpint::TwoIndex<double> results;
100 engine.compute_shell_pair(ecppotential, basis[s1], basis[s2], results);
101 cartesian_result +=
102 Eigen::Map<MatrixLibInt>(results.data.data(), c1, c2);
103 }
104
105 MatrixLibInt spherical_result = MatrixLibInt::Zero(n1, n2);
106 libint2::solidharmonics::tform<double>(basis[s1].l, basis[s2].l,
107 cartesian_result.data(),
108 spherical_result.data());
109 aopotential_.block(bf1, bf2, n1, n2) = spherical_result;
110 if (s1 != s2) { // if s1 >= s2, copy {s1,s2} to the corresponding
111 // {s2,s1} block, note the transpose!
112 aopotential_.block(bf2, bf1, n2, n1) = spherical_result.transpose();
113 }
114 }
115 }
116}
117
118} // namespace xtp
119} // namespace votca
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
Index getMaxL() const
Definition aobasis.cc:29
Index AOBasisSize() const
Definition aobasis.h:46
std::vector< Index > getMapToBasisFunctions() const
Definition aobasis.cc:45
Index getNumofShells() const
Definition aobasis.h:56
void FillPotential(const AOBasis &aobasis, const ECPAOBasis &ecp)
Definition aoecp.cc:59
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > aopotential_
Definition aopotential.h:49
Container to hold ECPs for all atoms.
Definition ecpaobasis.h:43
Index getMaxL() const
Definition ecpaobasis.cc:31
std::ostream & operator<<(std::ostream &out, const Correlate &c)
Definition correlate.h:53
Index getMaxThreads()
Definition eigen.h:128
Index getThreadId()
Definition eigen.h:143
std::string EnumToString(L l)
Definition basisset.cc:60
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixLibInt
Definition aoecp.cc:56
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26