24#include <unordered_map>
25#include <unordered_set>
48 const Eigen::VectorXd& dft_energies)
222 const Eigen::VectorXd& seed_energies,
223 const Eigen::VectorXd& qsgw_energies)
const;
236 Eigen::MatrixXd
getHQP()
const;
243 std::string states)
const;
246 return rpa_.getRPAInputEnergies();
272 std::unique_ptr<Sigma_base>
sigma_ =
nullptr;
292 std::pair<double, double>
operator()(
double frequency)
const {
293 std::pair<double, double> result;
294 result.first =
value(frequency, EvalStage::Other);
295 result.second =
deriv(frequency);
303 if (!insert_result.second) {
304 ++
stats_.sigma_repeat_calls;
306 ++
stats_.sigma_unique_frequencies;
310 auto cached =
cache_.find(key);
311 if (cached !=
cache_.end()) {
312 return cached->second;
319 void Prefetch(
const std::vector<double>& frequencies)
const {
320 std::vector<double> todo;
321 for (
double f : frequencies) {
329 const Eigen::VectorXd values =
sigma_c_func_.CalcCorrelationDiagElements(
331 Eigen::Map<const Eigen::VectorXd>(todo.data(),
Index(todo.size())));
332 for (std::size_t i = 0; i < todo.size(); ++i) {
341 double deriv(
double frequency)
const {
352 std::uint64_t key = 0;
353 static_assert(
sizeof(double) ==
sizeof(std::uint64_t),
354 "Unexpected double size");
355 std::memcpy(&key, &x,
sizeof(
double));
361 case EvalStage::Scan:
362 ++
stats_.sigma_scan_calls;
364 case EvalStage::Refine:
365 ++
stats_.sigma_refine_calls;
367 case EvalStage::Derivative:
368 ++
stats_.sigma_derivative_calls;
370 case EvalStage::Other:
372 ++
stats_.sigma_other_calls;
382 mutable std::unordered_map<std::uint64_t, double>
cache_;
388 const Eigen::VectorXd& dft_energies)
const;
392 Eigen::VectorXd
SolveQP(
const Eigen::VectorXd& frequencies)
const;
409 double intercept0,
double frequency0,
Index gw_level,
412 const std::vector<QPRootCandidate>& roots,
413 double chosen)
const {
421 boost::optional<double>
SolveQP_Grid(
double intercept0,
double frequency0,
423 QPStats* stats =
nullptr)
const;
426 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
427 double right_limit,
bool allow_rejected_return =
true,
428 QPStats* stats =
nullptr)
const;
431 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
432 double right_limit,
bool allow_rejected_return =
true,
433 QPStats* stats =
nullptr)
const;
436 double intercept0,
double frequency0,
Index gw_level,
double left_limit,
437 double right_limit,
bool allow_rejected_return =
true,
438 QPStats* stats =
nullptr)
const;
441 double frequency0,
Index gw_level,
442 QPStats* stats =
nullptr)
const;
446 QPStats* stats =
nullptr)
const;
447 bool Converged(
const Eigen::VectorXd& e1,
const Eigen::VectorXd& e2,
448 double epsilon)
const;
451 double lowerbound,
double f_lowerbound,
double upperbound,
452 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
void PlotSigma(std::string filename, Index steps, double spacing, std::string states) const
Index QPIterations() const
const Eigen::VectorXd & getQSGWSeedEnergies() const
Return the seed (G0W0/evGW) energies that QSGW started from.
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 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 getHQP() const
Index tracked_local_total_
Eigen::VectorXd SolveQP(const Eigen::VectorXd &frequencies) const
qp_solver::EvalStage EvalStage
void PrintReactionFieldShifts() const
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
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
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
How the RPA energies of levels outside the GW window are shifted.