votca 2024.2-dev
Loading...
Searching...
No Matches
gw.h
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#pragma once
21#ifndef VOTCA_XTP_GW_H
22#define VOTCA_XTP_GW_H
23
24// Local VOTCA includes
25#include "logger.h"
26#include "orbitals.h"
27#include "rpa.h"
28#include "sigma_base.h"
29#include "threecenter.h"
30
31namespace votca {
32namespace xtp {
33
34class GW {
35 public:
36 GW(Logger& log, TCMatrix_gwbse& Mmn, const Eigen::MatrixXd& vxc,
37 const Eigen::VectorXd& dft_energies)
38 : log_(log),
39 Mmn_(Mmn),
40 vxc_(vxc),
41 dft_energies_(dft_energies),
42 rpa_(log, Mmn) {};
43
44 struct options {
50 double eta;
51 double g_sc_limit;
55 double shift = 0;
56 double ScaHFX = 0.0;
57 std::string sigma_integration;
58 Index reset_3c; // how often the 3c integrals in iterate should be
59 // rebuilt
60 std::string qp_solver;
61 double qp_solver_alpha = 0.75;
62 Index qp_grid_steps; // Number of grid points
63 double qp_grid_spacing; // Spacing of grid points in Ha
64 Index gw_mixing_order; // mixing order
65 double gw_mixing_alpha; // mixing alpha, also linear mixing
66 std::string quadrature_scheme; // Kind of Gaussian-quadrature scheme to use
67 Index order; // only needed for complex integration sigma CDA
68 double alpha; // smooth tail in complex integration sigma CDA
69 };
70
71 void configure(const options& opt);
72
73 Eigen::VectorXd getGWAResults() const;
74 // Calculates the diagonal elements up to self consistency
76
77 // Calculated offdiagonal elements as well
78 void CalculateHQP();
79
80 Eigen::MatrixXd getHQP() const;
81
82 // Diagonalize QP particle Hamiltonian
83 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> DiagonalizeQPHamiltonian()
84 const;
85
86 void PlotSigma(std::string filename, Index steps, double spacing,
87 std::string states) const;
88
89 Eigen::VectorXd RPAInputEnergies() const {
91 }
92
93 private:
95
96 Eigen::MatrixXd Sigma_x_;
97 Eigen::MatrixXd Sigma_c_;
98
100
101 std::unique_ptr<Sigma_base> sigma_ = nullptr;
104 const Eigen::MatrixXd& vxc_;
105 const Eigen::VectorXd& dft_energies_;
106
108 // small class which calculates f(w) with and df/dw(w)
109 // f=Sigma_c(w)+offset-w
110 // offset= e_dft+Sigma_x-Vxc
111 class QPFunc {
112 public:
113 QPFunc(Index gw_level, const Sigma_base& sigma, double offset)
114 : gw_level_(gw_level), offset_(offset), sigma_c_func_(sigma) {};
115 std::pair<double, double> operator()(double frequency) const {
116 std::pair<double, double> result;
117 result.first = value(frequency);
118 result.second = deriv(frequency);
119
120 return result;
121 }
122 double value(double frequency) const {
124 offset_ - frequency;
125 }
126 double deriv(double frequency) const {
128 frequency) -
129 1.0;
130 }
131
132 private:
134 double offset_;
136 };
137
138 double SolveQP_Bisection(double lowerbound, double f_lowerbound,
139 double upperbound, double f_upperbound,
140 const QPFunc& f) const;
141 double CalcHomoLumoShift(Eigen::VectorXd frequencies) const;
142 Eigen::VectorXd ScissorShift_DFTlevel(
143 const Eigen::VectorXd& dft_energies) const;
144 void PrintQP_Energies(const Eigen::VectorXd& qp_diag_energies) const;
145 void PrintGWA_Energies() const;
146
147 Eigen::VectorXd SolveQP(const Eigen::VectorXd& frequencies) const;
148 boost::optional<double> SolveQP_Grid(double intercept0, double frequency0,
149 Index gw_level) const;
150 boost::optional<double> SolveQP_FixedPoint(double intercept0,
151 double frequency0,
152 Index gw_level) const;
153 boost::optional<double> SolveQP_Linearisation(double intercept0,
154 double frequency0,
155 Index gw_level) const;
156 bool Converged(const Eigen::VectorXd& e1, const Eigen::VectorXd& e2,
157 double epsilon) const;
158};
159} // namespace xtp
160} // namespace votca
161
162#endif // VOTCA_XTP_GW_H
const Sigma_base & sigma_c_func_
Definition gw.h:135
QPFunc(Index gw_level, const Sigma_base &sigma, double offset)
Definition gw.h:113
double deriv(double frequency) const
Definition gw.h:126
std::pair< double, double > operator()(double frequency) const
Definition gw.h:115
double value(double frequency) const
Definition gw.h:122
void PlotSigma(std::string filename, Index steps, double spacing, std::string states) const
Definition gw.cc:432
Index qptotal_
Definition gw.h:94
Eigen::SelfAdjointEigenSolver< Eigen::MatrixXd > DiagonalizeQPHamiltonian() const
Definition gw.cc:68
void PrintGWA_Energies() const
Definition gw.cc:75
RPA rpa_
Definition gw.h:107
double SolveQP_Bisection(double lowerbound, double f_lowerbound, double upperbound, double f_upperbound, const QPFunc &f) const
Definition gw.cc:382
boost::optional< double > SolveQP_FixedPoint(double intercept0, double frequency0, Index gw_level) const
Definition gw.cc:367
bool Converged(const Eigen::VectorXd &e1, const Eigen::VectorXd &e2, double epsilon) const
Definition gw.cc:413
void configure(const options &opt)
Definition gw.cc:35
options opt_
Definition gw.h:99
Eigen::MatrixXd getHQP() const
Definition gw.cc:62
Eigen::VectorXd SolveQP(const Eigen::VectorXd &frequencies) const
Definition gw.cc:242
TCMatrix_gwbse & Mmn_
Definition gw.h:103
Eigen::MatrixXd Sigma_c_
Definition gw.h:97
boost::optional< double > SolveQP_Grid(double intercept0, double frequency0, Index gw_level) const
Definition gw.cc:314
const Eigen::VectorXd & dft_energies_
Definition gw.h:105
std::unique_ptr< Sigma_base > sigma_
Definition gw.h:101
void CalculateHQP()
Definition gw.cc:426
Logger & log_
Definition gw.h:102
Eigen::VectorXd getGWAResults() const
Definition gw.cc:237
Eigen::VectorXd RPAInputEnergies() const
Definition gw.h:89
double CalcHomoLumoShift(Eigen::VectorXd frequencies) const
Definition gw.cc:55
const Eigen::MatrixXd & vxc_
Definition gw.h:104
void PrintQP_Energies(const Eigen::VectorXd &qp_diag_energies) const
Definition gw.cc:108
boost::optional< double > SolveQP_Linearisation(double intercept0, double frequency0, Index gw_level) const
Definition gw.cc:299
Eigen::VectorXd ScissorShift_DFTlevel(const Eigen::VectorXd &dft_energies) const
Definition gw.cc:135
GW(Logger &log, TCMatrix_gwbse &Mmn, const Eigen::MatrixXd &vxc, const Eigen::VectorXd &dft_energies)
Definition gw.h:36
Eigen::MatrixXd Sigma_x_
Definition gw.h:96
void CalculateGWPerturbation()
Definition gw.cc:143
Logger is used for thread-safe output of messages.
Definition logger.h:164
const Eigen::VectorXd & getRPAInputEnergies() const
Definition rpa.h:57
virtual double CalcCorrelationDiagElementDerivative(Index gw_level, double frequency) const =0
virtual double CalcCorrelationDiagElement(Index gw_level, double frequency) const =0
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
double qp_solver_alpha
Definition gw.h:61
double gw_sc_limit
Definition gw.h:53
Index gw_mixing_order
Definition gw.h:64
Index gw_sc_max_iterations
Definition gw.h:54
Index qp_grid_steps
Definition gw.h:62
std::string quadrature_scheme
Definition gw.h:66
std::string qp_solver
Definition gw.h:60
Index g_sc_max_iterations
Definition gw.h:52
double qp_grid_spacing
Definition gw.h:63
double g_sc_limit
Definition gw.h:51
double gw_mixing_alpha
Definition gw.h:65
std::string sigma_integration
Definition gw.h:57