24#include <unordered_map>
25#include <unordered_set>
48 const Eigen::VectorXd& dft_energies)
233 const Eigen::VectorXd& seed_energies,
234 const Eigen::VectorXd& qsgw_energies)
const;
247 Eigen::MatrixXd
getHQP()
const;
287 const std::string& version);
292 sigma_->setKeepScreeningData(keep);
297 return rpa_.getRPAInputEnergies();
305 double spacing)
const;
331 std::unique_ptr<Sigma_base>
sigma_ =
nullptr;
351 std::pair<double, double>
operator()(
double frequency)
const {
352 std::pair<double, double> result;
353 result.first =
value(frequency, EvalStage::Other);
354 result.second =
deriv(frequency);
362 if (!insert_result.second) {
363 ++
stats_.sigma_repeat_calls;
365 ++
stats_.sigma_unique_frequencies;
369 auto cached =
cache_.find(key);
370 if (cached !=
cache_.end()) {
371 return cached->second;
378 void Prefetch(
const std::vector<double>& frequencies)
const {
379 std::vector<double> todo;
380 for (
double f : frequencies) {
388 const Eigen::VectorXd values =
sigma_c_func_.CalcCorrelationDiagElements(
390 Eigen::Map<const Eigen::VectorXd>(todo.data(),
Index(todo.size())));
391 for (std::size_t i = 0; i < todo.size(); ++i) {
400 double deriv(
double frequency)
const {
411 std::uint64_t key = 0;
412 static_assert(
sizeof(double) ==
sizeof(std::uint64_t),
413 "Unexpected double size");
414 std::memcpy(&key, &x,
sizeof(
double));
420 case EvalStage::Scan:
421 ++
stats_.sigma_scan_calls;
423 case EvalStage::Refine:
424 ++
stats_.sigma_refine_calls;
426 case EvalStage::Derivative:
427 ++
stats_.sigma_derivative_calls;
429 case EvalStage::Other:
431 ++
stats_.sigma_other_calls;
441 mutable std::unordered_map<std::uint64_t, double>
cache_;
447 const Eigen::VectorXd& dft_energies)
const;
451 Eigen::VectorXd
SolveQP(
const Eigen::VectorXd& frequencies)
const;
468 double intercept0,
double frequency0,
Index gw_level,
471 const std::vector<QPRootCandidate>& roots,
472 double chosen)
const {
480 boost::optional<double>
SolveQP_Grid(
double intercept0,
double frequency0,
482 QPStats* stats =
nullptr)
const;
485 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
486 double right_limit,
bool allow_rejected_return =
true,
487 QPStats* stats =
nullptr)
const;
490 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
491 double right_limit,
bool allow_rejected_return =
true,
492 QPStats* stats =
nullptr)
const;
495 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
496 double right_limit,
bool allow_rejected_return =
true,
497 QPStats* stats =
nullptr)
const;
500 double frequency0,
Index gw_level,
501 QPStats* stats =
nullptr)
const;
505 QPStats* stats =
nullptr)
const;
506 bool Converged(
const Eigen::VectorXd& e1,
const Eigen::VectorXd& e2,
507 double epsilon)
const;
510 double lowerbound,
double f_lowerbound,
double upperbound,
511 double f_upperbound,
const QPFunc& f,
double reference)
const;
Wall-clock accounting for the parts of a DFT run.
void CountSigmaStage(EvalStage stage) const
std::unordered_map< std::uint64_t, double > cache_
double value(double frequency, EvalStage stage=EvalStage::Other) const
double sigma(double frequency, EvalStage stage=EvalStage::Other) const
const Sigma_base & sigma_c_func_
const QPStats & GetStats() const
std::unordered_set< std::uint64_t > seen_frequencies_
static std::uint64_t FrequencyKey(double x)
QPFunc(Index gw_level, const Sigma_base &sigma, double offset)
double deriv(double frequency) const
void Prefetch(const std::vector< double > &frequencies) const
std::pair< double, double > operator()(double frequency) const
boost::optional< double > SolveQP_Grid_Windowed(double intercept0, double frequency0, Index gw_level, double left_limit, double right_limit, bool allow_rejected_return=true, QPStats *stats=nullptr) const
Index QPIterations() const
const Eigen::VectorXd & getQSGWSeedEnergies() const
Return the seed (G0W0/evGW) energies that QSGW started from.
bool keep_screening_data_
Eigen::MatrixXd reaction_field_
void setReactionField(const Eigen::MatrixXd &R)
Screen by a static polarizable environment (embedded GW).
Eigen::SelfAdjointEigenSolver< Eigen::MatrixXd > DiagonalizeQPHamiltonian() const
void PrintGWA_Energies() const
Eigen::VectorXd tracked_change_
void DumpSigma(const sigma_dump_options &dopt, const std::string &gw_mode, const std::string &version)
Write the self-energy and screening data of the finished GW (G0W0 or evGW, ppm or exact) to a separat...
void setCoreExchange(const Eigen::MatrixXd &X)
boost::optional< qp_solver::RootCandidate > SolveQP_Tracked(double intercept0, double frequency0, Index gw_level, QPStats *stats) const
boost::optional< QPRootCandidate > RefineQPInterval(double lowerbound, double f_lowerbound, double upperbound, double f_upperbound, const QPFunc &f, double reference) const
Index ScreeningBuilds() const
Screening builds and QP iterations of the last evGW run.
void PrintQSGW_Energies(const std::string &seed_label, const Eigen::VectorXd &seed_energies, const Eigen::VectorXd &qsgw_energies) const
Print a two-column comparison of seed (G0W0 or evGW) vs converged QSGW quasiparticle energies.
Index TrackedLocalSolves() const
Level solves of the last evGW run done by root tracking (locally).
void PrintCompetingRoots(Log::Level level) const
void CalculateQSGW()
Run quasiparticle self-consistent GW (QSGW).
bool Converged(const Eigen::VectorXd &e1, const Eigen::VectorXd &e2, double epsilon) const
void configure(const options &opt)
boost::optional< double > SolveQP_Grid_Windowed_Adaptive(double intercept0, double frequency0, Index gw_level, double left_limit, double right_limit, bool allow_rejected_return=true, QPStats *stats=nullptr) const
Eigen::MatrixXd SigmaCurves(const std::vector< Index > &levels, Index steps, double spacing) const
Eigen::VectorXd qp_solution_
Eigen::MatrixXd getHQP() const
Index tracked_local_total_
Eigen::VectorXd SolveQP(const Eigen::VectorXd &frequencies) const
qp_solver::EvalStage EvalStage
void PrintReactionFieldShifts() const
void setKeepScreeningData(bool keep)
Call after configure and before CalculateGWPerturbation.
Eigen::VectorXd rpa_energies_solved_
boost::optional< double > SolveQP_Grid_Windowed_Dense(double intercept0, double frequency0, Index gw_level, double left_limit, double right_limit, bool allow_rejected_return=true, QPStats *stats=nullptr) const
qp_solver::RootCandidate QPRootCandidate
void PrintQSGW_Composition(double threshold=0.01) const
Print the dominant DFT-KS orbital contributions to each converged QSGW quasiparticle state.
Eigen::MatrixXd Sigma_reac_
Eigen::VectorXd qsgw_seed_energies_
const Eigen::VectorXd & dft_energies_
std::unique_ptr< Sigma_base > sigma_
std::vector< qp_solver::CompetingRoots > competing_roots_
Eigen::VectorXd qsgw_final_energies_
Eigen::VectorXd getGWAResults() const
Eigen::VectorXd RPAInputEnergies() const
const Eigen::MatrixXd & getSigmaReac() const
Eigen::VectorXd tracked_Z_
void DressForEnvironment()
qp_solver::WindowDiagnostics QPWindowDiagnostics
double CalcHomoLumoShift(Eigen::VectorXd frequencies) const
boost::optional< double > SolveQP_Grid(double intercept0, double frequency0, Index gw_level, QPStats *stats=nullptr) const
const Eigen::MatrixXd & vxc_
void RecordCompetingRoots(Index gw_level, const std::vector< QPRootCandidate > &roots, double chosen) const
void PrintQP_Energies(const Eigen::VectorXd &qp_diag_energies) const
const Eigen::MatrixXd & getQSGWRotation() const
void PlotSigma(std::string filename, Index steps, double spacing, std::string states)
boost::optional< double > SolveQP_FixedPoint(double intercept0, double frequency0, Index gw_level, QPStats *stats=nullptr) const
Eigen::VectorXd ScissorShift_DFTlevel(const Eigen::VectorXd &dft_energies) const
GW(Logger &log, TCMatrix_gwbse &Mmn, const Eigen::MatrixXd &vxc, const Eigen::VectorXd &dft_energies)
boost::optional< double > SolveQP_Linearisation(double intercept0, double frequency0, Index gw_level, QPStats *stats=nullptr) const
void CalculateGWPerturbation()
Eigen::MatrixXd qsgw_rotation_
Eigen::MatrixXd dressing_
Eigen::MatrixXd core_exchange_
Eigen::VectorXd tracked_root_
Logger is used for thread-safe output of messages.
CompetingRoots CheckCompetingRoots(const std::vector< RootCandidate > &roots, double chosen)
Provides a means for comparing floating point numbers.
OutOfWindowShift out_of_window_shift
double qp_full_window_half_width
double qsgw_max_virt_correction
Index qp_adaptive_shell_count
bool qsgw_hartree_screened
double qp_adaptive_shell_width
std::string screening_update
double screening_update_ratio
std::string qp_grid_search_mode
double qp_virtual_min_energy
Index screening_update_max_inner
Index gw_sc_max_iterations
std::string quadrature_scheme
Index g_sc_max_iterations
std::string qp_root_finder
std::string sigma_integration
Index qsgw_max_iterations
std::string qsgw_regularization
Options of DumpSigma (energies in Hartree unless noted).
How the RPA energies of levels outside the GW window are shifted.