25#include <unordered_map>
26#include <unordered_set>
49 const Eigen::VectorXd& dft_energies)
242 const Eigen::VectorXd& seed_energies,
243 const Eigen::VectorXd& qsgw_energies)
const;
256 Eigen::MatrixXd
getHQP()
const;
296 const std::string& version);
301 sigma_->setKeepScreeningData(keep);
306 return rpa_.getRPAInputEnergies();
314 double spacing)
const;
341 std::unique_ptr<Sigma_base>
sigma_ =
nullptr;
361 std::pair<double, double>
operator()(
double frequency)
const {
362 std::pair<double, double> result;
363 result.first =
value(frequency, EvalStage::Other);
364 result.second =
deriv(frequency);
372 if (!insert_result.second) {
373 ++
stats_.sigma_repeat_calls;
375 ++
stats_.sigma_unique_frequencies;
379 auto cached =
cache_.find(key);
380 if (cached !=
cache_.end()) {
381 return cached->second;
388 void Prefetch(
const std::vector<double>& frequencies)
const {
389 std::vector<double> todo;
390 for (
double f : frequencies) {
398 const Eigen::VectorXd values =
sigma_c_func_.CalcCorrelationDiagElements(
400 Eigen::Map<const Eigen::VectorXd>(todo.data(),
Index(todo.size())));
401 for (std::size_t i = 0; i < todo.size(); ++i) {
410 double deriv(
double frequency)
const {
421 std::uint64_t key = 0;
422 static_assert(
sizeof(double) ==
sizeof(std::uint64_t),
423 "Unexpected double size");
424 std::memcpy(&key, &x,
sizeof(
double));
430 case EvalStage::Scan:
431 ++
stats_.sigma_scan_calls;
433 case EvalStage::Refine:
434 ++
stats_.sigma_refine_calls;
436 case EvalStage::Derivative:
437 ++
stats_.sigma_derivative_calls;
439 case EvalStage::Other:
441 ++
stats_.sigma_other_calls;
451 mutable std::unordered_map<std::uint64_t, double>
cache_;
457 const Eigen::VectorXd& dft_energies)
const;
461 Eigen::VectorXd
SolveQP(
const Eigen::VectorXd& frequencies)
const;
478 double intercept0,
double frequency0,
Index gw_level,
481 const std::vector<QPRootCandidate>& roots,
482 double chosen)
const {
490 boost::optional<double>
SolveQP_Grid(
double intercept0,
double frequency0,
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 intercept0,
double frequency0,
Index gw_level,
double left_limit,
501 double right_limit,
bool allow_rejected_return =
true,
502 QPStats* stats =
nullptr)
const;
505 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
506 double right_limit,
bool allow_rejected_return =
true,
507 QPStats* stats =
nullptr)
const;
510 double frequency0,
Index gw_level,
511 QPStats* stats =
nullptr)
const;
515 QPStats* stats =
nullptr)
const;
516 bool Converged(
const Eigen::VectorXd& e1,
const Eigen::VectorXd& e2,
517 double epsilon)
const;
520 double lowerbound,
double f_lowerbound,
double upperbound,
521 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 setScreeningHook(ScreeningHook hook)
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
std::function< void(const Eigen::VectorXd &)> ScreeningHook
void CalculateGWPerturbation()
Eigen::MatrixXd qsgw_rotation_
Eigen::MatrixXd dressing_
Eigen::MatrixXd core_exchange_
ScreeningHook screening_hook_
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.