Loading...
Searching...
No Matches
q3::SCFIterator Class Referenceabstract

#include <init.hpp>

+ Inheritance diagram for q3::SCFIterator:

Public Member Functions

 SCFIterator (SCFIteratorConfig config)
 
virtual ~SCFIterator ()=default
 
bool is_converged () const
 
int iteration () const
 
int number_of_spin_components () const
 
void run ()
 
void set_convergence_threshold (Real threshold)
 Set the SCF convergence threshold (in Ry).
 
void set_maximum_iterations (int maximum_iterations)
 Set the maximum number of SCF iterations.
 
void set_owned_crystal (Crystal crystal)
 Transfer ownership of a Crystal into this iterator.
 
virtual Real total_energy () const =0
 
const std::vector< Real > & total_energy_history_in_ry () const
 
virtual void write_checkpoints (const std::string &output_directory, const std::string &prefix) const
 

Protected Member Functions

virtual void finalize ()=0
 
virtual void initialize ()
 Base implementation prints the SCF banner. Children call SCFIterator::initialize() last.
 
virtual bool is_iteration_converged () const =0
 
virtual void iterate ()
 Main iteration loop.
 
virtual void perform_iteration ()=0
 
virtual void report ()
 Report convergence or non-convergence after iterate() finishes.
 
virtual void report_convergence ()=0
 
virtual void report_iteration ()=0
 
virtual void report_non_convergence ()=0
 

Protected Attributes

Real convergence_threshold_
 
Crystal * crystal_structure_
 
bool is_converged_ {false}
 
int iteration_ {0}
 
int maximum_iterations_
 

Detailed Description

Definition at line 23 of file init.hpp.

Constructor & Destructor Documentation

◆ SCFIterator()

q3::SCFIterator::SCFIterator ( SCFIteratorConfig  config)
inlineexplicit

Definition at line 25 of file init.hpp.

◆ ~SCFIterator()

virtual q3::SCFIterator::~SCFIterator ( )
virtualdefault

Member Function Documentation

◆ finalize()

virtual void q3::SCFIterator::finalize ( )
protectedpure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by iterate().

◆ initialize()

virtual void q3::SCFIterator::initialize ( )
inlineprotectedvirtual

Base implementation prints the SCF banner. Children call SCFIterator::initialize() last.

Run state, like the two above: a second run() reports its own trajectory rather than one appended to the previous run's.

Reimplemented in q3::KohnShamSCFIterator.

Definition at line 122 of file init.hpp.

References is_converged_, iteration_, and q3::log::section().

Referenced by q3::KohnShamSCFIterator::initialize(), and run().

◆ is_converged()

◆ is_iteration_converged()

◆ iterate()

virtual void q3::SCFIterator::iterate ( )
inlineprotectedvirtual

Main iteration loop.

iteration_ is assigned from the loop counter rather than being it, so it never steps past the last iteration performed. Were it the counter, a run that exhausted its budget would leave it one past that budget, and the count read after run() – by the SCF state, the checkpoint header and the results file – would name an iteration that never ran.

Definition at line 135 of file init.hpp.

References finalize(), is_converged_, is_iteration_converged(), iteration_, maximum_iterations_, perform_iteration(), report_iteration(), and total_energy().

Referenced by run().

◆ iteration()

int q3::SCFIterator::iteration ( ) const
inline

The iteration in progress while run() iterates, numbered from 1.

After run() it is the number of iterations performed, on either exit: the iteration the run converged on, or the whole budget when it did not.

Definition at line 39 of file init.hpp.

References iteration_.

Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), q3::SelfConsistentFieldFlavor::run_calculation(), q3::PlanewaveKohnShamSCFIterator::set_diagonalization_tolerance(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints().

◆ number_of_spin_components()

int q3::SCFIterator::number_of_spin_components ( ) const
inline

Definition at line 45 of file init.hpp.

Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::add_augmentation_to_charge_density(), q3::PlanewaveKohnShamSCFIterator::compute_delta_escf_correction(), q3::PlanewaveKohnShamSCFIterator::compute_double_counting_correction(), q3::PlanewaveKohnShamSCFIterator::compute_energy_components(), q3::PlanewaveKohnShamSCFIterator::compute_local_residual_between(), q3::PlanewaveKohnShamSCFIterator::construct_density_from_states(), q3::PlanewaveKohnShamSCFIterator::global_eigenvalues(), q3::KohnShamSCFIterator::initialize(), q3::PlanewaveKohnShamSCFIterator::initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), q3::PlanewaveKohnShamSCFIterator::loaded_charge_density_fits_grid(), q3::PlanewaveKohnShamSCFIterator::log_representation_summary(), q3::PlanewaveKohnShamSCFIterator::mix_density(), q3::PlanewaveKohnShamSCFIterator::number_of_kpoint_states(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::on_charge_density_initialized(), q3::PlanewaveKohnShamSCFIterator::preload_charge_density(), q3::PlanewaveKohnShamSCFIterator::report_convergence_details(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::reset_projector_overlap_coefficients(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::snapshot_smooth_density(), q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states(), q3::PlanewaveKohnShamSCFIterator::symmetrize_density(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::symmetrize_density(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::synchronize_smooth_density_from_mixed(), q3::PlanewavePseudopotentialKohnShamSCFIterator::valence_exchange_correlation_potential_g_of(), q3::PlanewaveKohnShamSCFIterator::warn_if_total_charge_deviates(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints().

◆ perform_iteration()

virtual void q3::SCFIterator::perform_iteration ( )
protectedpure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by iterate().

◆ report()

virtual void q3::SCFIterator::report ( )
inlineprotectedvirtual

Report convergence or non-convergence after iterate() finishes.

Definition at line 160 of file init.hpp.

References is_converged_, report_convergence(), and report_non_convergence().

Referenced by run().

◆ report_convergence()

virtual void q3::SCFIterator::report_convergence ( )
protectedpure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by report().

◆ report_iteration()

virtual void q3::SCFIterator::report_iteration ( )
protectedpure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by iterate().

◆ report_non_convergence()

virtual void q3::SCFIterator::report_non_convergence ( )
protectedpure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by report().

◆ run()

void q3::SCFIterator::run ( )
inline

Definition at line 82 of file init.hpp.

References q3::log::info(), initialize(), iterate(), and report().

Referenced by q3::SelfConsistentFieldFlavor::run_calculation().

◆ set_convergence_threshold()

void q3::SCFIterator::set_convergence_threshold ( Real  threshold)
inline

Set the SCF convergence threshold (in Ry).

Definition at line 68 of file init.hpp.

References convergence_threshold_.

◆ set_maximum_iterations()

void q3::SCFIterator::set_maximum_iterations ( int  maximum_iterations)
inline

Set the maximum number of SCF iterations.

Definition at line 72 of file init.hpp.

References maximum_iterations_.

◆ set_owned_crystal()

void q3::SCFIterator::set_owned_crystal ( Crystal  crystal)
inline

Transfer ownership of a Crystal into this iterator.

Definition at line 77 of file init.hpp.

References crystal_structure_.

◆ total_energy()

virtual Real q3::SCFIterator::total_energy ( ) const
pure virtual

Implemented in q3::KohnShamSCFIterator.

Referenced by iterate().

◆ total_energy_history_in_ry()

const std::vector< Real > & q3::SCFIterator::total_energy_history_in_ry ( ) const
inline

Total energy (Ry) after each completed iteration, oldest first.

Recorded by the iterate() loop for every flavor, since the sequence is what shows how a run converged rather than only where it landed: a monotone descent, an oscillation, and a run that never moved all report the same final energy. The last entry equals total_energy() unless finalize() ran, which recomputes the energy components from the restored density after convergence.

Empty before run(); one entry per iteration performed thereafter.

Definition at line 61 of file init.hpp.

◆ write_checkpoints()

virtual void q3::SCFIterator::write_checkpoints ( const std::string &  output_directory,
const std::string &  prefix 
) const
inlinevirtual

Write binary checkpoint files (charge density, wavefunctions) to the given directory.

Each level of the hierarchy overrides this, calling the parent first, then adding its own checkpoint data. Default no-op.

Reimplemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.

Definition at line 182 of file init.hpp.

Member Data Documentation

◆ convergence_threshold_

◆ crystal_structure_

Crystal* q3::SCFIterator::crystal_structure_
protected

Definition at line 103 of file init.hpp.

Referenced by q3::KohnShamSCFIterator::crystal_structure(), and set_owned_crystal().

◆ is_converged_

bool q3::SCFIterator::is_converged_ {false}
protected

Definition at line 108 of file init.hpp.

Referenced by initialize(), is_converged(), iterate(), and report().

◆ iteration_

◆ maximum_iterations_

int q3::SCFIterator::maximum_iterations_
protected

The documentation for this class was generated from the following file: