1313#include " module_base/lapack_connector.h"
1414#include " module_base/scalapack_connector.h"
1515#include " module_elecstate/module_charge/symmetry_rho.h"
16+ #include " module_elecstate/module_dm/cal_dm_psi.h"
1617#include " module_elecstate/module_dm/cal_edm_tddft.h"
18+ #include " module_elecstate/module_dm/density_matrix.h"
1719#include " module_elecstate/occupy.h"
1820#include " module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" // need divide_HS_in_frag
1921#include " module_hamilt_lcao/module_tddft/evolve_elec.h"
2325
2426// -----HSolver ElecState Hamilt--------
2527#include " module_elecstate/elecstate_lcao.h"
26- #include " module_elecstate/elecstate_lcao_tddft.h"
2728#include " module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
2829#include " module_hsolver/hsolver_lcao.h"
2930#include " module_parameter/parameter.h"
@@ -66,57 +67,11 @@ ESolver_KS_LCAO_TDDFT::~ESolver_KS_LCAO_TDDFT()
6667
6768void ESolver_KS_LCAO_TDDFT::before_all_runners (const Input_para& inp, UnitCell& ucell)
6869{
69- // 1) run "before_all_runners" in ESolver_KS
70- ESolver_KS::before_all_runners (inp, ucell);
71-
72- // 2) initialize the local pseudopotential with plane wave basis set
73- GlobalC::ppcell.init_vloc (GlobalC::ppcell.vloc , pw_rho);
74-
75- // 3) initialize the electronic states for TDDFT
76- if (this ->pelec == nullptr )
77- {
78- this ->pelec = new elecstate::ElecStateLCAO_TDDFT (&this ->chr ,
79- &kv,
80- kv.get_nks (),
81- &this ->GK , // mohan add 2024-04-01
82- this ->pw_rho ,
83- pw_big);
84- }
85-
86- // 4) read the local orbitals and construct the interpolation tables.
87- // initialize the pv
88- LCAO_domain::init_basis_lcao (this ->pv ,
89- inp.onsite_radius ,
90- inp.lcao_ecut ,
91- inp.lcao_dk ,
92- inp.lcao_dr ,
93- inp.lcao_rmax ,
94- ucell,
95- two_center_bundle_,
96- orb_);
97-
98- // 5) allocate H and S matrices according to computational resources
99- LCAO_domain::divide_HS_in_frag (PARAM.globalv .gamma_only_local , this ->pv , kv.get_nks (), orb_);
100-
101- // 6) initialize Density Matrix
102- dynamic_cast <elecstate::ElecStateLCAO<std::complex <double >>*>(this ->pelec )
103- ->init_DM (&kv, &this ->pv , PARAM.inp .nspin );
104-
105- // 8) initialize the charge density
106- this ->pelec ->charge ->allocate (PARAM.inp .nspin );
107- this ->pelec ->omega = GlobalC::ucell.omega ; // this line is very odd.
108-
109- // 9) initializee the potential
110- this ->pelec ->pot = new elecstate::Potential (pw_rhod,
111- pw_rho,
112- &GlobalC::ucell,
113- &(GlobalC::ppcell.vloc ),
114- &(sf),
115- &(pelec->f_en .etxc ),
116- &(pelec->f_en .vtxc ));
70+ // 1) run before_all_runners in ESolver_KS_LCAO
71+ ESolver_KS_LCAO<std::complex <double >, double >::before_all_runners (inp, ucell);
11772
11873 // this line should be optimized
119- this ->pelec_td = dynamic_cast <elecstate::ElecStateLCAO_TDDFT*>(this ->pelec );
74+ // this->pelec = dynamic_cast<elecstate::ElecStateLCAO_TDDFT*>(this->pelec);
12075}
12176
12277void ESolver_KS_LCAO_TDDFT::hamilt2density_single (const int istep, const int iter, const double ethr)
@@ -134,13 +89,13 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
13489 this ->psi_laststep ,
13590 this ->Hk_laststep ,
13691 this ->Sk_laststep ,
137- this ->pelec_td ->ekb ,
92+ this ->pelec ->ekb ,
13893 td_htype,
13994 PARAM.inp .propagator ,
14095 kv.get_nks ());
141- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
96+ this ->weight_dm_rho ( );
14297 }
143- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
98+ this ->weight_dm_rho ( );
14499 }
145100 else if (istep >= 2 )
146101 {
@@ -153,11 +108,11 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
153108 this ->psi_laststep ,
154109 this ->Hk_laststep ,
155110 this ->Sk_laststep ,
156- this ->pelec_td ->ekb ,
111+ this ->pelec ->ekb ,
157112 td_htype,
158113 PARAM.inp .propagator ,
159114 kv.get_nks ());
160- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
115+ this ->weight_dm_rho ( );
161116 }
162117 else
163118 {
@@ -168,7 +123,7 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
168123 {
169124 bool skip_charge = PARAM.inp .calculation == " nscf" ? true : false ;
170125 hsolver::HSolverLCAO<std::complex <double >> hsolver_lcao_obj (&this ->pv , PARAM.inp .ks_solver );
171- hsolver_lcao_obj.solve (this ->p_hamilt , this ->psi [0 ], this ->pelec_td , skip_charge);
126+ hsolver_lcao_obj.solve (this ->p_hamilt , this ->psi [0 ], this ->pelec , skip_charge);
172127 }
173128 }
174129
@@ -203,8 +158,7 @@ void ESolver_KS_LCAO_TDDFT::iter_finish(const int istep, int& iter)
203158 for (int ib = 0 ; ib < PARAM.inp .nbands ; ib++)
204159 {
205160 std::setprecision (6 );
206- GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " " << this ->pelec_td ->wg (ik, ib)
207- << std::endl;
161+ GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " " << this ->pelec ->wg (ik, ib) << std::endl;
208162 }
209163 }
210164 GlobalV::ofs_running << std::endl;
@@ -379,7 +333,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
379333 for (int ib = 0 ; ib < PARAM.inp .nbands ; ib++)
380334 {
381335 GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " "
382- << this ->pelec_td ->ekb (ik, ib) * ModuleBase::Ry_to_eV << std::endl;
336+ << this ->pelec ->ekb (ik, ib) * ModuleBase::Ry_to_eV << std::endl;
383337 }
384338 }
385339 GlobalV::ofs_running << std::endl;
@@ -417,4 +371,21 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep)
417371 ESolver_KS_LCAO<std::complex <double >, double >::after_scf (istep);
418372}
419373
374+ void ESolver_KS_LCAO_TDDFT::weight_dm_rho ()
375+ {
376+ if (PARAM.inp .ocp == 1 )
377+ {
378+ this ->pelec ->fixed_weights (PARAM.inp .ocp_kb , PARAM.inp .nbands , PARAM.inp .nelec );
379+ }
380+ this ->pelec ->calEBand ();
381+
382+ ModuleBase::GlobalFunc::NOTE (" Calculate the density matrix." );
383+
384+ auto _pes = dynamic_cast <elecstate::ElecStateLCAO<std::complex <double >>*>(this ->pelec );
385+ elecstate::cal_dm_psi (_pes->DM ->get_paraV_pointer (), _pes->wg , this ->psi [0 ], *(_pes->DM ));
386+ _pes->DM ->cal_DMR ();
387+
388+ this ->pelec ->psiToRho (this ->psi [0 ]);
389+ }
390+
420391} // namespace ModuleESolver
0 commit comments