votca 2026-dev
Loading...
Searching...
No Matches
rpa.h
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#pragma once
21#ifndef VOTCA_XTP_RPA_H
22#define VOTCA_XTP_RPA_H
23
24// Standard includes
25#include <vector>
26
27// Local VOTCA includes
28#include "eigen.h"
29#include "logger.h"
30#include "out_of_window_shift.h"
31#include "screening_kernels.h"
32
33namespace votca {
34namespace xtp {
35class TCMatrix_gwbse;
36
37class RPA {
38 public:
39 RPA(Logger& log, const TCMatrix_gwbse& Mmn) : log_(log), Mmn_(Mmn) {};
40
41 void configure(Index homo, Index rpamin, Index rpamax) {
42 homo_ = homo;
43 rpamin_ = rpamin;
44 rpamax_ = rpamax;
45 }
46
47 double getEta() const { return eta_; }
48
51 out_of_window_ = shift;
52 }
53
55 void setTimings(DFTTimings* timings) { timings_ = timings; }
56
57 Eigen::MatrixXd calculate_epsilon_i(double frequency) const {
58 return calculate_epsilon<true>(frequency);
59 }
60
61 Eigen::MatrixXd calculate_epsilon_r(double frequency) const {
62 return calculate_epsilon<false>(frequency);
63 }
64
65 Eigen::MatrixXd calculate_epsilon_r(std::complex<double> frequency) const;
66
67 const Eigen::VectorXd& getRPAInputEnergies() const { return energies_; }
68
69 void setRPAInputEnergies(const Eigen::VectorXd& rpaenergies) {
70 energies_ = rpaenergies;
71 }
72
73 // calculates full RPA vector of energies from gwa and dftenergies and qpmin
74 // RPA energies have three parts, lower than qpmin: dftenergies,between qpmin
75 // and qpmax:gwa_energies,above:dftenergies+homo-lumo shift
76 void UpdateRPAInputEnergies(const Eigen::VectorXd& dftenergies,
77 const Eigen::VectorXd& gwaenergies, Index qpmin);
78
80 Eigen::VectorXd omega; // Eigenvalues
81 Eigen::MatrixXd XpY; // Eigenvector components (X + Y)
82 double ERPA_correlation; // total correlation energy
83 };
84
86
87 private:
88 Index homo_; // HOMO index with respect to dft energies
91 const double eta_ = 0.0001;
92
93 Eigen::VectorXd energies_;
94
97 DFTTimings* timings_ = nullptr;
98
99 // Calls use() with the virtual rows of hole slice m_level.
100 void VisitHoleVirtualRows(Index m_level,
101 const WeightedGram::RowsVisitor& use) const;
102 // sum_v M_v^T diag(w_v) M_v over the hole slices v, M_v their virtual rows
103 Eigen::MatrixXd ResponseSum(const WeightedGram::WeightsFn& weights) const;
104
105 template <bool imag>
106 Eigen::MatrixXd calculate_epsilon(double frequency) const;
107
108 Eigen::VectorXd Calculate_H2p_AmB() const;
109 Eigen::MatrixXd Calculate_H2p_ApB() const;
110 SymmetricEigenSystem Diagonalize_H2p_C(const Eigen::MatrixXd& C) const;
111
112 void ShiftUncorrectedEnergies(const Eigen::VectorXd& dftenergies, Index qpmin,
113 Index gwsize);
114
116};
117
118} // namespace xtp
119} // namespace votca
120
121#endif // VOTCA_XTP_RPA_H
Wall-clock accounting for the parts of a DFT run.
Definition dfttimings.h:45
Logger is used for thread-safe output of messages.
Definition logger.h:164
RPA(Logger &log, const TCMatrix_gwbse &Mmn)
Definition rpa.h:39
Eigen::MatrixXd Calculate_H2p_ApB() const
Definition rpa.cc:190
Eigen::MatrixXd calculate_epsilon_i(double frequency) const
Definition rpa.h:57
void ShiftUncorrectedEnergies(const Eigen::VectorXd &dftenergies, Index qpmin, Index gwsize)
Definition rpa.cc:46
Eigen::MatrixXd ResponseSum(const WeightedGram::WeightsFn &weights) const
Definition rpa.cc:58
Index rpamax_
Definition rpa.h:90
OutOfWindowShift out_of_window_
Definition rpa.h:115
void setRPAInputEnergies(const Eigen::VectorXd &rpaenergies)
Definition rpa.h:69
Eigen::VectorXd energies_
Definition rpa.h:93
void setTimings(DFTTimings *timings)
Times the dielectric-matrix builds in these timings (optional).
Definition rpa.h:55
void VisitHoleVirtualRows(Index m_level, const WeightedGram::RowsVisitor &use) const
Definition rpa.cc:52
Eigen::MatrixXd calculate_epsilon(double frequency) const
Definition rpa.cc:70
Eigen::MatrixXd calculate_epsilon_r(double frequency) const
Definition rpa.h:61
void setOutOfWindowShift(const OutOfWindowShift &shift)
How levels outside the GW window are shifted by UpdateRPAInputEnergies.
Definition rpa.h:50
const TCMatrix_gwbse & Mmn_
Definition rpa.h:96
const double eta_
Definition rpa.h:91
Index rpamin_
Definition rpa.h:89
SymmetricEigenSystem Diagonalize_H2p_C(const Eigen::MatrixXd &C) const
Definition rpa.cc:213
Eigen::VectorXd Calculate_H2p_AmB() const
Definition rpa.cc:175
void configure(Index homo, Index rpamin, Index rpamax)
Definition rpa.h:41
double getEta() const
Definition rpa.h:47
const Eigen::VectorXd & getRPAInputEnergies() const
Definition rpa.h:67
Logger & log_
Definition rpa.h:95
rpa_eigensolution Diagonalize_H2p() const
Definition rpa.cc:113
void UpdateRPAInputEnergies(const Eigen::VectorXd &dftenergies, const Eigen::VectorXd &gwaenergies, Index qpmin)
Definition rpa.cc:32
DFTTimings * timings_
Definition rpa.h:97
Index homo_
Definition rpa.h:88
std::function< void(Index m, Eigen::VectorXd &w)> WeightsFn
Writes the weights of block m; their number is the number of rows.
std::function< void(const Eigen::Ref< const Eigen::MatrixXd > &)> RowsVisitor
Calls use(R_m); R_m may be a block of stored data or a temporary.
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
How the RPA energies of levels outside the GW window are shifted.