votca 2024.2-dev
Loading...
Searching...
No Matches
aomatrix.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 "A_ol I_ol" BA_olI_ol,
14 * WITHOUT WARRANTIE_ol OR CONDITION_ol OF ANY KIND, either express or implied.
15 * olee_ the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Standard includes
21#include <vector>
22// Local VOTCA includes
23#include "votca/xtp/aomatrix.h"
24
25namespace votca {
26namespace xtp {
27
28Eigen::MatrixXd AOOverlap::Pseudo_InvSqrt(double etol) {
29 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(aomatrix_);
30 smallestEigenvalue = es.eigenvalues()(0);
31 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.eigenvalues().size());
33 for (Index i = 0; i < diagonal.size(); ++i) {
34 if (es.eigenvalues()(i) < etol) {
36 } else {
37 diagonal(i) = 1.0 / std::sqrt(es.eigenvalues()(i));
38 }
39 }
40
41 return es.eigenvectors() * diagonal.asDiagonal() *
42 es.eigenvectors().transpose();
43}
44
45Eigen::MatrixXd AOOverlap::Sqrt() {
46 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(aomatrix_);
47 smallestEigenvalue = es.eigenvalues()(0);
48 return es.operatorSqrt();
49}
50
51// This converts V into ((S-1/2 V S-1/2)-1/2 S-1/2)T, which is needed to
52// construct 4c integrals,
53Eigen::MatrixXd AOCoulomb::Pseudo_InvSqrt_GWBSE(const AOOverlap& auxoverlap,
54 double etol) {
55
56 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> eo(auxoverlap.Matrix());
58 Eigen::VectorXd diagonal_overlap =
59 Eigen::VectorXd::Zero(eo.eigenvalues().size());
60 for (Index i = 0; i < diagonal_overlap.size(); ++i) {
61 if (eo.eigenvalues()(i) < etol) {
63 } else {
64 diagonal_overlap(i) = 1.0 / std::sqrt(eo.eigenvalues()(i));
65 }
66 }
67 Eigen::MatrixXd Ssqrt = eo.eigenvectors() * diagonal_overlap.asDiagonal() *
68 eo.eigenvectors().transpose();
69
70 Eigen::MatrixXd ortho = Ssqrt * aomatrix_ * Ssqrt;
71 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(ortho);
72 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.eigenvalues().size());
73
74 for (Index i = 0; i < diagonal.size(); ++i) {
75 if (es.eigenvalues()(i) < etol) {
77 } else {
78 diagonal(i) = 1.0 / std::sqrt(es.eigenvalues()(i));
79 }
80 }
81
82 Eigen::MatrixXd Vm1 =
83 es.eigenvectors() * diagonal.asDiagonal() * es.eigenvectors().transpose();
84 Eigen::MatrixXd result = (Vm1 * Ssqrt).transpose();
85 return result;
86}
87
88Eigen::MatrixXd AOCoulomb::Pseudo_InvSqrt(double etol) {
89 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(aomatrix_);
90 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.eigenvalues().size());
92 for (Index i = 0; i < diagonal.size(); ++i) {
93 if (es.eigenvalues()(i) < etol) {
95 } else {
96 diagonal(i) = 1.0 / std::sqrt(es.eigenvalues()(i));
97 }
98 }
99
100 return es.eigenvectors() * diagonal.asDiagonal() *
101 es.eigenvectors().transpose();
102}
103
104} // namespace xtp
105} // namespace votca
Eigen::MatrixXd aomatrix_
Definition aomatrix.h:82
Eigen::MatrixXd Pseudo_InvSqrt(double etol)
Definition aomatrix.cc:88
Eigen::MatrixXd Pseudo_InvSqrt_GWBSE(const AOOverlap &auxoverlap, double etol)
Definition aomatrix.cc:53
Eigen::MatrixXd Pseudo_InvSqrt(double etol)
Definition aomatrix.cc:28
const Eigen::MatrixXd & Matrix() const
Definition aomatrix.h:52
double smallestEigenvalue
Definition aomatrix.h:63
Eigen::MatrixXd Sqrt()
Definition aomatrix.cc:45
Eigen::MatrixXd aomatrix_
Definition aomatrix.h:64
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26