Loading...
Searching...
No Matches
q3::SelfConsistentFieldFlavor Class Reference

#include <self_consistent_field.hpp>

+ Inheritance diagram for q3::SelfConsistentFieldFlavor:

Public Member Functions

 SelfConsistentFieldFlavor (IteratorFactory iterator_factory={})
 
- Public Member Functions inherited from q3::Flavor
virtual ~Flavor ()=default
 
generated::Results run (const InputData &input)
 

Static Public Member Functions

template<typename History >
static void record_convergence (generated::Results &results, const History &history)
 
static void record_forces (generated::Results &results, const std::vector< Vector3D > &total_forces, const AtomicForcesContributions &contributions)
 ESSE's atomic_forces record, and beside it the share of each mechanism, in Ry/bohr.
 
template<typename Manifolds >
static void record_hubbard_occupations (generated::Results &results, const std::vector< std::vector< Real > > &traces, const Manifolds &manifolds)
 
static void record_incomplete_stress (generated::Results &results, const std::string &reason)
 
static void record_magnetization (generated::Results &results, const std::optional< Magnetization > &magnetization)
 
static void record_stress (generated::Results &results, const StressTensorTotal &total, const StressTensorContributions &contributions)
 

Protected Member Functions

generated::Results run_calculation (const InputData &input) override
 

Detailed Description

Definition at line 44 of file self_consistent_field.hpp.

Constructor & Destructor Documentation

◆ SelfConsistentFieldFlavor()

q3::SelfConsistentFieldFlavor::SelfConsistentFieldFlavor ( IteratorFactory  iterator_factory = {})
inlineexplicit

iterator_factory carries the entry point's execution policy (see IteratorFactory); empty runs serially on the CPU.

Definition at line 50 of file self_consistent_field.hpp.

Member Function Documentation

◆ record_convergence()

template<typename History >
static void q3::SelfConsistentFieldFlavor::record_convergence ( generated::Results &  results,
const History &  history 
)
inlinestatic

─── The SCF's results, shared with the bindings' SCFSolver ──────────────

The bindings run the same calculation without this flavor, so what an SCF reports is filled here once, and both report it the same way. The total energy after each iteration, as ESSE's convergence_electronic record (one row: this run's only ionic step), and the density residual after each, as runtime_log.density_residuals.

Definition at line 276 of file self_consistent_field.hpp.

References q3::set_record().

Referenced by run_calculation(), and q3::bindings::SCFSolver::solve().

◆ record_forces()

static void q3::SelfConsistentFieldFlavor::record_forces ( generated::Results &  results,
const std::vector< Vector3D > &  total_forces,
const AtomicForcesContributions &  contributions 
)
inlinestatic

◆ record_hubbard_occupations()

template<typename Manifolds >
static void q3::SelfConsistentFieldFlavor::record_hubbard_occupations ( generated::Results &  results,
const std::vector< std::vector< Real > > &  traces,
const Manifolds &  manifolds 
)
inlinestatic

Tr[n] per Hubbard manifold, per spin channel: the number of electrons the manifold's projectors see, and the first thing to look at when a DFT+U result looks wrong. Nothing when the run has no Hubbard manifolds. atom_index is 0-based, matching the orbital projections' labels.

Definition at line 327 of file self_consistent_field.hpp.

Referenced by run_calculation(), and q3::bindings::SCFSolver::solve().

◆ record_incomplete_stress()

static void q3::SelfConsistentFieldFlavor::record_incomplete_stress ( generated::Results &  results,
const std::string &  reason 
)
inlinestatic

Name a term the stress leaves out, in runtime_log.incomplete, rather than only in the log: a variable-cell relaxation driven by a stress with a term missing converges to the wrong cell without anything in its output saying so, and the Python vc-relax workflow reads this and stops.

Definition at line 392 of file self_consistent_field.hpp.

Referenced by run_calculation().

◆ record_magnetization()

static void q3::SelfConsistentFieldFlavor::record_magnetization ( generated::Results &  results,
const std::optional< Magnetization > &  magnetization 
)
inlinestatic

Both of the numbers the convergence report prints, ∫(ρ↑−ρ↓) and ∫|ρ↑−ρ↓|, as ESSE's magnetization_total and magnetization_absolute records. The total alone cannot describe an antiferromagnet – it is zero both for a converged AFM state and for one that collapsed to non-magnetic – so both are listed, and neither for a run without them (spin-unpolarized, or one that never reached the convergence block): absent rather than a zero that reads as a collapsed moment.

Definition at line 303 of file self_consistent_field.hpp.

References q3::set_record().

Referenced by run_calculation(), and q3::bindings::SCFSolver::solve().

◆ record_stress()

static void q3::SelfConsistentFieldFlavor::record_stress ( generated::Results &  results,
const StressTensorTotal &  total,
const StressTensorContributions &  contributions 
)
inlinestatic

◆ run_calculation()

generated::Results q3::SelfConsistentFieldFlavor::run_calculation ( const InputData &  input)
inlineoverrideprotectedvirtual

Execute the calculation described by the input and return results.

Implementations must be self-contained: they set up, run, and finalize the calculation entirely. The caller receives fully-populated results, minus what run() adds.

─── Mean-field export (BerkeleyGW, etc.) ────────────────────────────── Format selection lives in the factory ("none" resolves to the Null object), so there is no branching on the format name here – see io/mean_field_export/init.hpp. BerkeleyGW normally consumes an NSCF run with many empty (conduction) bands rather than the SCF run itself (see non_self_consistent_field.hpp), but the export is wired into both flavors so either can be used directly. Which rank (if any) writes is decided by the execution topology – see export_and_record_mean_field_under_topology()'s comment. The exported Vxc is the valence one, not the state's own, which includes any core charge – see valence_exchange_correlation_potential_g_of().

Called on every rank, not just the writing one: the memory reduction inside is collective, and guarding it behind the root would hang the others.

Carry the timing breakdown into the result, so a measurement does not have to be scraped back out of the log. Counts go alongside the stage times: a stage that got slower because it ran more often is a different finding from one that got slower per call, and the times alone cannot tell them apart.

total_solve_calls is deliberately not emitted: it is declared in DavidsonTimingAccumulator but never incremented anywhere, so it would publish a constant zero that reads as "no solves happened".

Magnetization and the DFT+U occupation traces come from the iterator rather than being re-derived here: both are integrated over state the SCF releases a few lines below, and both are already printed, so a second derivation would be a second definition of the same number.

─── Isolated-system correction (if SCF converged) ───────────────────── Scheme selection lives in the factory ("none" resolves to the Null object), so there is no branching on the scheme name here – see isolated_system_correction/planewave/init.hpp.

The SCF is over: drop its working basis, projector cache and mixing history before the properties allocate their own, so that the run's peak is the SCF's rather than the SCF's with the forces' on top.

Record the derivative terms Q3 knows it left out, in the result rather than only in the log. A relaxation driven by forces with the Hubbard term missing converges to the wrong geometry without anything in its output saying so; the Python relax and vc-relax workflows read these and stop.

Atomic-projector and ortho-atomic force and stress include their complete orbital, overlap-operator, and cell-wide Lowdin-transform derivatives for every dataset family. Keep this metadata guard for future projector types.

─── Stress tensor ──────────────────────────────────────────────── Stress computation is not yet G-vector-distribution-aware. Skip when band_size > 1 to avoid out-of-bounds access on distributed wavefunctions/projectors.

Implements q3::Flavor.

Definition at line 54 of file self_consistent_field.hpp.

References q3::assemble_global_eigenvalues_at_kpoints(), q3::execution::QuantumSystemExecutionPolicy::band_size(), q3::ForceCalculator::compute_forces(), q3::compute_stress(), q3::create_isolated_system_correction_calculator(), q3::create_iterator(), q3::log::debug(), q3::InputData::disable_symmetry, q3::InputData::dispersion_correction, q3::energy(), q3::PlanewaveKohnShamSCFIterator::execution_policy(), q3::execution::PlanewaveExecutionPolicy::execution_record(), q3::export_and_record_mean_field_under_topology(), q3::log::info(), q3::ProfilingCounters::instance(), q3::SCFIterator::is_converged(), q3::InputData::isolated_system_correction, q3::SCFIterator::iteration(), q3::new_results(), q3::InputData::nonlocal_stress_derivative_method, q3::InputData::output_directory, q3::InputData::prefix, record_convergence(), record_forces(), record_hubbard_occupations(), record_incomplete_stress(), record_magnetization(), record_stress(), q3::PlanewaveKohnShamSCFIterator::result(), q3::SCFIterator::run(), q3::KohnShamSCFIterator::scf_history(), q3::set_energy_records(), q3::set_fermi_energy(), q3::set_record(), q3::InputData::start_from_saved_charge_density, q3::HubbardStressTensorCalculator::supports(), and q3::log::warn().


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