1#ifndef ABACUS_SOURCE_ESOLVER_ESOLVER_LR_LCAO_TDDFT_H
2#define ABACUS_SOURCE_ESOLVER_ESOLVER_LR_LCAO_TDDFT_H
42template <
typename T,
typename TR =
double>
80 std::unique_ptr<ModuleESolver::ESolver_KS_LCAO<T, TR>>
ks_;
106 std::vector<std::shared_ptr<LR::PotHxcLR>>
pot;
126 std::unique_ptr<elecstate::Potential>
pot_gs;
131 std::shared_ptr<LR::PotHxcLR>
138 std::vector<ct::Tensor>
X;
196 return this->openshell ? this->target_state_ : this->target_is_ * this->nstates + this->target_state_;
265 const std::vector<std::vector<ct::Tensor>> &window_density);
269 std::vector<ModuleBase::matrix>
cal_force(
const int ispin,
const int istate_only = -1);
288 const std::vector<double> &omega,
289 const int label_begin);
292 const ct::Tensor &Xz,
const std::vector<double> &omega,
const int label_begin);
307 std::vector<std::vector<ModuleBase::matrix>>
g;
308 int dim()
const {
return static_cast<int>(
states.size()); }
364 const std::vector<int> &group,
365 const std::vector<ModuleBase::matrix> &diag,
372 std::shared_ptr<Exx_LRI<T>> exx_lri =
nullptr;
376 void share_exx_lri(std::shared_ptr<
Exx_LRI<std::complex<double>>> &);
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
Definition esolver_fp.h:33
double etot_gs_
ground-state total energy of the current step (Ry)
Definition esolver_lr_lcao_tddft.h:172
int nloc_per_state_z_
Definition esolver_lr_lcao_tddft.h:224
Parallel_Blkcyclic paraC_
variables for parallel distribution of KS orbitals
Definition esolver_lr_lcao_tddft.h:205
virtual void before_all_runners(BaseCell &basecell, const Input_para &inp) override
input: input, call, basis(LCAO), psi(ground state), elecstate
Definition esolver_lr_init.cpp:88
int nbasis
Definition esolver_lr_lcao_tddft.h:147
module_dm::DensityMatrix< T, double > cal_dm_gs()
ground-state density matrix
Definition esolver_lr_grad.cpp:378
std::vector< int > npairs
n_occ*nvirt, the basis size of electron-hole pair representation
Definition esolver_lr_lcao_tddft.h:149
Parallel_Grid * pgrid_ptr_
Definition esolver_lr_lcao_tddft.h:91
ct::Tensor pad_group_to_z_(const int ispin, const std::vector< int > &group) const
Definition esolver_lr_rlx.cpp:163
void init_pot_groundstate(const Charge &chg_gs)
========================== for gradient calculation =========================
Definition esolver_lr_grad.cpp:21
ModuleBase::matrix wg_ks
Definition esolver_lr_lcao_tddft.h:122
void test_force()
Definition esolver_lr_grad.cpp:397
Parallel_Blkcyclic paraC_z_
Definition esolver_lr_lcao_tddft.h:220
std::vector< int > target_group_
Definition esolver_lr_lcao_tddft.h:320
int nocc_in
nocc read from input (adjusted by nelec): max(spin-up, spindown)
Definition esolver_lr_lcao_tddft.h:142
int target_is_
spin block of the relaxed state in X and pelec->ekb
Definition esolver_lr_lcao_tddft.h:171
int nvirt_in
nvirt read from input (adjusted by nelec): min(spin-up, spindown)
Definition esolver_lr_lcao_tddft.h:145
std::vector< int > nvirt_z_
Definition esolver_lr_lcao_tddft.h:222
bool exx_owned_
exx_lri was built here (so its Cs/Vs are ours to refresh)
Definition esolver_lr_lcao_tddft.h:164
ModuleBase::matrix wg_ks_all
occupation numbers of ground state in the [nocc+nvirt] window
Definition esolver_lr_lcao_tddft.h:123
void setup_eigenvectors_X()
allocate and set the inital value of X
Definition esolver_lr_orb.cpp:44
void setup_relax_target_()
Definition esolver_lr_rlx.cpp:20
ModuleBase::matrix eig_ks_all
all eigenvalues of ground state, read from the file, or moved from ESolver_FP::pelec....
Definition esolver_lr_lcao_tddft.h:121
int nspin
Definition esolver_lr_lcao_tddft.h:152
void initialize_from_unitcell_(UnitCell &ucell, const Input_para &inp)
Definition esolver_lr_init.cpp:343
double target_omega_() const
Definition esolver_lr_rlx.cpp:229
ModuleBase::matrix eig_ks_z_
Definition esolver_lr_lcao_tddft.h:219
double vtxc_gs
Definition esolver_lr_lcao_tddft.h:129
LCAO_Orbitals orb_
numerical atomic orbital data for single-point evaluation
Definition esolver_lr_lcao_tddft.h:235
ESolver_LR(const Input_para &inp, const std::string &in_dir, const std::string &out_dir, const LRRuntime &runtime)
Definition esolver_lr_lcao_tddft.cpp:21
std::vector< ModuleBase::matrix > cal_force_openshell_Xz(const ct::Tensor &Xz, const std::vector< double > &omega, const int label_begin)
open-shell counterpart of cal_force_Xz
Definition esolver_lr_grad.cpp:351
std::vector< std::vector< ModuleBase::matrix > > cal_grad_matrix_degenerate(const int ispin, const std::vector< int > &group, const std::vector< ModuleBase::matrix > &diag, std::ofstream &ofs)
The gradient matrix of one degenerate multiplet, $G^{(A\alpha)}_{kl}=\langle X_k|\partial A/\partial ...
Definition esolver_lr_grad.cpp:235
void set_dimension()
check the legality of the input parameters
Definition esolver_lr_cfg.cpp:16
void reset_dim_spin2()
reset nocc, nvirt, npairs after read ground-state wavefunction when nspin=2
Definition esolver_lr_cfg.cpp:112
Grid_Driver & gd() const
Definition esolver_lr_lcao_tddft.h:95
std::ofstream & ofs_running_
cached aliases, read once here instead of at every log/print call site below
Definition esolver_lr_lcao_tddft.h:74
int nstates
how many 2-particle states to be solved
Definition esolver_lr_lcao_tddft.h:151
int nbands_z_
Definition esolver_lr_lcao_tddft.h:223
std::unique_ptr< psi::Psi< T > > psi_ks_z_
Definition esolver_lr_lcao_tddft.h:218
void set_X_initial_guess()
Definition esolver_lr_orb.cpp:79
std::vector< int > nocc
number of occupied orbitals for each spin used in the calculation
Definition esolver_lr_lcao_tddft.h:141
ModuleBase::matrix cal_lr_force_relax_(std::ofstream &ofs)
Definition esolver_lr_rlx.cpp:245
const UnitCell * ucell_
Definition esolver_lr_lcao_tddft.h:70
void bind_ground_state_aliases_()
bind the aliases above; ks_ must already be set (or null for the lr path)
Definition esolver_lr_init.cpp:115
void resolve_target_multiplet_()
Fill target_group_ from the excitation energies of the current geometry.
Definition esolver_lr_rlx.cpp:182
const std::string in_dir
Definition esolver_lr_lcao_tddft.h:68
~ESolver_LR()
Definition esolver_lr_lcao_tddft.h:51
virtual double cal_energy() override
Definition esolver_lr_rlx.cpp:111
void set_parallel_orbitals_band(Parallel_Orbitals &p, const int nbands_in)
setup Parallel_Orbitals info. beyond Parallel_Blkcyclic
Definition esolver_lr_orb.cpp:16
ModuleBase::matrix force_gs_
Definition esolver_lr_lcao_tddft.h:173
const TwoCenterBundle * tcb_ptr_
Definition esolver_lr_lcao_tddft.h:90
Parallel_Grid & pgrid() const
Definition esolver_lr_lcao_tddft.h:97
void read_ks_chg(Charge &chg)
read in the ground state charge density
Definition esolver_lr_orb.cpp:299
std::unique_ptr< elecstate::Potential > pot_gs_hartree
Definition esolver_lr_lcao_tddft.h:127
int nbands
Definition esolver_lr_lcao_tddft.h:146
std::vector< ModuleBase::matrix > cal_force_openshell(const int istate_only=-1)
Definition esolver_lr_grad.cpp:327
virtual void init_pot(const Charge &chg_gs)
Definition esolver_lr_cfg.cpp:152
ModuleBase::matrix eig_ks
ground state bands, read from the file, or moved from ESolver_FP::pelec.ekb
Definition esolver_lr_lcao_tddft.h:119
bool excited_relax_
driving calculation = relax from an excited state
Definition esolver_lr_lcao_tddft.h:170
std::unique_ptr< elecstate::Potential > pot_gs
occupation number of all bands of ground state
Definition esolver_lr_lcao_tddft.h:126
virtual void cal_force(BaseCell &basecell, ModuleBase::matrix &force) override
Force on the atoms in the relaxed excited state, F = -d(E_gs + Omega)/dR (Ry/Bohr).
Definition esolver_lr_rlx.cpp:127
int nk
Definition esolver_lr_lcao_tddft.h:153
pseudopot_cell_vl * locpp_ptr_
Definition esolver_lr_lcao_tddft.h:93
void cal_force_and_grad_matrix_(const int ispin, std::ofstream &ofs)
Per-state gradients of every state, plus the gradient matrix of each degenerate multiplet when lr_deg...
Definition esolver_lr_grad.cpp:179
TwoCenterBundle two_center_bundle_own_
only used when ks_ is null
Definition esolver_lr_lcao_tddft.h:88
int nupdown
Definition esolver_lr_lcao_tddft.h:154
std::unique_ptr< psi::Psi< T > > psi_ks
ground state wave function
Definition esolver_lr_lcao_tddft.h:111
Parallel_Orbitals paraMat_
variables for parallel distribution of matrix in AO representation
Definition esolver_lr_lcao_tddft.h:232
std::vector< int > nvirt
number of virtual orbitals for each spin used in the calculation
Definition esolver_lr_lcao_tddft.h:144
std::vector< Parallel_Blkcyclic > paraX_z_
Definition esolver_lr_lcao_tddft.h:221
virtual void runner(BaseCell &basecell, int istep) override
run energy solver
Definition esolver_lr_lcao_tddft.cpp:35
std::unique_ptr< psi::Psi< T > > psi_ks_all_own_
Definition esolver_lr_lcao_tddft.h:116
std::vector< ModuleBase::matrix > cal_force_Xz(const int ispin, const ct::Tensor &Xz, const std::vector< double > &omega, const int label_begin)
Gradients for excitation vectors supplied by the caller, already widened into the Z window – the two ...
Definition esolver_lr_grad.cpp:148
ct::Tensor pad_X_to_z_(const int ispin, const int istate_begin, const int nst) const
Definition esolver_lr_grad.cpp:67
bool openshell
Definition esolver_lr_lcao_tddft.h:155
std::ofstream & ofs_warning_
Definition esolver_lr_lcao_tddft.h:75
ModuleBase::matrix lr_force_
The LR part of the excited-state force, -d(Omega)/dR (Ry/Bohr).
Definition esolver_lr_lcao_tddft.h:175
ct::Tensor solve_zvector_eqation(const int ispin, const int nst, const ct::Tensor &Xz, const std::vector< std::vector< ct::Tensor > > &window_density)
Solve the Z-vector equation for nst independent blocks of Xz.
Definition esolver_lr_grad.cpp:75
pseudopot_cell_vl & vloc() const
Definition esolver_lr_lcao_tddft.h:99
int target_state_
Definition esolver_lr_lcao_tddft.h:183
std::vector< std::shared_ptr< LR::PotHxcLR > > pot
Definition esolver_lr_lcao_tddft.h:106
std::vector< Parallel_Blkcyclic > paraX_
variables for parallel distribution of excited states
Definition esolver_lr_lcao_tddft.h:207
Parallel_Orbitals paraMat_all_
Definition esolver_lr_lcao_tddft.h:233
const int my_rank_
Definition esolver_lr_lcao_tddft.h:76
std::vector< std::string > spin_types
Definition esolver_lr_lcao_tddft.h:199
Grid_Driver gd_own_
only used when ks_ is null
Definition esolver_lr_lcao_tddft.h:87
bool ks_initialized_
whether initialize_from_ks_ has already run
Definition esolver_lr_lcao_tddft.h:163
std::unique_ptr< ModuleESolver::ESolver_KS_LCAO< T, TR > > ks_
the ground-state solver, kept alive across ionic steps (esolver_type = "ks-lr"). Null on the lr path,...
Definition esolver_lr_lcao_tddft.h:80
int target_ekb_offset_() const
index of the relaxed state inside pelec->ekb
Definition esolver_lr_lcao_tddft.h:194
void initialize_from_ks_(UnitCell &ucell, const Input_para &inp)
one-time setup from the ground-state solver; ends by calling refresh_from_ks_
Definition esolver_lr_init.cpp:147
std::unique_ptr< ModuleGint::GintInfo > gint_info_
Definition esolver_lr_lcao_tddft.h:201
std::vector< T > target_X_prev_
Definition esolver_lr_lcao_tddft.h:186
std::string xc_kernel
Definition esolver_lr_lcao_tddft.h:156
void follow_target_state_(std::ofstream &ofs)
Compare roots in a common electron-hole basis using exact cross-geometry AO overlap.
Definition esolver_lr_rlx.cpp:85
void refresh_from_ks_(UnitCell &ucell)
re-read everything that depends on the atomic positions, once per ionic step
Definition esolver_lr_init.cpp:251
const TwoCenterBundle & tcb() const
Definition esolver_lr_lcao_tddft.h:96
const std::string out_dir
Definition esolver_lr_lcao_tddft.h:69
std::vector< MultipletLVC > multiplet_lvc_
Definition esolver_lr_lcao_tddft.h:315
std::vector< ct::Tensor > X
used in lr-grad, in the ground-state Hxc gradient term coming from dF/dC
Definition esolver_lr_lcao_tddft.h:138
psi::Psi< T > * psi_ks_all_
all KS orbitals. On the ks-lr path this aliases the ground-state solver's psi (nk x nbands x nbasis –...
Definition esolver_lr_lcao_tddft.h:115
virtual void after_all_runners(BaseCell &basecell) override
perform post processing calculations
Definition esolver_lr_lcao_tddft.cpp:256
int nocc_max
full occupied count in the largest spin channel
Definition esolver_lr_lcao_tddft.h:143
void fill_z_window_(const int *desc_src)
Definition esolver_lr_orb.cpp:192
int nloc_per_state
Definition esolver_lr_lcao_tddft.h:139
LR::GradientInputs< T > gradient_inputs_() const
Definition esolver_lr_grad.cpp:133
double etxc_gs
ground-state Hartree potential, only used for test_force
Definition esolver_lr_lcao_tddft.h:128
Structure_Factor & sfac() const
Definition esolver_lr_lcao_tddft.h:98
std::vector< double > orb_cutoff_
Definition esolver_lr_lcao_tddft.h:71
virtual void read_ks_wfc()
read in the ground state wave function, band energy and occupation
Definition esolver_lr_orb.cpp:137
Grid_Driver * gd_ptr_
Definition esolver_lr_lcao_tddft.h:89
ModuleBase::matrix cal_jt_force_(const std::vector< ModuleBase::matrix > &diag, std::ofstream &ofs)
The force of the steepest-descending branch of the target multiplet, i.e. lr_degen_mode = jt.
Definition esolver_lr_rlx.cpp:287
std::shared_ptr< LR::PotHxcLR > pot_hxc_gs
Definition esolver_lr_lcao_tddft.h:132
LR::RootBasis< T > target_basis_prev_
Definition esolver_lr_lcao_tddft.h:187
Structure_Factor * sf_ptr_
Definition esolver_lr_lcao_tddft.h:92
virtual void cal_stress(BaseCell &basecell, ModuleBase::matrix &stress) override
Not implemented: there is no excited-state stress. cell-relax is rejected at input.
Definition esolver_lr_rlx.cpp:153
std::vector< std::complex< double > > velocity_mo
store the velocity matrix elements in MO basis
Definition esolver_lr_lcao_tddft.h:236
Parallel block-cyclic matrix distribution.
Definition parallel_blkcyc.h:25
Definition parallel_grid.h:8
Definition parallel_orbitals.h:16
Definition two_center_bundle.h:11
Provide the basic information about unitcell.
Definition unitcell.h:16
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
DensityMatrix Class <TK,TR> = <double,double> for Gamma-only calculation <TK,TR> = <std::complex<doub...
Definition density_matrix.h:172
Definition esolver_lr_lcao_tddft.h:28
The First-Principles (FP) Energy Solver Class.
Definition opt_test_tools.cpp:93
Definition state_track.h:25
The linear vibronic coupling (LVC) data of one degenerate multiplet.
Definition esolver_lr_lcao_tddft.h:301
int ispin
which spin channel (index into spin_types)
Definition esolver_lr_lcao_tddft.h:302
std::vector< int > states
the multiplet's state indices, ascending
Definition esolver_lr_lcao_tddft.h:303
std::vector< std::vector< ModuleBase::matrix > > g
G[k][l], symmetric, each a (nat, 3) force matrix – i.e. the 3N matrices of d x d.
Definition esolver_lr_lcao_tddft.h:307
int dim() const
Definition esolver_lr_lcao_tddft.h:308
ModuleBase::matrix average_force() const
Definition esolver_lr_rlx.cpp:380
double omega_spread
Definition esolver_lr_lcao_tddft.h:305
double omega0
the common excitation energy (Ry)
Definition esolver_lr_lcao_tddft.h:304
Definition esolver_lr_lcao_tddft.h:35
std::ofstream & warning_log
Definition esolver_lr_lcao_tddft.h:37
int rank
Definition esolver_lr_lcao_tddft.h:38
std::ofstream & running_log
Definition esolver_lr_lcao_tddft.h:36