votca 2026-dev
Loading...
Searching...
No Matches
sigma_exact.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 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
21#include "sigma_exact.h"
23#include "votca/xtp/rpa.h"
25#include "votca/xtp/vc2index.h"
26
27namespace votca {
28namespace xtp {
29
31 RPA::rpa_eigensolution rpa_solution;
32 {
33 OptionalTiming t(timings_, "screening: RPA pair eigenproblem");
34 rpa_solution = rpa_.Diagonalize_H2p();
35 }
36 OptionalTiming t(timings_, "screening: residues");
37 rpa_omegas_ = rpa_solution.omega;
38 // residues of level m: M_m Z with the screening modes
39 // Z = sum_v M_v,virt^T (X+Y)_v, once for all levels
40 const Eigen::MatrixXd modes = ScreeningModes(rpa_solution.XpY);
41 const Index B = Mmn_.nsize();
42 const Index S = rpa_omegas_.size();
43 residues_.resize(B * S, qptotal_);
44 const Index qpoffset = opt_.qpmin - opt_.rpamin;
45#pragma omp parallel for schedule(dynamic)
46 for (Index gw_level = 0; gw_level < qptotal_; gw_level++) {
47 Eigen::Map<Eigen::MatrixXd>(residues_.col(gw_level).data(), B, S)
48 .noalias() = Mmn_[gw_level + qpoffset] * modes;
49 }
50}
51
53 return ExactPoles{rpa_.getRPAInputEnergies(), opt_.homo + 1 - opt_.rpamin,
54 rpa_omegas_, opt_.eta};
55}
56
58 double frequency) const {
60 // factor 2: both (identical) spin channels
61 return 2.0 * exact_pole_sums::Value(Poles(), Residues(gw_level), frequency);
62}
63
65 Index gw_level, const Eigen::VectorXd& frequencies) const {
66 for (Index i = 0; i < frequencies.size(); ++i) {
68 }
69 return 2.0 *
70 exact_pole_sums::Values(Poles(), Residues(gw_level), frequencies);
71}
72
74 Index gw_level, double frequency) const {
75 return 2.0 *
76 exact_pole_sums::Derivative(Poles(), Residues(gw_level), frequency);
77}
78
80 Index gw_level2,
81 double frequency1,
82 double frequency2) const {
83 // 2 (both spins) x 1/2 (symmetrised in the two frequencies)
84 const Eigen::Vector2d w(frequency1, frequency2);
85 const ExactPoles poles = Poles();
86 const Eigen::VectorXd r12 =
87 residues_.col(gw_level1).cwiseProduct(residues_.col(gw_level2));
88 const Eigen::VectorXd sums =
89 exact_pole_sums::ValuesDirectWeighted(poles, r12.data(), w);
90 return sums(0) + sums(1);
91}
92
94 const Eigen::VectorXd& frequencies) const {
95 return exact_pole_sums::OffDiagonal(Poles(), residues_, frequencies);
96}
97
98Eigen::MatrixXd Sigma_Exact::ScreeningModes(const Eigen::MatrixXd& XpY) const {
99 const Index lumo = opt_.homo + 1;
100 const Index n_occ = lumo - opt_.rpamin;
101 const Index n_unocc = opt_.rpamax - opt_.homo;
102 const Index rpasize = n_occ * n_unocc;
103 vc2index vc = vc2index(0, 0, n_unocc);
104 // rows (v, c) of the virtual rows of the hole slices
105 Eigen::MatrixXd M(rpasize, Mmn_.auxsize());
106#pragma omp parallel for schedule(dynamic)
107 for (Index v = 0; v < n_occ; v++) {
108 M.middleRows(vc.I(v, 0), n_unocc) = Mmn_[v].middleRows(n_occ, n_unocc);
109 }
110 return M.transpose() * XpY;
111}
112
113} // namespace xtp
114} // namespace votca
Eigen::VectorXd CalcCorrelationDiagElements(Index gw_level, const Eigen::VectorXd &frequencies) const final
Eigen::MatrixXd residues_
Definition sigma_exact.h:63
Eigen::MatrixXd CalcCorrelationOffDiag(const Eigen::VectorXd &frequencies) const final
All off-diagonal elements as blocked matrix products.
ExactPoles Poles() const
Eigen::MatrixXd ScreeningModes(const Eigen::MatrixXd &XpY) const
const double * Residues(Index gw_level) const
Definition sigma_exact.h:66
double CalcCorrelationDiagElementDerivative(Index gw_level, double frequency) const final
void PrepareScreening() final
double CalcCorrelationDiagElement(Index gw_level, double frequency) const final
Eigen::VectorXd rpa_omegas_
Definition sigma_exact.h:60
double CalcCorrelationOffDiagElement(Index gw_level1, Index gw_level2, double frequency1, double frequency2) const final
DFTTimings * timings_
Definition sigma_base.h:144
TCMatrix_gwbse & Mmn_
Definition sigma_base.h:142
void CountDiagEval() const
Definition sigma_base.h:149
This class transforms a pair of indices v,c into a compound index I, via I=ctotal*v+c the fast dimens...
Definition vc2index.h:36
Index I(Index v, Index c) const
Definition vc2index.h:42
double Value(const ExactPoles &poles, const double *residues, double w)
S_n(w) at one frequency.
double Derivative(const ExactPoles &poles, const double *residues, double w)
dS_n/dw at one frequency
Eigen::MatrixXd OffDiagonal(const ExactPoles &poles, const Eigen::MatrixXd &residues_all, const Eigen::VectorXd &w)
Eigen::VectorXd Values(const ExactPoles &poles, const double *residues, const Eigen::VectorXd &w)
Eigen::VectorXd ValuesDirectWeighted(const ExactPoles &poles, const double *weights, const Eigen::VectorXd &w)
sum_p a_p f(w - z_p) with given weights a_p (e.g. r_n1 r_n2)
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
Pole sums of the exact (RPA spectral) correlation self-energy.