votca 2024-dev
Loading...
Searching...
No Matches
aoecp.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 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#include <libint2/solidharmonics.h>
28
29namespace votca {
30namespace xtp {
31
32std::ostream& operator<<(std::ostream& out,
33 const libecpint::GaussianShell& shell) {
34 out << " Shelltype:" << xtp::EnumToString(static_cast<L>(shell.am()))
35 << " L:" << Index(shell.am()) << " Func:" << shell.nprimitive() << "\n";
36 for (int i = 0; i < shell.nprimitive(); i++) {
37 out << " Gaussian Decay: " << shell.exp(i);
38 out << " Contractions: " << shell.coef(i) << "\n";
39 }
40 return out;
41}
42
44 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
45
46void AOECP::FillPotential(const AOBasis& aobasis, const ECPAOBasis& ecp) {
47
49 Eigen::MatrixXd::Zero(aobasis.AOBasisSize(), aobasis.AOBasisSize());
50 std::vector<libecpint::GaussianShell> basis;
51 std::vector<Index> cartesian_size;
52 std::vector<Index> spherical_size;
53 for (const auto& shell : aobasis) {
54 libecpint::GaussianShell s(
55 {shell.getPos().x(), shell.getPos().y(), shell.getPos().z()},
56 int(shell.getL()));
57 spherical_size.push_back(shell.getNumFunc());
58 cartesian_size.push_back(shell.getCartesianNumFunc());
59 // The normalisation libecpint requires is identical to the libint
60 // normalisation of shells
61 libint2::Shell s_libint = shell.LibintShell();
62 for (Index i = 0; i < Index(s_libint.nprim()); i++) {
63 s.addPrim(s_libint.alpha[i], s_libint.contr[0].coeff[i]);
64 }
65 basis.push_back(s);
66 }
67 std::vector<Index> shell2bf = aobasis.getMapToBasisFunctions();
68
69 std::vector<libecpint::ECPIntegral> engines(
71 libecpint::ECPIntegral(int(aobasis.getMaxL()), int(ecp.getMaxL()), 0));
72#pragma omp parallel for schedule(guided)
73 for (Index s1 = 0; s1 < aobasis.getNumofShells(); ++s1) {
74 Index thread_id = OPENMP::getThreadId();
75 libecpint::ECPIntegral& engine = engines[thread_id];
76 Index bf1 = shell2bf[s1];
77 Index n1 = spherical_size[s1];
78 Index c1 = cartesian_size[s1];
79 for (Index s2 = 0; s2 <= s1; ++s2) {
80 Index bf2 = shell2bf[s2];
81 Index n2 = spherical_size[s2];
82 Index c2 = cartesian_size[s2];
83
84 MatrixLibInt cartesian_result = MatrixLibInt::Zero(c1, c2);
85 for (auto& ecppotential : ecp) {
86 libecpint::TwoIndex<double> results;
87 engine.compute_shell_pair(ecppotential, basis[s1], basis[s2], results);
88 cartesian_result +=
89 Eigen::Map<MatrixLibInt>(results.data.data(), c1, c2);
90 }
91
92 MatrixLibInt spherical_result = MatrixLibInt::Zero(n1, n2);
93 libint2::solidharmonics::tform<double>(basis[s1].l, basis[s2].l,
94 cartesian_result.data(),
95 spherical_result.data());
96 aopotential_.block(bf1, bf2, n1, n2) = spherical_result;
97 if (s1 != s2) { // if s1 >= s2, copy {s1,s2} to the corresponding
98 // {s2,s1} block, note the transpose!
99 aopotential_.block(bf2, bf1, n2, n1) = spherical_result.transpose();
100 }
101 }
102 }
103}
104
105} // namespace xtp
106} // 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:46
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:44
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26