@@ -62,6 +62,21 @@ inline int cal_nupdown_form_occ(const ModuleBase::matrix& wg)
6262 return nupdown;
6363}
6464
65+ inline void setup_2center_table (TwoCenterBundle& two_center_bundle, LCAO_Orbitals& orb, UnitCell& ucell)
66+ {
67+ // set up 2-center table
68+ #ifdef USE_NEW_TWO_CENTER
69+ two_center_bundle.tabulate ();
70+ #else
71+ two_center_bundle.tabulate (inp.lcao_ecut , inp.lcao_dk , inp.lcao_dr , inp.lcao_rmax );
72+ #endif
73+ if (PARAM.inp .vnl_in_h )
74+ {
75+ ucell.infoNL .setupNonlocal (ucell.ntype , ucell.atoms , GlobalV::ofs_running, orb);
76+ two_center_bundle.build_beta (ucell.ntype , ucell.infoNL .Beta );
77+ }
78+ }
79+
6580template <typename T, typename TR>
6681void LR::ESolver_LR<T, TR>::parameter_check()const
6782{
@@ -149,8 +164,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
149164 this ->gd = std::move (ks_sol.gd );
150165
151166 // xc kernel
152- this ->xc_kernel = inp.xc_kernel ;
153- std::transform (xc_kernel.begin (), xc_kernel.end (), xc_kernel.begin (), tolower);
167+ this ->xc_kernel = LR_Util::tolower (inp.xc_kernel );
154168 // kv
155169 this ->kv = std::move (ks_sol.kv );
156170
@@ -218,8 +232,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
218232 if (xc_kernel == " hf" || xc_kernel == " hse" )
219233 {
220234 // if the same kernel is calculated in the esolver_ks, move it
221- std::string dft_functional = input.dft_functional ;
222- std::transform (dft_functional.begin (), dft_functional.end (), dft_functional.begin (), tolower);
235+ std::string dft_functional = LR_Util::tolower (input.dft_functional );
223236 if (ks_sol.exx_lri_double && std::is_same<T, double >::value && xc_kernel == dft_functional) {
224237 this ->move_exx_lri (ks_sol.exx_lri_double );
225238 } else if (ks_sol.exx_lri_complex && std::is_same<T, std::complex <double >>::value && xc_kernel == dft_functional) {
@@ -237,6 +250,10 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
237250#endif
238251 this ->pelec = new elecstate::ElecStateLCAO<T>();
239252 orb_cutoff_ = ks_sol.orb_ .cutoffs ();
253+ if (LR_Util::tolower (input.abs_gauge ) == " velocity" )
254+ {
255+ this ->two_center_bundle_ = std::move (ks_sol.two_center_bundle_ );
256+ }
240257}
241258
242259template <typename T, typename TR>
@@ -247,8 +264,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
247264{
248265 ModuleBase::TITLE (" ESolver_LR" , " ESolver_LR(from scratch)" );
249266 // xc kernel
250- this ->xc_kernel = inp.xc_kernel ;
251- std::transform (xc_kernel.begin (), xc_kernel.end (), xc_kernel.begin (), tolower);
267+ this ->xc_kernel = LR_Util::tolower (inp.xc_kernel );
252268
253269 // necessary steps in ESolver_FP
254270 ESolver_FP::before_all_runners (ucell, inp);
@@ -272,6 +288,10 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
272288 LCAO_Orbitals orb;
273289 two_center_bundle_.to_LCAO_Orbitals (orb, inp.lcao_ecut , inp.lcao_dk , inp.lcao_dr , inp.lcao_rmax );
274290 orb_cutoff_ = orb.cutoffs ();
291+ if (LR_Util::tolower (input.abs_gauge ) == " velocity" )
292+ {
293+ setup_2center_table (this ->two_center_bundle_ , orb, ucell);
294+ }
275295
276296 this ->set_dimension ();
277297 // setup 2d-block distribution for AO-matrix and KS wfc
@@ -320,7 +340,6 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
320340 this ->init_pot (chg_gs);
321341
322342 // search adjacent atoms and init Gint
323- std::cout << " ucell.infoNL.get_rcutmax_Beta(): " << ucell.infoNL .get_rcutmax_Beta () << std::endl;
324343 double search_radius = -1.0 ;
325344 search_radius = atom_arrange::set_sr_NL (GlobalV::ofs_running,
326345 PARAM.inp .out_level ,
@@ -539,26 +558,21 @@ void LR::ESolver_LR<T, TR>::after_all_runners(UnitCell& ucell)
539558 auto spin_types = (nspin == 2 && !openshell) ? std::vector<std::string>({ " singlet" , " triplet" }) : std::vector<std::string>({ " updown" });
540559 for (int is = 0 ;is < this ->X .size ();++is)
541560 {
542- LR_Spectrum<T> spectrum (nspin,
543- this ->nbasis ,
544- this ->nocc ,
545- this ->nvirt ,
546- this ->gint_ ,
547- *this ->pw_rho ,
548- *this ->psi_ks ,
549- this ->ucell ,
550- this ->kv ,
551- this ->gd ,
552- this ->orb_cutoff_ ,
553- this ->paraX_ ,
554- this ->paraC_ ,
555- this ->paraMat_ ,
556- &this ->pelec ->ekb .c [is * nstates],
557- this ->X [is].template data <T>(),
558- nstates,
559- openshell);
561+ LR_Spectrum<T> spectrum (nspin, this ->nbasis , this ->nocc , this ->nvirt , this ->gint_ , *this ->pw_rho , *this ->psi_ks ,
562+ this ->ucell , this ->kv , this ->gd , this ->orb_cutoff_ , this ->two_center_bundle_ ,
563+ this ->paraX_ , this ->paraC_ , this ->paraMat_ ,
564+ &this ->pelec ->ekb .c [is * nstates], this ->X [is].template data <T>(), nstates, openshell,
565+ LR_Util::tolower (input.abs_gauge ));
560566 spectrum.transition_analysis (spin_types[is]);
561- spectrum.optical_absorption (freq, input.abs_broadening , spin_types[is]);
567+ if (spin_types[is] != " triplet" ) // triplets has no transition dipole and no contribution to the spectrum
568+ {
569+ spectrum.optical_absorption_method1 (freq, input.abs_broadening );
570+ // =============================================== for test ====================================================
571+ // spectrum.optical_absorption_method2(freq, input.abs_broadening, spin_types[is]);
572+ // spectrum.test_transition_dipoles_velocity_ks(eig_ks.c);
573+ // spectrum.write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_velocity_ks.dat");
574+ // =============================================== for test ====================================================
575+ }
562576 }
563577}
564578
0 commit comments