|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
The First-Principles (FP) Energy Solver Class. More...
Classes | |
| class | ESolver_OF |
| class | ESolver |
| class | ESolver_DFPT_PW |
| class | ESolver_DM2rho |
| class | ESolver_DoubleXC |
| class | esolver_forcefields |
| class | ESolver_FP |
| class | ESolver_GetS |
| class | ESolver_KS |
| class | ESolver_LR |
| Forward declaration for the linear-response solver. More... | |
| class | ESolver_KS_LCAO |
| Kohn-Sham energy solver using the LCAO basis. More... | |
| class | ESolver_KS_LCAO_TDDFT |
| Real-time TDDFT energy solver using the LCAO basis. More... | |
| class | ESolver_KS_LIP |
| class | ESolver_KS_PW |
| class | ESolver_KS_PW_TDDFT |
| class | ESolver_BSE |
| struct | LRRuntime |
| class | ESolver_OF_TDDFT |
| class | ESolver_SDFT_PW |
Typedefs | |
| template<typename T> | |
| using | Real = typename GetTypeReal<T>::type |
Functions | |
| std::string | determine_type (const Input_para &inp) |
| Determine the ESolver type string from input parameters. | |
| ESolver * | init_esolver (const Input_para &inp) |
| Determine and initialize an ESolver based on input information. | |
| template<typename TK> | |
| void | init_deltaspin_lcao (const UnitCell &ucell, const Input_para &inp, void *pv, const K_Vectors &kv, void *p_hamilt, void *psi, void *dm, void *pelec) |
| Initialize the SpinConstrain singleton with all input parameters. | |
| template<typename TK> | |
| void | cal_mi_lcao_wrapper (const int iter, const Input_para &inp) |
| Wrapper: calculate magnetic moments for current SCF iteration. | |
| template<typename TK> | |
| bool | run_deltaspin_lambda_loop_lcao (const int iter, const double drho, const Input_para &inp, std::ostream &ofs_running) |
| Wrapper: run the lambda optimization loop. | |
| template void | init_deltaspin_lcao< double > (const UnitCell &ucell, const Input_para &inp, void *pv, const K_Vectors &kv, void *p_hamilt, void *psi, void *dm, void *pelec) |
| Template instantiations for both spin types. | |
| template void | init_deltaspin_lcao< std::complex< double > > (const UnitCell &ucell, const Input_para &inp, void *pv, const K_Vectors &kv, void *p_hamilt, void *psi, void *dm, void *pelec) |
| template void | cal_mi_lcao_wrapper< double > (const int iter, const Input_para &inp) |
| template void | cal_mi_lcao_wrapper< std::complex< double > > (const int iter, const Input_para &inp) |
| template bool | run_deltaspin_lambda_loop_lcao< double > (const int iter, const double drho, const Input_para &inp, std::ostream &ofs_running) |
| template bool | run_deltaspin_lambda_loop_lcao< std::complex< double > > (const int iter, const double drho, const Input_para &inp, std::ostream &ofs_running) |
| void | init_dftu_lcao (int dft_plus_u, void *dftu, const UnitCell &ucell, double **rho, const int nrxx, const LCAO_Orbitals *orb) |
| Initialize DFT+U for LCAO method in iter_init. | |
| template<typename TK> | |
| void | finish_dftu_lcao (const bool conv_esolver, int dft_plus_u, void *dftu, const UnitCell &ucell, const std::vector< std::vector< TK > > &dm_vec, const K_Vectors &kv, const double mixing_beta, void *hamilt_lcao, int nspin, const bool gamma_only_local) |
| Finish DFT+U calculation for LCAO method in iter_finish. | |
| template void | finish_dftu_lcao< double > (const bool conv_esolver, int dft_plus_u, void *dftu, const UnitCell &ucell, const std::vector< std::vector< double > > &dm_vec, const K_Vectors &kv, const double mixing_beta, void *hamilt_lcao, int nspin, const bool gamma_only_local) |
| Template instantiation. | |
| template void | finish_dftu_lcao< std::complex< double > > (const bool conv_esolver, int dft_plus_u, void *dftu, const UnitCell &ucell, const std::vector< std::vector< std::complex< double > > > &dm_vec, const K_Vectors &kv, const double mixing_beta, void *hamilt_lcao, int nspin, const bool gamma_only_local) |
The First-Principles (FP) Energy Solver Class.
This class represents components that needed in first-principles energy solver, such as the plane wave basis, the structure factors, and the k points.
| using ModuleESolver::Real = typename GetTypeReal<T>::type |
| void ModuleESolver::cal_mi_lcao_wrapper | ( | const int | iter, |
| const Input_para & | inp ) |
Wrapper: calculate magnetic moments for current SCF iteration.
Calculate magnetic moments for DeltaSpin in LCAO method.
If DeltaSpin is enabled, calls SpinConstrain::cal_mi_lcao(). The moments are stored in Mi_ and can be retrieved via get_target_mag().
This function calculates the magnetic moments for each atom in the DeltaSpin method.
| iter | Current iteration number |
| inp | Input parameters |
| template void ModuleESolver::cal_mi_lcao_wrapper< double > | ( | const int | iter, |
| const Input_para & | inp ) |
| template void ModuleESolver::cal_mi_lcao_wrapper< std::complex< double > > | ( | const int | iter, |
| const Input_para & | inp ) |
| std::string ModuleESolver::determine_type | ( | const Input_para & | inp | ) |
Determine the ESolver type string from input parameters.
The type is decided based on inp.basis_type and inp.esolver_type, together with device/precision hints written to the running log.
| [in] | inp | Input parameters used to determine the ESolver type. |
| void ModuleESolver::finish_dftu_lcao | ( | const bool | conv_esolver, |
| int | dft_plus_u, | ||
| void * | dftu, | ||
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< TK > > & | dm_vec, | ||
| const K_Vectors & | kv, | ||
| const double | mixing_beta, | ||
| void * | hamilt_lcao, | ||
| int | nspin, | ||
| const bool | gamma_only_local ) |
Finish DFT+U calculation for LCAO method in iter_finish.
This function handles the DFT+U finalization during the SCF iteration. It calculates the occupation matrix and energy correction if needed.
| conv_esolver | Whether ESolver has converged |
| dft_plus_u | DFT+U mode (0=disabled, 1=old, 2=new) |
| dftu | DFT+U object |
| ucell | Unit cell |
| dm_vec | Density matrix vector |
| kv | K-vectors |
| mixing_beta | Mixing beta parameter |
| hamilt_lcao | Hamiltonian LCAO object |
| nspin | Number of spin channels (1, 2, or 4) |
| gamma_only_local | Whether only the Gamma point is used for LCAO |
old DFT+U method calculates energy correction in esolver, new DFT+U method calculates energy in Hamiltonian
use the converged occupation matrix for next MD/Relax SCF calculation
| template void ModuleESolver::finish_dftu_lcao< double > | ( | const bool | conv_esolver, |
| int | dft_plus_u, | ||
| void * | dftu, | ||
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< double > > & | dm_vec, | ||
| const K_Vectors & | kv, | ||
| const double | mixing_beta, | ||
| void * | hamilt_lcao, | ||
| int | nspin, | ||
| const bool | gamma_only_local ) |
Template instantiation.
| template void ModuleESolver::finish_dftu_lcao< std::complex< double > > | ( | const bool | conv_esolver, |
| int | dft_plus_u, | ||
| void * | dftu, | ||
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< std::complex< double > > > & | dm_vec, | ||
| const K_Vectors & | kv, | ||
| const double | mixing_beta, | ||
| void * | hamilt_lcao, | ||
| int | nspin, | ||
| const bool | gamma_only_local ) |
| void ModuleESolver::init_deltaspin_lcao | ( | const UnitCell & | ucell, |
| const Input_para & | inp, | ||
| void * | pv, | ||
| const K_Vectors & | kv, | ||
| void * | p_hamilt, | ||
| void * | psi, | ||
| void * | dm, | ||
| void * | pelec ) |
Initialize the SpinConstrain singleton with all input parameters.
Initialize DeltaSpin for LCAO method.
Called once at the start of a DeltaSpin calculation. Checks sc_mag_switch first; if disabled, returns immediately without any action.
This function initializes the DeltaSpin calculation by setting up the SpinConstrain object with input parameters.
| ucell | Unit cell |
| inp | Input parameters |
| pv | Parallel orbitals |
| kv | K-vectors |
| p_hamilt | Pointer to Hamiltonian |
| psi | Pointer to wave functions |
| dm | Density matrix |
| pelec | Pointer to electronic state |
| template void ModuleESolver::init_deltaspin_lcao< double > | ( | const UnitCell & | ucell, |
| const Input_para & | inp, | ||
| void * | pv, | ||
| const K_Vectors & | kv, | ||
| void * | p_hamilt, | ||
| void * | psi, | ||
| void * | dm, | ||
| void * | pelec ) |
Template instantiations for both spin types.
| template void ModuleESolver::init_deltaspin_lcao< std::complex< double > > | ( | const UnitCell & | ucell, |
| const Input_para & | inp, | ||
| void * | pv, | ||
| const K_Vectors & | kv, | ||
| void * | p_hamilt, | ||
| void * | psi, | ||
| void * | dm, | ||
| void * | pelec ) |
| void ModuleESolver::init_dftu_lcao | ( | int | dft_plus_u, |
| void * | dftu, | ||
| const UnitCell & | ucell, | ||
| double ** | rho, | ||
| const int | nrxx, | ||
| const LCAO_Orbitals * | orb ) |
Initialize DFT+U for LCAO method in iter_init.
This function handles the DFT+U initialization during the SCF iteration. It calculates Slater integrals if the Yukawa potential is used. The DMR needed by DFT+U is read directly from the solver-owned DensityMatrix via the DFTU Hamiltonian operator, so it is not passed in here.
| dft_plus_u | DFT+U mode (0=disabled, 1=old, 2=new) |
| dftu | DFT+U object |
| ucell | Unit cell |
| rho | Charge density |
| nrxx | Number of real space grid points |
| orb | Numerical atomic orbitals; used for Slater integrals when the Yukawa potential is enabled. May be nullptr when no LCAO orbital data is available (e.g. PW-only DFT+U paths). |
Calculate U and J if Yukawa potential is used
| ESolver * ModuleESolver::init_esolver | ( | const Input_para & | inp | ) |
Determine and initialize an ESolver based on input information.
This function determines the type of ESolver to create based on input information and initializes the corresponding ESolver child class. It supports various ESolver types including ksdft_pw, ksdft_lcao, ksdft_lcao_tddft, sdft_pw, ofdft, lj_pot, and dp_pot.
| [in] | inp | Input parameters used to select and configure the ESolver. |
| bool ModuleESolver::run_deltaspin_lambda_loop_lcao | ( | const int | iter, |
| const double | drho, | ||
| const Input_para & | inp, | ||
| std::ostream & | ofs_running ) |
Wrapper: run the lambda optimization loop.
Run DeltaSpin lambda loop for LCAO method.
Decision logic for when to run the lambda loop:
Case 1: NOT converged AND charge density is close enough (drho < sc_scf_thr) -> Run lambda loop, mark as converged, skip_solve = true Rationale: The charge density is stable enough to optimize lambda. The lambda loop does its own diagonalization, so skip the outer solve.
Case 2: Already converged -> Still run lambda loop (to refine for the current charge density) -> skip_solve = true Rationale: Even if converged, the charge density may have changed slightly, requiring lambda refinement.
Case 3: NOT converged AND charge density is NOT close enough (drho >= sc_scf_thr) -> Do nothing, skip_solve = false Rationale: The charge density is still changing significantly, so optimizing lambda would be premature. Wait for SCF to stabilize first.
| iter | Current SCF iteration number |
| drho | Charge density convergence criterion (max|drho|) |
| inp | Input parameters |
This function handles the lambda loop optimization for the DeltaSpin method in LCAO calculations. It determines whether to skip the Hamiltonian solve based on the convergence status of magnetic moments.
| iter | Current iteration number |
| drho | Charge density convergence criterion |
| inp | Input parameters |
Charge density is stable enough: optimize lambda for the first time
Already converged: refine lambda for the current charge density
| template bool ModuleESolver::run_deltaspin_lambda_loop_lcao< double > | ( | const int | iter, |
| const double | drho, | ||
| const Input_para & | inp, | ||
| std::ostream & | ofs_running ) |
| template bool ModuleESolver::run_deltaspin_lambda_loop_lcao< std::complex< double > > | ( | const int | iter, |
| const double | drho, | ||
| const Input_para & | inp, | ||
| std::ostream & | ofs_running ) |