|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Forward declaration for the linear-response solver. More...
#include <esolver_lr_lcao_tddft.h>
Classes | |
| struct | MultipletLVC |
| The linear vibronic coupling (LVC) data of one degenerate multiplet. More... | |
Public Member Functions | |
| ESolver_LR (const Input_para &inp, const std::string &in_dir, const std::string &out_dir, const LRRuntime &runtime) | |
| ~ESolver_LR () | |
| virtual void | before_all_runners (BaseCell &basecell, const Input_para &inp) override |
| input: input, call, basis(LCAO), psi(ground state), elecstate | |
| virtual void | runner (BaseCell &basecell, int istep) override |
| run energy solver | |
| virtual void | after_all_runners (BaseCell &basecell) override |
| perform post processing calculations | |
| virtual double | cal_energy () override |
| 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). | |
| virtual void | cal_stress (BaseCell &basecell, ModuleBase::matrix &stress) override |
| Not implemented: there is no excited-state stress. cell-relax is rejected at input. | |
| Public Member Functions inherited from ModuleESolver::ESolver_FP | |
| ESolver_FP () | |
| virtual | ~ESolver_FP () |
| Public Member Functions inherited from ModuleESolver::ESolver | |
| ESolver () | |
| virtual | ~ESolver () |
| virtual void | others (BaseCell &, const int) |
Protected Member Functions | |
| Grid_Driver & | gd () const |
| const TwoCenterBundle & | tcb () const |
| Parallel_Grid & | pgrid () const |
| Structure_Factor & | sfac () const |
| pseudopot_cell_vl & | vloc () const |
| void | bind_ground_state_aliases_ () |
| bind the aliases above; ks_ must already be set (or null for the lr path) | |
| void | initialize_from_unitcell_ (UnitCell &ucell, const Input_para &inp) |
| void | initialize_from_ks_ (UnitCell &ucell, const Input_para &inp) |
| one-time setup from the ground-state solver; ends by calling refresh_from_ks_ | |
| void | refresh_from_ks_ (UnitCell &ucell) |
| re-read everything that depends on the atomic positions, once per ionic step | |
| void | setup_relax_target_ () |
| void | follow_target_state_ (std::ofstream &ofs) |
| Compare roots in a common electron-hole basis using exact cross-geometry AO overlap. | |
| int | target_ekb_offset_ () const |
| index of the relaxed state inside pelec->ekb | |
| void | set_gint () |
| void | fill_z_window_ (const int *desc_src) |
| ct::Tensor | pad_X_to_z_ (const int ispin, const int istate_begin, const int nst) const |
| void | setup_eigenvectors_X () |
| allocate and set the inital value of X | |
| void | set_X_initial_guess () |
| virtual void | read_ks_wfc () |
| read in the ground state wave function, band energy and occupation | |
| void | read_ks_chg (Charge &chg) |
| read in the ground state charge density | |
| virtual void | init_pot (const Charge &chg_gs) |
| void | set_dimension () |
| check the legality of the input parameters | |
| void | reset_dim_spin2 () |
| reset nocc, nvirt, npairs after read ground-state wavefunction when nspin=2 | |
| void | set_parallel_orbitals_band (Parallel_Orbitals &p, const int nbands_in) |
| setup Parallel_Orbitals info. beyond Parallel_Blkcyclic | |
| void | init_pot_groundstate (const Charge &chg_gs) |
| ========================== for gradient calculation ========================= | |
| 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. | |
| std::vector< ModuleBase::matrix > | cal_force (const int ispin, const int istate_only=-1) |
| std::vector< ModuleBase::matrix > | cal_force_openshell (const int istate_only=-1) |
| 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 functions above are thin wrappers that widen the stored eigenvectors and look up their omega. | |
| 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 | |
| void | resolve_target_multiplet_ () |
| Fill target_group_ from the excitation energies of the current geometry. | |
| double | target_omega_ () const |
| ModuleBase::matrix | cal_lr_force_relax_ (std::ofstream &ofs) |
| 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. | |
| LR::GradientInputs< T > | gradient_inputs_ () const |
| ct::Tensor | pad_group_to_z_ (const int ispin, const std::vector< int > &group) const |
| 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_degen_thr asks for it. The single-point entry point. | |
| 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 R_{A\alpha}|X_l\rangle$. | |
| void | test_force () |
| module_dm::DensityMatrix< T, double > | cal_dm_gs () |
| ground-state density matrix | |
| Protected Member Functions inherited from ModuleESolver::ESolver_FP | |
| virtual void | before_scf (UnitCell &ucell, const int istep) |
| virtual void | after_scf (UnitCell &ucell, const int istep, const bool conv_esolver) |
| virtual void | iter_finish (UnitCell &ucell, const int istep, int &iter, bool &conv_esolver) |
| const vdw::VdwResult * | get_vdw_result () const |
Protected Attributes | |
| const std::string | in_dir |
| const std::string | out_dir |
| const UnitCell * | ucell_ = nullptr |
| std::vector< double > | orb_cutoff_ |
| std::ofstream & | ofs_running_ |
| cached aliases, read once here instead of at every log/print call site below | |
| std::ofstream & | ofs_warning_ |
| const int | my_rank_ |
| 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, where the ground state comes from files instead. | |
| Grid_Driver | gd_own_ |
| only used when ks_ is null | |
| TwoCenterBundle | two_center_bundle_own_ |
| only used when ks_ is null | |
| Grid_Driver * | gd_ptr_ = nullptr |
| const TwoCenterBundle * | tcb_ptr_ = nullptr |
| Parallel_Grid * | pgrid_ptr_ = nullptr |
| Structure_Factor * | sf_ptr_ = nullptr |
| pseudopot_cell_vl * | locpp_ptr_ = nullptr |
| std::vector< std::shared_ptr< LR::PotHxcLR > > | pot |
| std::unique_ptr< psi::Psi< T > > | psi_ks |
| ground state wave function | |
| psi::Psi< T > * | psi_ks_all_ = nullptr |
| all KS orbitals. On the ks-lr path this aliases the ground-state solver's psi (nk x nbands x nbasis – far too big to copy every ionic step, and only read here); on the lr path it points at psi_ks_all_own_, filled from file. | |
| std::unique_ptr< psi::Psi< T > > | psi_ks_all_own_ |
| ModuleBase::matrix | eig_ks |
| ground state bands, read from the file, or moved from ESolver_FP::pelec.ekb | |
| ModuleBase::matrix | eig_ks_all |
| all eigenvalues of ground state, read from the file, or moved from ESolver_FP::pelec.ekb | |
| ModuleBase::matrix | wg_ks |
| ModuleBase::matrix | wg_ks_all |
| occupation numbers of ground state in the [nocc+nvirt] window | |
| std::unique_ptr< elecstate::Potential > | pot_gs |
| occupation number of all bands of ground state | |
| std::unique_ptr< elecstate::Potential > | pot_gs_hartree |
| double | etxc_gs = 0. |
| ground-state Hartree potential, only used for test_force | |
| double | vtxc_gs = 0. |
| std::shared_ptr< LR::PotHxcLR > | pot_hxc_gs |
| std::vector< ct::Tensor > | X |
| used in lr-grad, in the ground-state Hxc gradient term coming from dF/dC | |
| int | nloc_per_state = 1 |
| std::vector< int > | nocc |
| number of occupied orbitals for each spin used in the calculation | |
| int | nocc_in = 1 |
| nocc read from input (adjusted by nelec): max(spin-up, spindown) | |
| int | nocc_max = 1 |
| full occupied count in the largest spin channel | |
| std::vector< int > | nvirt |
| number of virtual orbitals for each spin used in the calculation | |
| int | nvirt_in = 1 |
| nvirt read from input (adjusted by nelec): min(spin-up, spindown) | |
| int | nbands = 2 |
| int | nbasis = 2 |
| std::vector< int > | npairs |
| n_occ*nvirt, the basis size of electron-hole pair representation | |
| int | nstates = 1 |
| how many 2-particle states to be solved | |
| int | nspin = 1 |
| int | nk = 1 |
| int | nupdown = 0 |
| bool | openshell = false |
| std::string | xc_kernel |
| bool | ks_initialized_ = false |
| whether initialize_from_ks_ has already run | |
| bool | exx_owned_ = false |
| exx_lri was built here (so its Cs/Vs are ours to refresh) | |
| bool | excited_relax_ = false |
| driving calculation = relax from an excited state | |
| int | target_is_ = 0 |
| spin block of the relaxed state in X and pelec->ekb | |
| double | etot_gs_ = 0.0 |
| ground-state total energy of the current step (Ry) | |
| ModuleBase::matrix | force_gs_ |
| ModuleBase::matrix | lr_force_ |
| The LR part of the excited-state force, -d(Omega)/dR (Ry/Bohr). | |
| int | target_state_ = -1 |
| std::vector< T > | target_X_prev_ |
| LR::RootBasis< T > | target_basis_prev_ |
| std::vector< std::string > | spin_types |
| std::unique_ptr< ModuleGint::GintInfo > | gint_info_ = nullptr |
| Parallel_Blkcyclic | paraC_ |
| variables for parallel distribution of KS orbitals | |
| std::vector< Parallel_Blkcyclic > | paraX_ |
| variables for parallel distribution of excited states | |
| std::unique_ptr< psi::Psi< T > > | psi_ks_z_ |
| ModuleBase::matrix | eig_ks_z_ |
| Parallel_Blkcyclic | paraC_z_ |
| std::vector< Parallel_Blkcyclic > | paraX_z_ |
| std::vector< int > | nvirt_z_ |
| int | nbands_z_ = 0 |
| int | nloc_per_state_z_ = 0 |
| Parallel_Orbitals | paraMat_ |
| variables for parallel distribution of matrix in AO representation | |
| Parallel_Orbitals | paraMat_all_ |
| LCAO_Orbitals | orb_ |
| numerical atomic orbital data for single-point evaluation | |
| std::vector< std::complex< double > > | velocity_mo |
| store the velocity matrix elements in MO basis | |
| std::vector< MultipletLVC > | multiplet_lvc_ |
| std::vector< int > | target_group_ |
| 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. | |
Additional Inherited Members | |
| Public Attributes inherited from ModuleESolver::ESolver | |
| bool | conv_esolver = true |
| std::string | classname |
Forward declaration for the linear-response solver.
Excited State Solver: Linear Response TDDFT (Tamm Dancoff Approximation).
| ModuleESolver::ESolver_LR< T, TR >::ESolver_LR | ( | const Input_para & | inp, |
| const std::string & | in_dir, | ||
| const std::string & | out_dir, | ||
| const LRRuntime & | runtime ) |
|
inline |
|
overridevirtual |
perform post processing calculations
Reimplemented from ModuleESolver::ESolver_FP.
Reimplemented in ModuleESolver::ESolver_BSE< T, TR >.
|
overridevirtual |
input: input, call, basis(LCAO), psi(ground state), elecstate
Reimplemented from ModuleESolver::ESolver_FP.
Reimplemented in ModuleESolver::ESolver_BSE< T, TR >.
|
protected |
bind the aliases above; ks_ must already be set (or null for the lr path)
|
protected |
ground-state density matrix
|
overridevirtual |
Total energy of the excited state being relaxed: E_gs + Omega. Zero outside a relaxation, where nothing consumes it and the old behaviour is kept.
Implements ModuleESolver::ESolver.
|
overridevirtual |
Force on the atoms in the relaxed excited state, F = -d(E_gs + Omega)/dR (Ry/Bohr).
Implements ModuleESolver::ESolver.
|
protected |
Excited-state gradients d(Omega)/dR, one matrix per state solved. istate_only >= 0 restricts it to that one state: geometry relaxation follows a single state, and the Z-vector solve dominates the cost. -1 does all nstates.
|
protected |
Per-state gradients of every state, plus the gradient matrix of each degenerate multiplet when lr_degen_thr asks for it. The single-point entry point.
Fills multiplet_lvc_.
|
protected |
open-shell (spin-unrestricted) excited-state force: X holds [up | down] and every density matrix has two independent channels
|
protected |
open-shell counterpart of cal_force_Xz
|
protected |
Gradients for excitation vectors supplied by the caller, already widened into the Z window – the two functions above are thin wrappers that widen the stored eigenvectors and look up their omega.
The blocks of Xz need not be the eigenvectors the Casida diagonalizer returned. Any normalized vector inside a degenerate multiplet is an eigenvector with the same omega, so passing a linear combination is what turns the per-state gradient into the full degenerate-subspace gradient matrix; see cal_grad_matrix_degenerate and grad_degen.h.
| omega | excitation energy of each block (Ry); its size sets the block count |
| label_begin | state index the first block is reported under (labels only) |
|
protected |
The gradient matrix of one degenerate multiplet, $G^{(A\alpha)}_{kl}=\langle X_k|\partial A/\partial R_{A\alpha}|X_l\rangle$.
At a degeneracy no single state has a gradient vector – the branch slopes along a displacement $u$ are the eigenvalues of $\sum_{A\alpha}u_{A\alpha}G^{(A\alpha)}$, whose eigenvectors depend on $u$ – so this whole matrix, not its diagonal, is the first-order information. It is obtained from the polarization identity $G_{kl}=\mathcal F[(X_k{+}X_l)/\sqrt2]-\tfrac12(G_{kk}+G_{ll})$, which needs no new physics. grad_degen.h derives why that is exact.
| group | state indices of the multiplet, from LR::group_degenerate_states |
| diag | their per-state gradients, i.e. $G_{kk}$, already computed by cal_force |
| ofs | log stream the matrix and the precondition diagnostics are written to |
|
protected |
The force of the steepest-descending branch of the target multiplet, i.e. lr_degen_mode = jt.
Assembles the off-diagonal part of the gradient matrix (which average does not need), solves the joint direction/mixing optimization in LR::find_jt_direction, and returns that branch's own force. Once a step has split the multiplet there is no group left and the ordinary single-state path takes over, so the mode is self-limiting.
| diag | the multiplet's per-state forces, already computed |
|
protected |
The LR half of the force for the current geometry, following whichever surface lr_degen_mode selects. ofs receives the note when that is not a single state.
|
overridevirtual |
Not implemented: there is no excited-state stress. cell-relax is rejected at input.
Implements ModuleESolver::ESolver.
|
protected |
(re)build the Z window from psi_ks_all_ / eig_ks_all. desc_src describes the source wavefunction's 2D layout; unused (and may be null) in a serial build.
|
protected |
Compare roots in a common electron-hole basis using exact cross-geometry AO overlap.
Match the old subspace to current energy groups and refresh the single/group references. ofs receives the note when the followed root changes index, and the warning when no current root resembles the previous one.
|
inlineprotected |
|
protected |
|
protectedvirtual |
Reimplemented in ModuleESolver::ESolver_BSE< T, TR >.
|
protected |
========================== for gradient calculation =========================
========================= excited-state geometry relaxation =========================
11) calculate the structure factor
|
protected |
one-time setup from the ground-state solver; ends by calling refresh_from_ks_
|
protected |
read orbitals and build the interpolation table
|
protected |
Widen a multiplet's eigenvectors into the Z window, one block each. Members need not be contiguous, so they are padded one at a time.
|
protected |
Widen nst X blocks starting at istate_begin from the X window into the Z window, zero-filling the virtual rows X does not have.
|
inlineprotected |
|
protected |
read in the ground state charge density
|
protectedvirtual |
read in the ground state wave function, band energy and occupation
Reimplemented in ModuleESolver::ESolver_BSE< T, TR >.
|
protected |
re-read everything that depends on the atomic positions, once per ionic step
|
protected |
reset nocc, nvirt, npairs after read ground-state wavefunction when nspin=2
|
protected |
Fill target_group_ from the excitation energies of the current geometry.
|
overridevirtual |
run energy solver
Implements ModuleESolver::ESolver.
Reimplemented in ModuleESolver::ESolver_BSE< T, TR >.
|
protected |
check the legality of the input parameters
set nocc, nvirt, nbasis, npairs and nstates
|
protected |
|
protected |
setup Parallel_Orbitals info. beyond Parallel_Blkcyclic
|
protected |
global index map between (i,c) and ix
|
protected |
allocate and set the inital value of X
|
protected |
resolve and validate lr_target_state / lr_target_spin; call once the dimensions (and therefore openshell) are final
|
inlineprotected |
|
protected |
Solve the Z-vector equation for nst independent blocks of Xz.
|
inlineprotected |
index of the relaxed state inside pelec->ekb
|
protected |
The excitation energy the relaxation is minimising: the target state's own, or the multiplet average when target_group_ is set.
|
inlineprotected |
|
protected |
========================== test 1: reproduce the force of ground state =========================
======================================= END test 1 ========================================= ========================== test 2: reproduce the DX Hartree term =========================
======================================= END test 2 =========================================
|
inlineprotected |
|
protected |
ground state bands, read from the file, or moved from ESolver_FP::pelec.ekb
ground state eigenvalues in the [nocc+nvirt] window
|
protected |
all eigenvalues of ground state, read from the file, or moved from ESolver_FP::pelec.ekb
|
protected |
|
protected |
ground-state total energy of the current step (Ry)
|
protected |
ground-state Hartree potential, only used for test_force
|
protected |
driving calculation = relax from an excited state
|
protected |
exx_lri was built here (so its Cs/Vs are ours to refresh)
|
protected |
ground-state force of the current step (Ry/Bohr, F = -dE/dR)
|
protected |
only used when ks_ is null
|
protected |
|
protected |
|
protected |
|
protected |
the ground-state solver, kept alive across ionic steps (esolver_type = "ks-lr"). Null on the lr path, where the ground state comes from files instead.
|
protected |
whether initialize_from_ks_ has already run
|
protected |
|
protected |
The LR part of the excited-state force, -d(Omega)/dR (Ry/Bohr).
|
protected |
LVC data of every multiplet found at this geometry, rebuilt on each call of cal_force_and_grad_matrix_. Empty unless lr_degen_thr > 0.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
number of occupied orbitals for each spin used in the calculation
|
protected |
nocc read from input (adjusted by nelec): max(spin-up, spindown)
|
protected |
full occupied count in the largest spin channel
|
protected |
n_occ*nvirt, the basis size of electron-hole pair representation
|
protected |
|
protected |
how many 2-particle states to be solved
|
protected |
|
protected |
number of virtual orbitals for each spin used in the calculation
|
protected |
nvirt read from input (adjusted by nelec): min(spin-up, spindown)
|
protected |
|
protected |
cached aliases, read once here instead of at every log/print call site below
|
protected |
|
protected |
|
protected |
numerical atomic orbital data for single-point evaluation
|
protected |
|
protected |
|
protected |
variables for parallel distribution of KS orbitals
|
protected |
|
protected |
variables for parallel distribution of matrix in AO representation
|
protected |
|
protected |
variables for parallel distribution of excited states
|
protected |
|
protected |
|
protected |
|
protected |
occupation number of all bands of ground state
|
protected |
|
protected |
|
protected |
ground state wave function
KS orbitals used in the [nocc+nvirt] window
|
protected |
all KS orbitals. On the ks-lr path this aliases the ground-state solver's psi (nk x nbands x nbasis – far too big to copy every ionic step, and only read here); on the lr path it points at psi_ks_all_own_, filled from file.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The multiplet lr_target_state belongs to, or empty when the target is non-degenerate or lr_degen_mode = state. Refreshed every ionic step by resolve_target_multiplet_, and it is what makes cal_energy and the reported gradient describe the same surface.
|
protected |
spin block of the relaxed state in X and pelec->ekb
|
protected |
The state currently being followed, as an index into X / pelec->ekb. Seeded from lr_target_state on the first ionic step, then re-chosen at every later step by cross-geometry group overlap, then the single/JT reference. Following a fixed INDEX instead is what makes a relaxation fail near a degeneracy: the index always names the n-th lowest root, so as soon as two surfaces cross, "the target" jumps to a different diabatic state and the force is discontinuous. CG assumes a conservative field and cannot recover from that.
|
protected |
Previous ionic step's amplitude for the followed state (local part), the reference the overlap is taken against. Empty on the first step.
|
protected |
|
protected |
only used when ks_ is null
|
protected |
|
protected |
store the velocity matrix elements in MO basis
|
protected |
|
protected |
|
protected |
occupation numbers of ground state in the [nocc+nvirt] window
|
protected |
used in lr-grad, in the ground-state Hxc gradient term coming from dF/dC
Excited state wavefunction (locc, lvirt are local size of nocc and nvirt in each process) size of X: [neq][{nstate, nloc_per_state}], namely:
|
protected |