ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModuleESolver::ESolver_KS_LCAO< TK, TR > Class Template Reference

Kohn-Sham energy solver using the LCAO basis. More...

#include <esolver_ks_lcao.h>

Inheritance diagram for ModuleESolver::ESolver_KS_LCAO< TK, TR >:
Collaboration diagram for ModuleESolver::ESolver_KS_LCAO< TK, TR >:

Public Member Functions

 ESolver_KS_LCAO ()
 Initialize the solver identity and DFT+U storage.
 ~ESolver_KS_LCAO ()
 Release the electronic wave functions.
void before_all_runners (BaseCell &basecell, const Input_para &inp) override
 Initialize the LCAO basis, electronic state, and potentials before all steps.
double cal_energy () override
 Return the electronic total energy in Ry.
void cal_force (BaseCell &basecell, ModuleBase::matrix &force) override
 Calculate the requested forces and stress, caching the stress for cal_stress().
void cal_stress (BaseCell &basecell, ModuleBase::matrix &stress) override
 Return the cached stress, calling cal_force() first when needed.
void after_all_runners (BaseCell &basecell) override
 Perform final LCAO output and postprocessing after all steps.
Public Member Functions inherited from ModuleESolver::ESolver_KS
 ESolver_KS ()
 Constructor.
virtual ~ESolver_KS ()
 Deconstructor.
virtual void runner (BaseCell &basecell, const int istep) override
 run energy solver
Public Member Functions inherited from ModuleESolver::ESolver_FP
 ESolver_FP ()
virtual ~ESolver_FP ()
Public Member Functions inherited from ModuleESolver::ESolver
 ESolver ()
virtual ~ESolver ()

Protected Member Functions

virtual TD_info * get_td_info () const
 Optional solver-owned RT state passed to LCAO consumers.
virtual void before_scf (UnitCell &ucell, const int istep) override
 Prepare an ionic step using istep for both initialization and initial-state output.
void before_scf (UnitCell &ucell, const int istep, const int output_step)
 Prepare an ionic step with a separate index for initial charge and potential output.
virtual void iter_init (UnitCell &ucell, const int istep, const int iter) override
 Prepare charge mixing and Hamiltonian updates for an SCF iteration.
virtual void hamilt2rho_single (UnitCell &ucell, const int istep, const int iter, const double ethr) override
 Solve the Hamiltonian and update the charge density and energy terms.
virtual void iter_finish (UnitCell &ucell, const int istep, int &iter, bool &conv_esolver) override
 Finish an SCF iteration with energy corrections, mixing, convergence checks, and output.
virtual void after_scf (UnitCell &ucell, const int istep, const bool conv_esolver) override
 Write the SCF results and release adjacency records when forces and stress are not requested.
virtual void others (BaseCell &basecell, const int istep) override
 Run specialized LCAO calculations outside the standard SCF workflow.
Protected Member Functions inherited from ModuleESolver::ESolver_KS
virtual int scf_iter_limit (const int istep) const
 Maximum SCF iterations for the current electronic step.
bool scf_loop (UnitCell &ucell, int istep, int iter_limit)
 Run SCF iterations without preparing or committing a physical endpoint.
void record_iteration (const UnitCell &ucell, double duration)
 Record an accepted iteration in JSON without changing its convergence status.
void write_iter_bands ()
 Write current band expectations when iterative band output is requested.
virtual DensityStage density_stage (const int istep, const int iter) const
 Identify mandatory predictor stages before mixing and convergence checks.
virtual bool defer_iter_output (const int istep) const
 Whether KS iterations defer output until the final state is accepted.
void hamilt2rho (UnitCell &ucell, const int istep, const int iter, const double ethr)
virtual std::string diag_policy (const int istep) const
 Select the diagonalization threshold and error-control policy for the current stage.
Protected Member Functions inherited from ModuleESolver::ESolver_FP
const vdw::VdwResult * get_vdw_result () const

Protected Attributes

int istep_ = 0
bool final_electronic_step_ = true
 Whether the current after_scf() call ends the final electronic step of the run.
psi::Psi< TK > * psi = nullptr
 Electronic wave functions (moved from base class).
Record_adj RA
 Store information about adjacent atoms for the distributed matrix layout.
Grid_Driver gd
 Search for adjacent atoms and provide their positions and cell indices.
Parallel_Orbitals pv
 NAO orbitals: 2D block-cyclic distribution info.
std::unique_ptr< BasisFlattenedIndexing > basis_index_
 Canonical global ordering and atom slices of the LCAO basis.
std::unique_ptr< ModuleGint::GintInfo > gint_info_
 GintInfo: used to store basic grid-integration information for module_gint.
LCAO_Orbitals orb_
 Store NAO orbitals and their radial tables.
TwoCenterBundle two_center_bundle_
 NAO orbitals: two-center integrations.
module_dm::Setup_DM< TK > dmat
 Own the density matrix, mohan add 2025-10-30.
Setup_DeePKS< TK > deepks
 For DeePKS calculations, mohan add 2025-10-08.
Exx_Info exx_info_
 Full EXX info for LCAO (includes info_ri, info_opt_abfs, info_lip).
Exx_NAO< TK > exx_nao
 For exact-exchange calculations, mohan add 2025-10-08.
rdmft::RDMFT< TK, TR > rdmft_solver
 For RDMFT calculations, added by jghan, 2024-03-16.
ModuleBase::matrix scs
 Cache the stress computed by cal_force() for the separate cal_stress() interface.
bool have_force = false
 Track whether cal_force() has run since the last cal_stress() call.
GintPrecisionController gint_precision_controller_
 Control grid-integration precision and its switching during SCF iterations.
Protected Attributes inherited from ModuleESolver::ESolver_KS
hamilt::HamiltBase * p_hamilt = nullptr
 Hamiltonian (base class pointer, actual type determined at runtime).
ModulePW::PW_Basis_K * pw_wfc = nullptr
 PW for wave functions, only used in KSDFT, not in OFDFT.
Charge_Mixing * p_chgmix = nullptr
 Charge mixing method.
pseudopot_cell_vnl ppcell
 nonlocal pseudopotentials
std::unique_ptr< Plus_U_Base > dftu_
std::string basisname
double esolver_KS_ne = 0.0
 esolver_ks_lcao.cpp
double diag_ethr
 number of electrons
double scf_thr
 the threshold for diagonalization
double scf_ene_thr
 scf density threshold
double drho
 scf energy threshold
double hsolver_error
 the difference between rho_in (before HSolver) and rho_out (After HSolver)
double ds_rms_ = -1.0
int maxniter
int niter
 maximum iter steps for scf
bool oscillate_esolver = false
 iter steps actually used in scf
bool scf_nmax_flag = false
bool scf_rerun_ = false
General_Exx_Info general_exx_info_
 General EXX info owned by ESolver, initialized from input parameters.
Protected Attributes inherited from ModuleESolver::ESolver_FP
std::unique_ptr< const vdw::VdwResult > vdw_result_
 vdW correction evaluated once for the current ionic configuration.
elecstate::ElecState * pelec = nullptr
 These pointers will be deleted in the free_pointers() function every ion step.
K_Vectors kv
 K points in Brillouin zone.
Charge chr
 Electorn charge density.
ModulePW::PW_Basis * pw_rho = nullptr
ModulePW::PW_Basis * pw_rhod = nullptr
ModulePW::PW_Basis_Big * pw_big = nullptr
 dense grid for USPP
Parallel_Grid Pgrid
 parallel for rho grid
Structure_Factor sf
 Structure factors that used with plane-wave basis set.
pseudopot_cell_vl locpp
 local pseudopotentials
module_charge::Charge_Extra CE
 charge extrapolation method
surchem solvent
 solvent model
bool pw_rho_flag = false
 flag for pw_rho, 0: not initialized, 1: initialized
ModuleBase::TimePoint iter_time
 the start time of scf iteration
Protected Attributes inherited from ModuleESolver::ESolver
const Input_para * inp_ = nullptr
 Bound in before_all_runners; members use inp_->xxx instead of PARAM.inp.xxx.

Friends

class ESolver_LR< double, double >
 For linear-response TDDFT.
class ESolver_LR< std::complex< double >, double >
 For linear-response TDDFT.

Additional Inherited Members

Public Attributes inherited from ModuleESolver::ESolver
bool conv_esolver = true
std::string classname
Protected Types inherited from ModuleESolver::ESolver_KS
enum class  DensityStage { standard , predictor }
 Select whether the density is an endpoint predictor or an SCF iterate. More...

Detailed Description

template<typename TK, typename TR>
class ModuleESolver::ESolver_KS_LCAO< TK, TR >

Kohn-Sham energy solver using the LCAO basis.

Constructor & Destructor Documentation

◆ ESolver_KS_LCAO()

template<typename TK, typename TR>
ModuleESolver::ESolver_KS_LCAO< TK, TR >::ESolver_KS_LCAO ( )

Initialize the solver identity and DFT+U storage.

◆ ~ESolver_KS_LCAO()

template<typename TK, typename TR>
ModuleESolver::ESolver_KS_LCAO< TK, TR >::~ESolver_KS_LCAO ( )

Release the electronic wave functions.

Member Function Documentation

◆ after_all_runners()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::after_all_runners ( BaseCell & basecell)
overridevirtual

Perform final LCAO output and postprocessing after all steps.

Reimplemented from ModuleESolver::ESolver_KS.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ after_scf()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::after_scf ( UnitCell & ucell,
const int istep,
const bool conv_esolver )
overrideprotectedvirtual

Write the SCF results and release adjacency records when forces and stress are not requested.

1) call after_scf() of ESolver_KS

2) write LCAO output using the applicable ionic or RT-TDDFT electronic step The outer ionic driver marks the final ionic step on the cell so the output gate can always persist the final snapshot. In RT-TDDFT one ionic step spans several electronic substeps, so the override is limited to the substep the solver flagged as the final one; otherwise every substep of the final ionic step would bypass out_freq_ion.

3) Clean up the adjacency records in RA when forces and stress are not needed

Reimplemented from ModuleESolver::ESolver_KS.

Reimplemented in ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >.

Here is the call graph for this function:

◆ before_all_runners()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::before_all_runners ( BaseCell & basecell,
const Input_para & inp )
overridevirtual

Initialize the LCAO basis, electronic state, and potentials before all steps.

if nks is not divisible by kpar, print a warning

init rdmft, added by jghan

Reimplemented from ModuleESolver::ESolver_KS.

Reimplemented in ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ before_scf() [1/2]

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::before_scf ( UnitCell & ucell,
const int istep )
overrideprotectedvirtual

Prepare an ionic step using istep for both initialization and initial-state output.

Reimplemented from ModuleESolver::ESolver_KS.

Reimplemented in ModuleESolver::ESolver_DoubleXC< TK, TR >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ before_scf() [2/2]

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::before_scf ( UnitCell & ucell,
const int istep,
const int output_step )
protected

Prepare an ionic step with a separate index for initial charge and potential output.

1) call before_scf() of ESolver_KS.

2) find search radius

3) use search_radius to search adj atoms

4) initialize grid-integration information

11.1) init charge density from density matrix file

11.2) init charge density from Hamiltonian matrix file

Here is the call graph for this function:

◆ cal_energy()

template<typename TK, typename TR>
double ModuleESolver::ESolver_KS_LCAO< TK, TR >::cal_energy ( )
overridevirtual

Return the electronic total energy in Ry.

Implements ModuleESolver::ESolver.

◆ cal_force()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::cal_force ( BaseCell & basecell,
ModuleBase::matrix & force )
overridevirtual

Calculate the requested forces and stress, caching the stress for cal_stress().

Implements ModuleESolver::ESolver.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_stress()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::cal_stress ( BaseCell & basecell,
ModuleBase::matrix & stress )
overridevirtual

Return the cached stress, calling cal_force() first when needed.

Implements ModuleESolver::ESolver.

Here is the call graph for this function:

◆ get_td_info()

template<typename TK, typename TR>
virtual TD_info * ModuleESolver::ESolver_KS_LCAO< TK, TR >::get_td_info ( ) const
inlineprotectedvirtual

Optional solver-owned RT state passed to LCAO consumers.

Reimplemented in ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >.

Here is the caller graph for this function:

◆ hamilt2rho_single()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::hamilt2rho_single ( UnitCell & ucell,
const int istep,
const int iter,
const double ethr )
overrideprotectedvirtual

Solve the Hamiltonian and update the charge density and energy terms.

Reimplemented from ModuleESolver::ESolver_KS.

Reimplemented in ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >.

Here is the call graph for this function:

◆ iter_finish()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::iter_finish ( UnitCell & ucell,
const int istep,
int & iter,
bool & conv_esolver )
overrideprotectedvirtual

Finish an SCF iteration with energy corrections, mixing, convergence checks, and output.

Reimplemented from ModuleESolver::ESolver_KS.

Reimplemented in ModuleESolver::ESolver_DoubleXC< TK, TR >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iter_init()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::iter_init ( UnitCell & ucell,
const int istep,
const int iter )
overrideprotectedvirtual

Prepare charge mixing and Hamiltonian updates for an SCF iteration.

Reimplemented from ModuleESolver::ESolver_KS.

Here is the call graph for this function:

◆ others()

template<typename TK, typename TR>
void ModuleESolver::ESolver_KS_LCAO< TK, TR >::others ( BaseCell & basecell,
const int istep )
overrideprotectedvirtual

Run specialized LCAO calculations outside the standard SCF workflow.

Reimplemented from ModuleESolver::ESolver.

Here is the call graph for this function:

◆ ESolver_LR< double, double >

template<typename TK, typename TR>
friend class ESolver_LR< double, double >
friend

For linear-response TDDFT.

◆ ESolver_LR< std::complex< double >, double >

template<typename TK, typename TR>
friend class ESolver_LR< std::complex< double >, double >
friend

For linear-response TDDFT.

Member Data Documentation

◆ basis_index_

template<typename TK, typename TR>
std::unique_ptr<BasisFlattenedIndexing> ModuleESolver::ESolver_KS_LCAO< TK, TR >::basis_index_
protected

Canonical global ordering and atom slices of the LCAO basis.

◆ deepks

template<typename TK, typename TR>
Setup_DeePKS<TK> ModuleESolver::ESolver_KS_LCAO< TK, TR >::deepks
protected

For DeePKS calculations, mohan add 2025-10-08.

◆ dmat

template<typename TK, typename TR>
module_dm::Setup_DM<TK> ModuleESolver::ESolver_KS_LCAO< TK, TR >::dmat
protected

Own the density matrix, mohan add 2025-10-30.

◆ exx_info_

template<typename TK, typename TR>
Exx_Info ModuleESolver::ESolver_KS_LCAO< TK, TR >::exx_info_
protected

Full EXX info for LCAO (includes info_ri, info_opt_abfs, info_lip).

◆ exx_nao

template<typename TK, typename TR>
Exx_NAO<TK> ModuleESolver::ESolver_KS_LCAO< TK, TR >::exx_nao
protected

For exact-exchange calculations, mohan add 2025-10-08.

◆ final_electronic_step_

template<typename TK, typename TR>
bool ModuleESolver::ESolver_KS_LCAO< TK, TR >::final_electronic_step_ = true
protected

Whether the current after_scf() call ends the final electronic step of the run.

Non-RT solvers perform one electronic calculation per ionic step, so the default stays true and the final-snapshot override keeps covering every call of the final ionic step. RT-TDDFT updates this flag before each electronic substep, so the override in ctrl_scf_lcao applies only to the last substep of the final ionic step instead of bypassing out_freq_ion for the whole final ionic step.

◆ gd

template<typename TK, typename TR>
Grid_Driver ModuleESolver::ESolver_KS_LCAO< TK, TR >::gd
protected

Search for adjacent atoms and provide their positions and cell indices.

◆ gint_info_

template<typename TK, typename TR>
std::unique_ptr<ModuleGint::GintInfo> ModuleESolver::ESolver_KS_LCAO< TK, TR >::gint_info_
protected

GintInfo: used to store basic grid-integration information for module_gint.

◆ gint_precision_controller_

template<typename TK, typename TR>
GintPrecisionController ModuleESolver::ESolver_KS_LCAO< TK, TR >::gint_precision_controller_
protected

Control grid-integration precision and its switching during SCF iterations.

◆ have_force

template<typename TK, typename TR>
bool ModuleESolver::ESolver_KS_LCAO< TK, TR >::have_force = false
protected

Track whether cal_force() has run since the last cal_stress() call.

◆ istep_

template<typename TK, typename TR>
int ModuleESolver::ESolver_KS_LCAO< TK, TR >::istep_ = 0
protected

Ionic step index of the most recent ionic step, recorded in before_scf(). Read by after_all_runners() when labelling provenance headers of files written once at the end of a run.

◆ orb_

template<typename TK, typename TR>
LCAO_Orbitals ModuleESolver::ESolver_KS_LCAO< TK, TR >::orb_
protected

Store NAO orbitals and their radial tables.

◆ psi

template<typename TK, typename TR>
psi::Psi<TK>* ModuleESolver::ESolver_KS_LCAO< TK, TR >::psi = nullptr
protected

Electronic wave functions (moved from base class).

◆ pv

template<typename TK, typename TR>
Parallel_Orbitals ModuleESolver::ESolver_KS_LCAO< TK, TR >::pv
protected

NAO orbitals: 2D block-cyclic distribution info.

◆ RA

template<typename TK, typename TR>
Record_adj ModuleESolver::ESolver_KS_LCAO< TK, TR >::RA
protected

Store information about adjacent atoms for the distributed matrix layout.

◆ rdmft_solver

template<typename TK, typename TR>
rdmft::RDMFT<TK, TR> ModuleESolver::ESolver_KS_LCAO< TK, TR >::rdmft_solver
protected

For RDMFT calculations, added by jghan, 2024-03-16.

◆ scs

template<typename TK, typename TR>
ModuleBase::matrix ModuleESolver::ESolver_KS_LCAO< TK, TR >::scs
protected

Cache the stress computed by cal_force() for the separate cal_stress() interface.

◆ two_center_bundle_

template<typename TK, typename TR>
TwoCenterBundle ModuleESolver::ESolver_KS_LCAO< TK, TR >::two_center_bundle_
protected

NAO orbitals: two-center integrations.


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