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

Real-time TDDFT energy solver using the LCAO basis. More...

#include <esolver_ks_lcao_tddft.h>

Inheritance diagram for ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >:
Collaboration diagram for ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >:

Public Member Functions

 ESolver_KS_LCAO_TDDFT ()
 Initialize the solver identity and basis name.
 ~ESolver_KS_LCAO_TDDFT ()
 Release the saved wave functions, Hamiltonian, and solver-owned TD contexts.
void before_all_runners (BaseCell &basecell, const Input_para &inp) override
 Initialize the LCAO solver, shared field state, and optional restart wave functions.
Public Member Functions inherited from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >
 ESolver_KS_LCAO ()
 Initialize the solver identity and DFT+U storage.
 ~ESolver_KS_LCAO ()
 Release the electronic wave functions.
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.
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

int scf_iter_limit (const int istep) const override
 Use the initial-state limit for initialization or restart replay, and the RT limit for propagation.
TD_info * get_td_info () const override
 Return the solver-owned RT state used by LCAO operators and output.
virtual void runner (BaseCell &basecell, const int istep) override
 Run the electronic steps belonging to one MD call, including initialization or restart replay.
virtual void hamilt2rho_single (UnitCell &ucell, const int istep, const int iter, const double ethr) override
 Obtain the density from initial-state diagonalization, loaded wave functions, or time propagation.
void store_h_s_psi (UnitCell &ucell, const int istep, const int iter, const bool conv_esolver)
 Save H, S, and wave functions when requested at convergence or the maximum iteration count.
void iter_finish (UnitCell &ucell, const int istep, const int estep, const int estep_max, int &iter, bool &conv_esolver)
 Finish an electronic iteration and update the saved state and requested energy-density matrix.
virtual void after_scf (UnitCell &ucell, const int istep, const bool conv_esolver) override
 Write the electronic-step energy and TD observables after the SCF loop.
void print_step ()
 Print the electronic-step header using a 1-based step number.
Protected Member Functions inherited from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >
virtual void before_scf (UnitCell &ucell, const int istep) override
 Prepare an ionic step using istep for both initialization and initial-state 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 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 others (BaseCell &basecell, const int istep) override
 Run specialized LCAO calculations outside the standard SCF workflow.
Protected Member Functions inherited from ModuleESolver::ESolver_KS
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

psi::Psi< std::complex< double > > * psi_laststep = nullptr
 Wave functions for all local k-points of the last electronic step.
ct::Tensor Hk_laststep = ct::Tensor(ct::DataType::DT_COMPLEX_DOUBLE)
 Hamiltonian for all local k-points of the last electronic step.
ct::Tensor Sk_laststep = ct::Tensor(ct::DataType::DT_COMPLEX_DOUBLE)
 Overlap matrix for all local k-points of the last electronic step.
bool use_tensor = false
 Control tensor-based heterogeneous computing of the TDDFT solver.
bool use_lapack = false
 Use gathered full matrices rather than distributed matrices in tensor propagation.
int totstep = -1
 Current 0-based electronic-step index, with -1 before the initial state.
Velocity_op< TR > * velocity_mat = nullptr
 Velocity matrix for calculating current.
TD_info * td_p = nullptr
 Solver-owned TD context for field-dependent LCAO operators and observables.
bool use_td_moving_gauge = false
 Moving spatial gauge for Ehrenfest dynamics, to calculate the correction term arising from the movement of basis.
std::unique_ptr< module_rt::TD_MovingGauge > td_mg_
 Moving-basis correction matrices, allocated when the moving spatial gauge is enabled.
bool restart_done = false
 Whether the saved restart endpoint has been replayed to rebuild the electronic state.
std::shared_ptr< elecstate::TDFieldManager > td_field_manager_
 Field manager shared by propagation, potentials, and restart output.
Protected Attributes inherited from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >
int istep_
bool final_electronic_step_
 Whether the current after_scf() call ends the final electronic step of the run.
psi::Psi< std::complex< double > > * psi
 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< std::complex< double > > dmat
 Own the density matrix, mohan add 2025-10-30.
Setup_DeePKS< std::complex< double > > 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< std::complex< double > > exx_nao
 For exact-exchange calculations, mohan add 2025-10-08.
rdmft::RDMFT< std::complex< double >, 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
 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.

Static Protected Attributes

static constexpr ct::DeviceType ct_device_type_hs = ct::DeviceType::CpuDevice
 Store Hk_laststep and Sk_laststep on the CPU, including for GPU propagation.

Private Member Functions

void weight_dm_rho (const UnitCell &ucell)
 Apply specified occupations and rebuild band energy, density matrices, and charge density.

Private Attributes

int restart_step_ = 0
 Fixed electronic-step origin loaded at restart, independent of field advancement.

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 TR, typename Device = base_device::DEVICE_CPU>
class ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >

Real-time TDDFT energy solver using the LCAO basis.

Constructor & Destructor Documentation

◆ ESolver_KS_LCAO_TDDFT()

template<typename TR, typename Device>
ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::ESolver_KS_LCAO_TDDFT ( )

Initialize the solver identity and basis name.

◆ ~ESolver_KS_LCAO_TDDFT()

template<typename TR, typename Device>
ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::~ESolver_KS_LCAO_TDDFT ( )

Release the saved wave functions, Hamiltonian, and solver-owned TD contexts.

Member Function Documentation

◆ after_scf()

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

Write the electronic-step energy and TD observables after the SCF loop.

Reimplemented from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >.

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

◆ before_all_runners()

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

Initialize the LCAO solver, shared field state, and optional restart wave functions.

Reimplemented from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >.

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

◆ get_td_info()

template<typename TR, typename Device = base_device::DEVICE_CPU>
TD_info * ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::get_td_info ( ) const
inlineoverrideprotectedvirtual

Return the solver-owned RT state used by LCAO operators and output.

Reimplemented from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >.

◆ hamilt2rho_single()

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

Obtain the density from initial-state diagonalization, loaded wave functions, or time propagation.

Reimplemented from ModuleESolver::ESolver_KS_LCAO< std::complex< double >, TR >.

Here is the call graph for this function:

◆ iter_finish()

template<typename TR, typename Device>
void ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::iter_finish ( UnitCell & ucell,
const int istep,
const int estep,
const int estep_max,
int & iter,
bool & conv_esolver )
protected

Finish an electronic iteration and update the saved state and requested energy-density matrix.

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

◆ print_step()

template<typename TR, typename Device>
void ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::print_step ( )
protected

Print the electronic-step header using a 1-based step number.

Here is the caller graph for this function:

◆ runner()

template<typename TR, typename Device>
void ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::runner ( BaseCell & basecell,
const int istep )
overrideprotectedvirtual

Run the electronic steps belonging to one MD call, including initialization or restart replay.

Reimplemented from ModuleESolver::ESolver_KS.

Here is the call graph for this function:

◆ scf_iter_limit()

template<typename TR, typename Device>
int ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::scf_iter_limit ( const int istep) const
overrideprotectedvirtual

Use the initial-state limit for initialization or restart replay, and the RT limit for propagation.

Reimplemented from ModuleESolver::ESolver_KS.

Here is the caller graph for this function:

◆ store_h_s_psi()

template<typename TR, typename Device>
void ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::store_h_s_psi ( UnitCell & ucell,
const int istep,
const int iter,
const bool conv_esolver )
protected

Save H, S, and wave functions when requested at convergence or the maximum iteration count.

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

◆ weight_dm_rho()

template<typename TR, typename Device>
void ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::weight_dm_rho ( const UnitCell & ucell)
private

Apply specified occupations and rebuild band energy, density matrices, and charge density.

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

Member Data Documentation

◆ ct_device_type_hs

template<typename TR, typename Device = base_device::DEVICE_CPU>
ct::DeviceType ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::ct_device_type_hs = ct::DeviceType::CpuDevice
staticconstexprprotected

Store Hk_laststep and Sk_laststep on the CPU, including for GPU propagation.

◆ Hk_laststep

template<typename TR, typename Device = base_device::DEVICE_CPU>
ct::Tensor ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::Hk_laststep = ct::Tensor(ct::DataType::DT_COMPLEX_DOUBLE)
protected

Hamiltonian for all local k-points of the last electronic step.

◆ psi_laststep

template<typename TR, typename Device = base_device::DEVICE_CPU>
psi::Psi<std::complex<double> >* ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::psi_laststep = nullptr
protected

Wave functions for all local k-points of the last electronic step.

◆ restart_done

template<typename TR, typename Device = base_device::DEVICE_CPU>
bool ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::restart_done = false
protected

Whether the saved restart endpoint has been replayed to rebuild the electronic state.

◆ restart_step_

template<typename TR, typename Device = base_device::DEVICE_CPU>
int ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::restart_step_ = 0
private

Fixed electronic-step origin loaded at restart, independent of field advancement.

◆ Sk_laststep

template<typename TR, typename Device = base_device::DEVICE_CPU>
ct::Tensor ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::Sk_laststep = ct::Tensor(ct::DataType::DT_COMPLEX_DOUBLE)
protected

Overlap matrix for all local k-points of the last electronic step.

◆ td_field_manager_

template<typename TR, typename Device = base_device::DEVICE_CPU>
std::shared_ptr<elecstate::TDFieldManager> ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::td_field_manager_
protected

Field manager shared by propagation, potentials, and restart output.

◆ td_mg_

template<typename TR, typename Device = base_device::DEVICE_CPU>
std::unique_ptr<module_rt::TD_MovingGauge> ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::td_mg_
protected

Moving-basis correction matrices, allocated when the moving spatial gauge is enabled.

◆ td_p

template<typename TR, typename Device = base_device::DEVICE_CPU>
TD_info* ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::td_p = nullptr
protected

Solver-owned TD context for field-dependent LCAO operators and observables.

◆ totstep

template<typename TR, typename Device = base_device::DEVICE_CPU>
int ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::totstep = -1
protected

Current 0-based electronic-step index, with -1 before the initial state.

◆ use_lapack

template<typename TR, typename Device = base_device::DEVICE_CPU>
bool ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::use_lapack = false
protected

Use gathered full matrices rather than distributed matrices in tensor propagation.

◆ use_td_moving_gauge

template<typename TR, typename Device = base_device::DEVICE_CPU>
bool ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::use_td_moving_gauge = false
protected

Moving spatial gauge for Ehrenfest dynamics, to calculate the correction term arising from the movement of basis.

◆ use_tensor

template<typename TR, typename Device = base_device::DEVICE_CPU>
bool ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::use_tensor = false
protected

Control tensor-based heterogeneous computing of the TDDFT solver.

◆ velocity_mat

template<typename TR, typename Device = base_device::DEVICE_CPU>
Velocity_op<TR>* ModuleESolver::ESolver_KS_LCAO_TDDFT< TR, Device >::velocity_mat = nullptr
protected

Velocity matrix for calculating current.


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